diff options
| author | Jason Evans <jasone@canonware.com> | 2016-12-03 15:38:25 -0800 |
|---|---|---|
| committer | Jason Evans <jasone@canonware.com> | 2016-12-26 18:08:16 -0800 |
| commit | a6e86810d83aba0d94d0f6423ed09e8e6e0909fa (patch) | |
| tree | 7ca1d2d92bdba5fd5ec01b01e3167f1f6dd875d9 /src/pages.c | |
| parent | 884fa22b8c8a23831eb4090fa92d191d6e3e394e (diff) | |
| download | platform_external_jemalloc_new-a6e86810d83aba0d94d0f6423ed09e8e6e0909fa.tar.gz platform_external_jemalloc_new-a6e86810d83aba0d94d0f6423ed09e8e6e0909fa.tar.bz2 platform_external_jemalloc_new-a6e86810d83aba0d94d0f6423ed09e8e6e0909fa.zip | |
Refactor purging and splitting/merging.
Split purging into lazy and forced variants. Use the forced variant for
zeroing dss.
Add support for NULL function pointers as an opt-out mechanism for the
dalloc, commit, decommit, purge_lazy, purge_forced, split, and merge
fields of extent_hooks_t.
Add short-circuiting checks in large_ralloc_no_move_{shrink,expand}() so
that no attempt is made if splitting/merging is not supported.
This resolves #268.
Diffstat (limited to 'src/pages.c')
| -rw-r--r-- | src/pages.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/pages.c b/src/pages.c index 8bef6fac..d5a0a21c 100644 --- a/src/pages.c +++ b/src/pages.c @@ -163,33 +163,34 @@ pages_decommit(void *addr, size_t size) } bool -pages_purge(void *addr, size_t size) +pages_purge_lazy(void *addr, size_t size) { - bool unzeroed; + + if (!pages_can_purge_lazy) + return (true); #ifdef _WIN32 VirtualAlloc(addr, size, MEM_RESET, PAGE_READWRITE); - unzeroed = true; -#elif (defined(JEMALLOC_PURGE_MADVISE_FREE) || \ - defined(JEMALLOC_PURGE_MADVISE_DONTNEED)) -# if defined(JEMALLOC_PURGE_MADVISE_FREE) -# define JEMALLOC_MADV_PURGE MADV_FREE -# define JEMALLOC_MADV_ZEROS false -# elif defined(JEMALLOC_PURGE_MADVISE_DONTNEED) -# define JEMALLOC_MADV_PURGE MADV_DONTNEED -# define JEMALLOC_MADV_ZEROS true -# else -# error No madvise(2) flag defined for purging unused dirty pages -# endif - int err = madvise(addr, size, JEMALLOC_MADV_PURGE); - unzeroed = (!JEMALLOC_MADV_ZEROS || err != 0); -# undef JEMALLOC_MADV_PURGE -# undef JEMALLOC_MADV_ZEROS +#elif defined(JEMALLOC_PURGE_MADVISE_FREE) + madvise(addr, size, MADV_FREE); +#else + not_reached(); +#endif + return (false); +} + +bool +pages_purge_forced(void *addr, size_t size) +{ + + if (!pages_can_purge_forced) + return (true); + +#if defined(JEMALLOC_PURGE_MADVISE_DONTNEED) + return (madvise(addr, size, MADV_DONTNEED) != 0); #else - /* Last resort no-op. */ - unzeroed = true; + not_reached(); #endif - return (unzeroed); } bool |
