From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: Date: Mon, 13 May 2019 13:30:32 +0300 From: Cyrill Gorcunov Subject: Re: [RFC v2] slab_arena: Enhance slab_arena_create to support madvise hints Message-ID: <20190513103032.GB2544@uranus.lan> References: <20190506174321.11614-1-gorcunov@gmail.com> <20190513100642.h3ye4sphinkcemv4@esperanza> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190513100642.h3ye4sphinkcemv4@esperanza> To: Vladimir Davydov Cc: tml , Alexander Turenko List-ID: On Mon, May 13, 2019 at 01:06:42PM +0300, Vladimir Davydov wrote: > > > > +set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") > > + > > +check_symbol_exists(MAP_ANON sys/mman.h TARANTOOL_SMALL_HAVE_MAP_ANON) > > +check_symbol_exists(MAP_ANONYMOUS sys/mman.h TARANTOOL_SMALL_HAVE_MAP_ANONYMOUS) > > + > > +check_function_exists(madvise TARANTOOL_SMALL_HAS_MADVISE) > > HAS/HAVE - please be consistent in naming. OK > > +check_symbol_exists(MADV_NORMAL sys/mman.h TARANTOOL_SMALL_HAS_MADV_NORMAL) > > +check_symbol_exists(MADV_DONTDUMP sys/mman.h TARANTOOL_SMALL_HAS_MADV_DONTDUMP) > > Do we really need to check all of that? Is a check for MADV_DONTDUMP not > enough? Well, strictly speaking we should check each definition we use, because I'm not sure if MADV_NORMAL defined on other than linux environments. > > + > > +#ifdef TARANTOOL_SMALL_USE_MADVISE > > + if (slab_flags & SLAB_ARENA_DONTDUMP) > > + arena->madv_flag = MADV_DONTDUMP; > > +#endif > > May be, better store slab_flags in arena and convert them to > mmap/madvise flags when necessary? Would be one variable instead > of two. Sounds reasonable, will do. > > + > > +#ifdef TARANTOOL_SMALL_USE_MADVISE > > + if (ptr && arena->madv_flag != MADV_NORMAL) > > + madvise(ptr, arena->slab_size, arena->madv_flag); > > +#endif > > + > > I'd move this code to a helper function to avoid code duplication in > slab_arena_create/slab_map. OK > > > > +/** > > + * Backward compatible flags to be used with slab_arena_create(). > > Please elaborate the comment: explain how this backward compatibility > hack works, what it's needed for. Sure Cyrill