[Tarantool-patches] [PATCH v7 1/2] fiber: set diagnostics at madvise/mprotect failure
Cyrill Gorcunov
gorcunov at gmail.com
Fri Feb 14 10:54:16 MSK 2020
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
More information about the Tarantool-patches
mailing list