Re: Q: Darwin panicing too soon?
Re: Q: Darwin panicing too soon?
- Subject: Re: Q: Darwin panicing too soon?
- From: Stéphane Sudre <email@hidden>
- Date: Wed, 6 Aug 2003 19:24:38 +0200
Le mercredi, 6 ao{ 2003, ` 16:12 Europe/Paris, Jim Magee a icrit :
On Wednesday, August 6, 2003, at 7:04 AM, Jonas Maebe wrote:
On woensdag, aug 6, 2003, at 12:50 Europe/Brussels, Stiphane Sudre
wrote:
} else if (retval != KERN_RESOURCE_SHORTAGE) {
/* would like to cause a zone_gc() */
(1) panic("zalloc");
}
----
Q: Instead of panicing at (1), couldn't it just be possible to
return NULL?
KERN_RESOURCE_SHORTAGE is described as:
/* A system resource could not be allocated to fulfill
* this request. This failure may not be permanent.
*/
The issue is that once you "Kernel Panic"ed, it's 'permanent' till
the next reboot.
Note that it panics if retval is *different* from
KERN_RESOURCE_SHORTAGE". So in case of KERN_RESOURCE_SHORTAGE,
whatever comes below will be executed.
Correct. The issue is that most kernel code expects zalloc() to wait
until memory is available. They only expect a NULL return in the
cases that they specified that they are unwilling to block for memory
allocation. However, one of the "different from
KERN_RESOURCE_SHORTAGE" errors actually occurs as a result of the
kernel's virtual address space being exhausted (rather than just being
short of free page frames at the moment). It is extremely unlikely
that this "exhausted virtual memory space" situation will rectify
itself by having the current thread wait. So we panic.
This is somewhat analogous to malloc(). It will normally wait for
memory to become available (including waiting for the kernel to select
and page out other application pages, etc...). But if the virtual
address space of your application is completely exhausted, there's not
much that can be done.
The good news is that the Darwin 10.7 (Panther) PowerPC[1] kernel
supports a significantly larger kernel virtual address space. So the
odds of hitting that panic go WAY down (most existing machines can't
handle enough physical memory to trigger it). There are also
additional hand and soft resource limits added to keep applications
from inducing run-away kernel allocations.
Side question: Is there a way or a tool to monitor kernel memory (free)
space?
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.