summaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-04-20 23:35:42 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-04-20 23:40:16 +0200
commit67d4e8403fe12592f99cf6fc51e4f33684899d6b (patch)
treec4f8ed13d12ab04e067d396dd3c39b6afeadeb1a /vm
parenta44f51203c43bb4306a225506075740cdacaccfa (diff)
Warn once when part of the kernel is lacking memory
* kern/printf.h (printf_once): New macro. * ipc/mach_port.c (mach_port_names, mach_port_get_set_status): Warn when returning KERN_RESOURCE_SHORTAGE. * vm/vm_kern.c: Include printf.h. (kmem_alloc, kmem_realloc, kmem_alloc_wired, kmem_alloc_aligned, kmem_alloc_pageable): Warn when failing. * vm/vm_resident.c (vm_page_grab_contiguous_pages): Warn when returning KERN_RESOURCE_SHORTAGE.
Diffstat (limited to 'vm')
-rw-r--r--vm/vm_kern.c9
-rw-r--r--vm/vm_resident.c2
2 files changed, 10 insertions, 1 deletions
diff --git a/vm/vm_kern.c b/vm/vm_kern.c
index dc7f7e4..cfa33ff 100644
--- a/vm/vm_kern.c
+++ b/vm/vm_kern.c
@@ -43,6 +43,7 @@
#include <kern/debug.h>
#include <kern/lock.h>
#include <kern/thread.h>
+#include <kern/printf.h>
#include <vm/pmap.h>
#include <vm/vm_fault.h>
#include <vm/vm_kern.h>
@@ -387,6 +388,7 @@ kmem_alloc(map, addrp, size)
kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0,
VM_OBJECT_NULL, &entry);
if (kr != KERN_SUCCESS) {
+ printf_once("no more room for kmem_alloc in %p\n", map);
vm_map_unlock(map);
vm_object_deallocate(object);
return kr;
@@ -453,6 +455,7 @@ kern_return_t kmem_realloc(map, oldaddr, oldsize, newaddrp, newsize)
VM_OBJECT_NULL, &newentry);
if (kr != KERN_SUCCESS) {
vm_map_unlock(map);
+ printf_once("no more room for kmem_realloc in %p\n", map);
return kr;
}
@@ -537,6 +540,7 @@ kmem_alloc_wired(map, addrp, size)
kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0,
kernel_object, &entry);
if (kr != KERN_SUCCESS) {
+ printf_once("no more room for kmem_alloc_wired in %p\n", map);
vm_map_unlock(map);
return kr;
}
@@ -611,6 +615,7 @@ kmem_alloc_aligned(map, addrp, size)
kr = vm_map_find_entry(map, &addr, size, size - 1,
kernel_object, &entry);
if (kr != KERN_SUCCESS) {
+ printf_once("no more rooom for kmem_alloc_aligned in %p\n", map);
vm_map_unlock(map);
return kr;
}
@@ -672,8 +677,10 @@ kmem_alloc_pageable(map, addrp, size)
(vm_offset_t) 0, TRUE,
VM_OBJECT_NULL, (vm_offset_t) 0, FALSE,
VM_PROT_DEFAULT, VM_PROT_ALL, VM_INHERIT_DEFAULT);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ printf_once("no more room for kmem_alloc_pageable in %p\n", map);
return kr;
+ }
*addrp = addr;
return KERN_SUCCESS;
diff --git a/vm/vm_resident.c b/vm/vm_resident.c
index b23e0f3..a633498 100644
--- a/vm/vm_resident.c
+++ b/vm/vm_resident.c
@@ -976,6 +976,7 @@ vm_page_grab_contiguous_pages(
if ((vm_page_free_count < vm_page_free_reserved)
|| (vm_page_external_count >= vm_page_external_limit)) {
+ printf_once("no more room for vm_page_grab_contiguous_pages");
simple_unlock(&vm_page_queue_free_lock);
return KERN_RESOURCE_SHORTAGE;
}
@@ -1064,6 +1065,7 @@ count_ones:
*/
simple_unlock(&vm_page_queue_free_lock);
+ printf_once("no contiguous room for vm_page_grab_contiguous_pages");
ret = KERN_RESOURCE_SHORTAGE;
goto out;