|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [mini-os master] mini-os: let memory allocation fail if no free page available
commit 03d8b0f12b07ec914da9e6c258e1a1c7ac5d86f8
Author: Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Mon Jul 18 16:46:11 2016 +0200
Commit: Juergen Gross <jgross@xxxxxxxx>
CommitDate: Thu Aug 11 13:03:52 2016 +0200
mini-os: let memory allocation fail if no free page available
Instead of panicing when no page can be allocated try to fail the
memory allocation by returning NULL instead.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Acked-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
---
mm.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm.c b/mm.c
index 263a356..8cf3210 100644
--- a/mm.c
+++ b/mm.c
@@ -335,6 +335,13 @@ void *sbrk(ptrdiff_t increment)
if (new_brk > heap_mapped) {
unsigned long n = (new_brk - heap_mapped + PAGE_SIZE - 1) / PAGE_SIZE;
+
+ if ( n > nr_free_pages )
+ {
+ printk("Memory exhausted: want %ld pages, but only %ld are left\n",
+ n, nr_free_pages);
+ return NULL;
+ }
do_map_zero(heap_mapped, n);
heap_mapped += n * PAGE_SIZE;
}
--
generated by git-patchbot for /home/xen/git/mini-os.git#master
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |