Shrinking the x86 stack
[Posted December 10, 2002 by corbet]
The kernel stack on x86 systems is two pages - 8KB - in length. This stack
area exists for every process on the system; one can easily see that, in a
system with a large number of processes, the amount of memory given over to
stacks could get large. This memory is unpageable kernel memory; it also
requires an "order one" (two page) allocation for every new process. As
memory becomes fragmented, multi-page allocations get harder to satisfy,
and creation of new processes can fail. So there are plenty of reasons for
wanting to reduce the size of the kernel stack.
Dave Hansen has posted a patch (originally
by Ben LaHaise) which cuts the per-process kernel stack down to a single
page. To accomplish that, this patch must do a few things:
This patch does not try to address the problem of kernel code which puts
large variables on the stack. Heavy stack usage has always been considered
poor form, but there are still kernel functions which do it. A smaller
kernel stack would, undoubtedly, increase interest in fixing those
functions.
A variant of the smaller-stack patch has been circulated before, but Linus
has not commented on it. It is not clear whether this patch, at this time,
would pass the "feature freeze" test. The idea probably makes enough sense
to be integrated at some point, however, whether in this development series
or the next.
(
Log in to post comments)