diff options
author | Jason Evans <jasone@canonware.com> | 2016-12-03 23:38:25 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-12-27 02:08:16 (GMT) |
commit | a6e86810d83aba0d94d0f6423ed09e8e6e0909fa (patch) | |
tree | 7ca1d2d92bdba5fd5ec01b01e3167f1f6dd875d9 /include/jemalloc/internal/pages.h | |
parent | 884fa22b8c8a23831eb4090fa92d191d6e3e394e (diff) | |
download | jemalloc-a6e86810d83aba0d94d0f6423ed09e8e6e0909fa.zip jemalloc-a6e86810d83aba0d94d0f6423ed09e8e6e0909fa.tar.gz jemalloc-a6e86810d83aba0d94d0f6423ed09e8e6e0909fa.tar.bz2 |
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 'include/jemalloc/internal/pages.h')
-rw-r--r-- | include/jemalloc/internal/pages.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/include/jemalloc/internal/pages.h b/include/jemalloc/internal/pages.h index 034a8aa..98e4f38 100644 --- a/include/jemalloc/internal/pages.h +++ b/include/jemalloc/internal/pages.h @@ -24,6 +24,23 @@ #define HUGEPAGE_CEILING(s) \ (((s) + HUGEPAGE_MASK) & ~HUGEPAGE_MASK) +/* PAGES_CAN_PURGE_LAZY is defined if lazy purging is supported. */ +#if defined(_WIN32) || defined(JEMALLOC_PURGE_MADVISE_FREE) +# define PAGES_CAN_PURGE_LAZY +#endif +/* + * PAGES_CAN_PURGE_FORCED is defined if forced purging is supported. + * + * The only supported way to hard-purge on Windows is to decommit and then + * re-commit, but doing so is racy, and if re-commit fails it's a pain to + * propagate the "poisoned" memory state. Since we typically decommit as the + * next step after purging on Windows anyway, there's no point in adding such + * complexity. + */ +#if !defined(_WIN32) && defined(JEMALLOC_PURGE_MADVISE_DONTNEED) +# define PAGES_CAN_PURGE_FORCED +#endif + #endif /* JEMALLOC_H_TYPES */ /******************************************************************************/ #ifdef JEMALLOC_H_STRUCTS @@ -32,13 +49,29 @@ /******************************************************************************/ #ifdef JEMALLOC_H_EXTERNS +static const bool pages_can_purge_lazy = +#ifdef PAGES_CAN_PURGE_LAZY + true +#else + false +#endif + ; +static const bool pages_can_purge_forced = +#ifdef PAGES_CAN_PURGE_FORCED + true +#else + false +#endif + ; + void *pages_map(void *addr, size_t size, bool *commit); void pages_unmap(void *addr, size_t size); void *pages_trim(void *addr, size_t alloc_size, size_t leadsize, size_t size, bool *commit); bool pages_commit(void *addr, size_t size); bool pages_decommit(void *addr, size_t size); -bool pages_purge(void *addr, size_t size); +bool pages_purge_lazy(void *addr, size_t size); +bool pages_purge_forced(void *addr, size_t size); bool pages_huge(void *addr, size_t size); bool pages_nohuge(void *addr, size_t size); void pages_boot(void); |