Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_TYPES
|
|
|
|
|
2016-04-07 22:14:37 +08:00
|
|
|
/* Page size. LG_PAGE is determined by the configure script. */
|
|
|
|
#ifdef PAGE_MASK
|
|
|
|
# undef PAGE_MASK
|
|
|
|
#endif
|
|
|
|
#define PAGE ((size_t)(1U << LG_PAGE))
|
|
|
|
#define PAGE_MASK ((size_t)(PAGE - 1))
|
|
|
|
/* Return the page base address for the page containing address a. */
|
|
|
|
#define PAGE_ADDR2BASE(a) \
|
|
|
|
((void *)((uintptr_t)(a) & ~PAGE_MASK))
|
|
|
|
/* Return the smallest pagesize multiple that is >= s. */
|
|
|
|
#define PAGE_CEILING(s) \
|
|
|
|
(((s) + PAGE_MASK) & ~PAGE_MASK)
|
|
|
|
|
2016-11-18 05:36:17 +08:00
|
|
|
/* Huge page size. LG_HUGEPAGE is determined by the configure script. */
|
|
|
|
#define HUGEPAGE ((size_t)(1U << LG_HUGEPAGE))
|
|
|
|
#define HUGEPAGE_MASK ((size_t)(HUGEPAGE - 1))
|
|
|
|
/* Return the huge page base address for the huge page containing address a. */
|
|
|
|
#define HUGEPAGE_ADDR2BASE(a) \
|
|
|
|
((void *)((uintptr_t)(a) & ~HUGEPAGE_MASK))
|
|
|
|
/* Return the smallest pagesize multiple that is >= s. */
|
|
|
|
#define HUGEPAGE_CEILING(s) \
|
|
|
|
(((s) + HUGEPAGE_MASK) & ~HUGEPAGE_MASK)
|
|
|
|
|
2016-12-04 07:38:25 +08:00
|
|
|
/* 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
|
|
|
|
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
#endif /* JEMALLOC_H_TYPES */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_STRUCTS
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_STRUCTS */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_EXTERNS
|
|
|
|
|
2016-12-04 07:38:25 +08:00
|
|
|
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
|
|
|
|
;
|
|
|
|
|
2016-05-06 08:45:02 +08:00
|
|
|
void *pages_map(void *addr, size_t size, bool *commit);
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
void pages_unmap(void *addr, size_t size);
|
|
|
|
void *pages_trim(void *addr, size_t alloc_size, size_t leadsize,
|
2016-05-06 08:45:02 +08:00
|
|
|
size_t size, bool *commit);
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
bool pages_commit(void *addr, size_t size);
|
|
|
|
bool pages_decommit(void *addr, size_t size);
|
2016-12-04 07:38:25 +08:00
|
|
|
bool pages_purge_lazy(void *addr, size_t size);
|
|
|
|
bool pages_purge_forced(void *addr, size_t size);
|
2016-11-18 05:36:17 +08:00
|
|
|
bool pages_huge(void *addr, size_t size);
|
|
|
|
bool pages_nohuge(void *addr, size_t size);
|
2016-05-06 08:45:02 +08:00
|
|
|
void pages_boot(void);
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_EXTERNS */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_INLINES
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_INLINES */
|
|
|
|
/******************************************************************************/
|
|
|
|
|