Re: Q: Darwin panicing too soon?
Re: Q: Darwin panicing too soon?
- Subject: Re: Q: Darwin panicing too soon?
- From: Jim Magee <email@hidden>
- Date: Wed, 6 Aug 2003 10:12:35 -0400
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.
--Jim
[1]. The i386 kernel still maps the kernel as part of each task, so
it's kernel virtual space is still much smaller (and the application's
available virtual space is also smaller). The PowerPC kernel has
separate 4GB address spaces for the kernel vs. each application.
_______________________________________________
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.