From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: erik quanstrom Date: Wed, 2 Sep 2009 09:32:01 -0400 To: 9fans@9fans.net In-Reply-To: <599f06db0909020158t4f608b1cgec50f1b5120e68c3@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Subject: Re: [9fans] lowest valid stack address Topicbox-Message-UUID: 5ebc5e76-ead5-11e9-9d60-3106f5b1d025 > > Exactly two years ago you started a thread about > > memory overcommit. If I remember correctly, plan9 > > overcommits vm. Few weeks later the Go program i thought this was common knowledge, and so i ommitted recounting the discussion. since it's not common knowledge i'll recount. plan 9 overcommits vm. a large amount of this overcommit is due to the stack, since the kernel gives each process a 16mb segment. overcommit means you can malloc n bytes or even use a few extra bytes on the stack but will fault when accessing it. needless to say, overcommit is not much fun. executables are paged out even with no swap. the reason for the crash of the Go program is that the stack segment is 16mb. while plan 9 will demand load and zero fill within the stack segment, it's just a fault to try to access memory outside of any segment. therefore, we know the Go program had a stack >=16mb. (by careful arrangement, the page below the stack is generally invalid — it's not in any segment.) the bss, stack and shared segments are zero-filled on demand. it doesn't appear they can be paged out. > If you don´t touch the memory, > it never gets mapped in, so you may reserve a big chunk, but it has to fit > in your vm in the space between the stack and the bss. In my go program > I was reserving something unreasonable like 1Gb the maximum segment allowed by the pc kernel is 1984mb. (SEGMAPSIZE*PTEPERTAB*BY2PG), see segment.c:/^by2pg - erik