From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Cyrill Gorcunov <gorcunov@gmail.com> Cc: tml <tarantool-patches@freelists.org>, Alexander Turenko <alexander.turenko@tarantool.org> Subject: Re: [PATCH v3] slab_arena: Enhance slab_arena_create to support madvise hints Date: Wed, 15 May 2019 15:37:56 +0300 [thread overview] Message-ID: <20190515123756.6jmoyzm7kf7fahzp@esperanza> (raw) In-Reply-To: <20190513200126.7584-1-gorcunov@gmail.com> On Mon, May 13, 2019 at 11:01:26PM +0300, Cyrill Gorcunov wrote: > The purpose of this extension is to be able to eliminate > some of slab arenas from dumping, especially when huge > amount of memory involves. > > To keep backward compatibility we map flags passed into > new SLAB_ARENA_x flags. To be able to distinguish old > and new interfaces we reserve high bit of the integer > value and remap flags internally to syscall compatible > form. > > Same time I have to modify build script to define > _GNU_SOURCE symbol otherwise madvise bits won't be > found. > > Part-of https://github.com/tarantool/tarantool/issues/3509 > --- > v2: > - Encode madvise hint inside slab_arena_create flags, for backward compatibility > - Enhance test to address dynamic slabs > - Enhance build procedure to test all falgs and functions we're interested in > v3: > - Keep SLAB_ARENA_ flags inside struct slab_arena > - Use HAVE keyword in cmake > - Move madvise into madvise_checked helper > - Extend comment for SLAB_ARENA_ flags > > .gitignore | 1 + > CMakeLists.txt | 18 ++++++ > small/config.h.cmake | 31 +++++++++++ > small/slab_arena.c | 68 +++++++++++++++++++---- > small/slab_arena.h | 23 +++++++- > test/slab_arena.c | 128 +++++++++++++++++++++++++++++++++++++++++++ I'd also patch all places (tests, etc) where old flags (MAP_*) are used to switch them to new flags. Sooner or later we should drop this compat layer. > diff --git a/small/slab_arena.c b/small/slab_arena.c > index 26e2620..9f4baee 100644 > --- a/small/slab_arena.c > +++ b/small/slab_arena.c > @@ -41,17 +41,35 @@ > #include <valgrind/valgrind.h> > #include <valgrind/memcheck.h> > > -#if !defined(MAP_ANONYMOUS) > -#define MAP_ANONYMOUS MAP_ANON > +static void > +madvise_checked(void *ptr, size_t size, int flags) > +{ > +#ifdef TARANTOOL_SMALL_USE_MADVISE It would be nice to have a warning in case MADV_DONTDUMP is unavailable. It should be printed only once. May be, here, or, even better, in Tarantool itself (via say_warn()). > + if (ptr && (flags & SLAB_ARENA_DONTDUMP)) { > + if (madvise(ptr, size, MADV_DONTDUMP)) { > + char *ignore_it; > + char buf[64]; > + > + ignore_it = strerror_r(errno, buf, sizeof(buf)); > + (void)ignore_it; > + > + fprintf(stderr, "Error in madvise(%p, %zu, 0x%x): %s\n", > + ptr, size, MADV_DONTDUMP, buf); > + } > + } > +#else > + (void)ptr; > + (void)size; > + (void)flags; > #endif > +} > > static void > munmap_checked(void *addr, size_t size) > { > if (munmap(addr, size)) { > char buf[64]; > - intptr_t ignore_it = (intptr_t)strerror_r(errno, buf, > - sizeof(buf)); > + char *ignore_it = strerror_r(errno, buf, sizeof(buf)); This wouldn't compile on OS X. Please leave it as is. Same's fair for madvise_checked.
next prev parent reply other threads:[~2019-05-15 12:37 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-13 20:01 Cyrill Gorcunov 2019-05-15 12:37 ` Vladimir Davydov [this message] 2019-05-15 12:53 ` Cyrill Gorcunov 2019-05-15 13:08 ` Vladimir Davydov 2019-05-15 13:22 ` Cyrill Gorcunov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190515123756.6jmoyzm7kf7fahzp@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=alexander.turenko@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v3] slab_arena: Enhance slab_arena_create to support madvise hints' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox