Re: How much kernel stack do we need?

John G. Alvord (jalvo@cloud9.net)
Fri, 19 Jun 1998 21:26:25 GMT


On Fri, 19 Jun 1998 19:55:13 +0200 (CEST), Rik van Riel
<H.H.vanRiel@phys.uu.nl> wrote:

>On Fri, 19 Jun 1998, Bernd Schmidt wrote:
>
>> In 2.1.x kernels, the kernel stack size is 8192 bytes (2 pages) on the i386,
>> minus the size of the task structure (around 1000). This means the stack is
>> more than 3000 bytes larger than in 2.0.x where it used to be one page. My
>> question is: do we really need this?
>
>This is a _very_ good question, since it could save us one
>unswappable page _per process_. This might not seem like
>an awful lot of memory, but with the current fragmentation
>problems this patch could save our butt...
>(at least until the zone allocator is ready)
>
>[snip measurements]
>> that allocate a 2000 byte array on the stack. Does anyone else think it
>> would be worthwhile to fix those and reduce the kernel stack size again?
>
>Absolutely. Just think about someone running 60 processes
>on a 4MB machine. This person is now wasting 60 * 4k =
>240kB of _unswappable_ memory. That is 1/16th of total
>memory, which can be very taxing on your router/mailserver.
>
>> I have a patch that makes the stack size configurable (I've even tested it...)
>> which I could provide if someone is interested.

You could experiment by initializing the stack such that only a portion
was used. For example, allocate 4K, allocate kernel stuff, and then set
the pointers such that only 1K is available for use. That would expose
the memory hogs quickly. That is a pure debug case, of coruse.

john alvord

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu