From 67d4e8403fe12592f99cf6fc51e4f33684899d6b Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 20 Apr 2011 23:35:42 +0200 Subject: 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. --- ipc/mach_port.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ipc') diff --git a/ipc/mach_port.c b/ipc/mach_port.c index 122d5d9..904fd14 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -205,11 +205,14 @@ mach_port_names( size = size_needed; kr = vm_allocate(ipc_kernel_map, &addr1, size, TRUE); - if (kr != KERN_SUCCESS) + if (kr != KERN_SUCCESS) { + printf_once("no more room in ipc_kernel_map\n"); return KERN_RESOURCE_SHORTAGE; + } kr = vm_allocate(ipc_kernel_map, &addr2, size, TRUE); if (kr != KERN_SUCCESS) { + printf_once("no more room in ipc_kernel_map\n"); kmem_free(ipc_kernel_map, addr1, size); return KERN_RESOURCE_SHORTAGE; } @@ -982,8 +985,10 @@ mach_port_get_set_status( ipc_pset_t pset; kr = vm_allocate(ipc_kernel_map, &addr, size, TRUE); - if (kr != KERN_SUCCESS) + if (kr != KERN_SUCCESS) { + printf_once("no more room in ipc_kernel_map\n"); return KERN_RESOURCE_SHORTAGE; + } /* can't fault while we hold locks */ -- cgit v1.2.3