From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHqob-0008Vg-Mm for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:04:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHqoV-0006uq-10 for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:04:24 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:33384) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHqoU-0006ue-Qu for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:04:18 -0400 Received: by mail-wm0-x243.google.com with SMTP id r201so4953056wme.0 for ; Tue, 28 Jun 2016 04:04:18 -0700 (PDT) Sender: Paolo Bonzini References: <1467104499-27517-1-git-send-email-pl@kamp.de> <1467104499-27517-2-git-send-email-pl@kamp.de> From: Paolo Bonzini Message-ID: Date: Tue, 28 Jun 2016 13:04:13 +0200 MIME-Version: 1.0 In-Reply-To: <1467104499-27517-2-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 01/15] coroutine-ucontext: mmap stack memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven , qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, mst@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, kraxel@redhat.com On 28/06/2016 11:01, Peter Lieven wrote: > +#ifdef MAP_GROWSDOWN > + co->stack = mmap(NULL, COROUTINE_STACK_SIZE, PROT_READ | PROT_WRITE, > + MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN, -1, 0); > + if (co->stack == MAP_FAILED) { > + abort(); > + } > + /* add a guard page at bottom of the stack */ > + if (mmap(co->stack, getpagesize(), PROT_NONE, > + MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN, -1, 0) == MAP_FAILED) { > + abort(); > + } Nevermind, you added a guard page! Good! :) And actually it looks like the stack usage has been mostly tamed, at least for the block layer. On the other hand MAP_GROWSDOWN automatically adds a guard page since Linux 3.9 (see commit 09884964335e, "mm: do not grow the stack vma just because of an overrun on preceding vma", 2013-02-27), so as it turns out you don't even need the guard page! Paolo > +#else > co->stack = g_malloc(stack_size); > +#endif