From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id EC3BF469719 for ; Fri, 14 Feb 2020 10:54:18 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id y6so9664002lji.0 for ; Thu, 13 Feb 2020 23:54:18 -0800 (PST) Date: Fri, 14 Feb 2020 10:54:16 +0300 From: Cyrill Gorcunov Message-ID: <20200214075416.GS21061@uranus> References: <20200213205618.7982-1-gorcunov@gmail.com> <20200213205618.7982-2-gorcunov@gmail.com> <46c82f5e-5e4c-ec4a-b8ce-b999e6a6230c@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46c82f5e-5e4c-ec4a-b8ce-b999e6a6230c@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v7 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: Vladislav Shpilevoy Cc: tml On Fri, Feb 14, 2020 at 12:26:04AM +0100, Vladislav Shpilevoy wrote: > Thanks for the fixes! > > > @@ -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; > > + > > Why is it static? From what I know, when it is static we don't > have a guarantee, that it won't occupy memory in the .data section. it is not about memory occupation but rather init it once instead of doing so during function prologue. It actually depends on compiler and modern ones would simply optimize this assignment. Actually there is one hidden idea -- R|W is initial flags the 'small' uses when allocates memory that's why I mention this variable in comment. > Even though here it is clearly not necessary. Wouldn't just const > be enough? Why was not it possible to leave these flags inlined in > fiber_mprotect() call? They are not used anywhere else. PROT_NONE, > for example, is left inlined. PROT_NONE is special, it is unrelated to 'small'. Cyrill