Eset: Parameterize last globals accesses.
I.e. opt_retain and maps_coalesce.
This commit is contained in:
parent
7bb6e2dc0d
commit
f730577277
@ -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 */
|
||||
|
16
src/eset.c
16
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) {
|
||||
/*
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user