[PATCH 2/3] slab_arena: Provide slab_arena_madvise_create to madvice slabs

Alexander Turenko alexander.turenko at tarantool.org
Mon May 6 16:46:59 MSK 2019


> > +#ifdef TARANTOOL_SMALL_HAS_MADVISE
> > +/**
> > + * slab_arena_madvise_create - Initialize madvise permanent strategy
> > + * @arena:	slab arena to madvise
> > + * @advice:	strategy (MADV_DONTDUMP, ...)
> > + *
> > + * This function setups @slab_arena strategy so that new memory
> > + * allocation with mmap() call gets madvise() call with @advice.
> > + *
> > + * Note that we don't allow to change strategy once choosen because
> > + * otherwise we need to walk over all possible slab cache entry.
> > + *
> > + * This function should be called right after the slab arena creation,
> > + * otherwise if called later some of the non-preallocated slabs won't be
> > + * madvise'd.
> > + */
> > +int
> > +slab_arena_madvise_create(struct slab_arena *arena, int advice)
> 
> I don't see much point in changing madvise settings on the fly.
> Let's instead allow to pass DONTDUMP flag at creation time.
> This means we have to combine MAP_ and MADV_ flags. I guess it
> was a bad idea to pass MAP_ flags directly to small_create() in
> the first place. What about introducing small-specific flags like
> 
>   SLAB_ARENA_SHARED
>   SLAB_ARENA_DONTDUMP
> 
> Come to think of it, I assume we don't even need to introduce
> SLAB_ARENA_SHARED - we always pass MAP_PRIVATE to small_create().
> Let's drop it, perhaps?
> 
> It will break backward compatibility, but I don't think it really
> matters, as tarantool/small is only used by tarantool - it isn't
> a big deal if we change its API. We only need to bump the version
> number, I guess.
> 
> Alexander, please amend me if I'm wrong.

I don't know other users of the library, so incompatiable changes looks
okay.

I would release a new version (an annotated tag + a github release) and
mention incompatible changes to let potential users know about this.
Maybe this is too formal, don't know :)

WBR, Alexander Turenko.



More information about the Tarantool-patches mailing list