Re: stack hogs in kernel

From: Robert Watson <rwatson_at_FreeBSD.org>
Date: Tue, 15 Apr 2008 13:19:58 +0100 (BST)
On Tue, 15 Apr 2008, Andrew Reilly wrote:

> Why are single-digit kilobytes of memory space interesting, in this context? 
> Is the concern about L1 data cache footprint, for performance reasons?  If 
> that is the case, the MAXPATHLEN bufffer will only really occupy the amount 
> of cache actually touched.
>
> I've long wondered about the seemingly fanatical stack size concern in 
> kernel space.  In other domains (where I have more experience) you can get 
> good performance benefits from the essentially free memory management and 
> good cache re-use that comes from putting as much into the stack/call-frame 
> as possible.

In addition to the valid points others have replied with (use of KVA, often 
not swappable, etc), it's worth noting that as with file descriptors, vnodes, 
sockets, inodes, etc, kernel thread size directly affects overall kernel 
scalability, as we require one kernel thread for each user thread in the 
system.  If you have 4000 user threads, you have 4000 (plus change) kernel 
threads, so avoiding statically allocating large quantities of effectively 
unused memory can significantly improve memory pressure, especially on 
relatively small systems.

Robert N M Watson
Computer Laboratory
University of Cambridge
Received on Tue Apr 15 2008 - 10:19:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:29 UTC