From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHrAD-0002yJ-CV for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHrA9-0003R6-48 for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:26:44 -0400 Received: from mx5-phx2.redhat.com ([209.132.183.37]:49525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHrA8-0003R1-RG for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:26:41 -0400 Date: Tue, 28 Jun 2016 07:26:31 -0400 (EDT) From: Paolo Bonzini Message-ID: <1463796867.2611951.1467113191380.JavaMail.zimbra@redhat.com> In-Reply-To: <57725BD6.4040305@kamp.de> References: <1467104499-27517-1-git-send-email-pl@kamp.de> <1467104499-27517-4-git-send-email-pl@kamp.de> <57725BD6.4040305@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/15] coroutine-ucontext: reduce stack size to 64kB List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: qemu-devel@nongnu.org, kwolf@redhat.com, peter maydell , mst@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, kraxel@redhat.com ----- Original Message ----- > From: "Peter Lieven" > To: "Paolo Bonzini" , qemu-devel@nongnu.org > Cc: kwolf@redhat.com, "peter maydell" , mst@redhat.com, dgilbert@redhat.com, > mreitz@redhat.com, kraxel@redhat.com > Sent: Tuesday, June 28, 2016 1:13:26 PM > Subject: Re: [PATCH 03/15] coroutine-ucontext: reduce stack size to 64kB > > Am 28.06.2016 um 12:54 schrieb Paolo Bonzini: > > > > On 28/06/2016 11:01, Peter Lieven wrote: > >> evaluation with the recently introduced maximum stack size monitoring > >> revealed > >> that the actual used stack size was never above 4kB so allocating 1MB > >> stack > >> for each coroutine is a lot of wasted memory. So reduce the stack size to > >> 64kB which should still give enough head room. > > If we make the stack this much smaller, there is a non-zero chance of > > smashing it. You must add a guard page if you do this (actually more > > than one because QEMU will happily have stack frames as big as 16 KB). > > The stack counts for RSS but it's not actually allocated memory, so why > > does it matter? > > Is there an easy way to determinate how much of the RSS is actually > allocated? I erroneously it was all allocated.... > > So as for the stack, the MAP_GROWSDOWN is it really important? Will the > kernel > allocate all pages of the stack otherwise if the last page is written? > > I am asking because I don't know if MAP_GROWSDOWN is a good idea as Peter > mentioned there were discussions to deprecate it. I don't know, I found those discussions too. However I've also seen an interesting patch to ensure a guard page is kept at the bottom of the VMA. But thinking more about it, if you use MAP_GROWSDOWN you don't know anymore where the bottom of the stack and you cannot free it correctly, can you? Or am I completely misunderstanding the purpose of the flag? I guess it's better to steer clear of it unless we're ready to look at kernel code for a while... Paolo