Subject: Re: 'growable' mmap regions
To: Jaromir Dolecek <jdolecek@NetBSD.org>
From: Antti Kantee <pooka@cs.hut.fi>
List: tech-kern
Date: 08/29/2004 15:36:53
On Sat Aug 28 2004 at 00:59:16 +0200, Jaromir Dolecek wrote:
> Linux has concept of 'growable' mmap region. This is used for thread
> stack memory - memory is allocated using mmap(2) with special flag
> and passed as stack for a new thread via clone(2).  Then the memory
> block is automatically extended when the page fault happens below
> the currently-mapped memory block, up to the per-thread stack size
> limit.
> 
> I'm thinking of a good way to emulate this. Do we want to be able
> to have stack-like memory segments like this? Currently the page
> fault code handling growing of stack hardcodes check against USRSTACK, so
> it's limited only to the (single) stack allocated on process execution.

What I did in the FreeBSD comapt code for MAP_STACK was to not bother
with it, for reasons you state below.  I just adjusted the flags to map
normal MAP_ANON memory, and it's worked well so far.

> I'm not really convinced this is very useful when using virtual memory 
> management - such scheme doesn't preserve VA space (since the space must
> be reserved for the stack grow anyway), and physical pages are
> allocated on-demand, so bigger memory piece doesn't waste more physical RAM
> than the small one (with overcommit, at least).

-- 
Antti Kantee <pooka@iki.fi>                     Of course he runs NetBSD
http://www.iki.fi/pooka/                          http://www.NetBSD.org/
                 "connoisseurs do not chill their malts."