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