From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id AD9E2469719 for ; Fri, 21 Feb 2020 00:30:49 +0300 (MSK) References: <20200214132220.29830-1-gorcunov@gmail.com> <20200214132220.29830-2-gorcunov@gmail.com> From: Vladislav Shpilevoy Message-ID: Date: Thu, 20 Feb 2020 22:30:48 +0100 MIME-Version: 1.0 In-Reply-To: <20200214132220.29830-2-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v8 1/2] fiber: set diagnostics at madvise/mprotect failure List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov , tml Hi! Thanks for the patch! > diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c > index 00ae8cded..f10687b29 100644 > --- a/src/lib/core/fiber.c > +++ b/src/lib/core/fiber.c > @@ -1007,6 +1035,8 @@ fiber_stack_watermark_create(struct fiber *fiber) > static void > fiber_stack_destroy(struct fiber *fiber, struct slab_cache *slabc) > { > + static const int mprotect_flags = PROT_READ | PROT_WRITE; > + Well, seems like you won't change this. Ok, since I can't do anything about that, I have nothing to do but to say the patchset is ok. > if (fiber->stack != NULL) { > VALGRIND_STACK_DEREGISTER(fiber->stack_id); > #if ENABLE_ASAN > @@ -1017,7 +1047,22 @@ fiber_stack_destroy(struct fiber *fiber, struct slab_cache *slabc) > guard = page_align_down(fiber->stack - page_size); > else > guard = page_align_up(fiber->stack + fiber->stack_size); > - fiber_mprotect(guard, page_size, PROT_READ | PROT_WRITE); > + > + if (fiber_mprotect(guard, page_size, mprotect_flags) != 0) { > + /* > + * FIXME: We need some intelligent handling: > + * say put this slab into a queue and retry > + * to setup the original protection back in > + * background. > + * > + * Note that in case if we're called from > + * fiber_stack_create() the @a mprotect_flags is You could just say "protection flags are the same as the slab..." instead of mentioning a variable here. If you didn't think that enum would be good here.