From f730577277ace08287bb8eedce75e49d35aeb0ba Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Sat, 14 Mar 2020 10:05:12 -0700 Subject: [PATCH] Eset: Parameterize last globals accesses. I.e. opt_retain and maps_coalesce. --- include/jemalloc/internal/eset.h | 2 +- src/eset.c | 16 ++++++---------- src/extent.c | 8 +++++++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/jemalloc/internal/eset.h b/include/jemalloc/internal/eset.h index d051b81b..e29179d1 100644 --- a/include/jemalloc/internal/eset.h +++ b/include/jemalloc/internal/eset.h @@ -51,7 +51,7 @@ void eset_remove(eset_t *eset, edata_t *edata); * Select an extent from this eset of the given size and alignment. Returns * null if no such item could be found. */ -edata_t *eset_fit(eset_t *eset, size_t esize, size_t alignment, +edata_t *eset_fit(eset_t *eset, size_t esize, size_t alignment, bool exact_only, unsigned lg_max_fit); #endif /* JEMALLOC_INTERNAL_ESET_H */ diff --git a/src/eset.c b/src/eset.c index 12a57aff..c4e39d25 100644 --- a/src/eset.c +++ b/src/eset.c @@ -2,8 +2,6 @@ #include "jemalloc/internal/jemalloc_internal_includes.h" #include "jemalloc/internal/eset.h" -/* For opt_retain */ -#include "jemalloc/internal/extent_mmap.h" const bitmap_info_t eset_bitmap_info = BITMAP_INFO_INITIALIZER(SC_NPSIZES+1); @@ -162,16 +160,13 @@ eset_fit_alignment(eset_t *eset, size_t min_size, size_t max_size, * for others. */ static edata_t * -eset_first_fit(eset_t *eset, size_t size, unsigned lg_max_fit) { +eset_first_fit(eset_t *eset, size_t size, bool exact_only, + unsigned lg_max_fit) { edata_t *ret = NULL; pszind_t pind = sz_psz2ind(sz_psz_quantize_ceil(size)); - if (!maps_coalesce && !opt_retain) { - /* - * No split / merge allowed (Windows w/o retain). Try exact fit - * only. - */ + if (exact_only) { return edata_heap_empty(&eset->heaps[pind]) ? NULL : edata_heap_first(&eset->heaps[pind]); } @@ -208,14 +203,15 @@ eset_first_fit(eset_t *eset, size_t size, unsigned lg_max_fit) { } edata_t * -eset_fit(eset_t *eset, size_t esize, size_t alignment, unsigned lg_max_fit) { +eset_fit(eset_t *eset, size_t esize, size_t alignment, bool exact_only, + unsigned lg_max_fit) { size_t max_size = esize + PAGE_CEILING(alignment) - PAGE; /* Beware size_t wrap-around. */ if (max_size < esize) { return NULL; } - edata_t *edata = eset_first_fit(eset, max_size, lg_max_fit); + edata_t *edata = eset_first_fit(eset, max_size, exact_only, lg_max_fit); if (alignment > PAGE && edata == NULL) { /* diff --git a/src/extent.c b/src/extent.c index e570ed59..db658bb6 100644 --- a/src/extent.c +++ b/src/extent.c @@ -398,6 +398,11 @@ extent_recycle_extract(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks, emap_unlock_edata(tsdn, &emap_global, unlock_edata); } } else { + /* + * If split and merge are not allowed (Windows w/o retain), try + * exact fit only. + */ + bool exact_only = (!maps_coalesce && !opt_retain); /* * A large extent might be broken up from its original size to * some small size to satisfy a small request. When that small @@ -409,7 +414,8 @@ extent_recycle_extract(tsdn_t *tsdn, pa_shard_t *shard, ehooks_t *ehooks, */ unsigned lg_max_fit = ecache->delay_coalesce ? (unsigned)opt_lg_extent_max_active_fit : SC_PTR_BITS; - edata = eset_fit(&ecache->eset, size, alignment, lg_max_fit); + edata = eset_fit(&ecache->eset, size, alignment, exact_only, + lg_max_fit); } if (edata == NULL) { malloc_mutex_unlock(tsdn, &ecache->mtx);