Fix the arena selection for oversized allocations.
Use the per-arena oversize_threshold, instead of the global setting.
This commit is contained in:
parent
5832ef6589
commit
86eb49b478
@ -100,7 +100,7 @@ unsigned arena_nthreads_get(arena_t *arena, bool internal);
|
|||||||
void arena_nthreads_inc(arena_t *arena, bool internal);
|
void arena_nthreads_inc(arena_t *arena, bool internal);
|
||||||
void arena_nthreads_dec(arena_t *arena, bool internal);
|
void arena_nthreads_dec(arena_t *arena, bool internal);
|
||||||
arena_t *arena_new(tsdn_t *tsdn, unsigned ind, const arena_config_t *config);
|
arena_t *arena_new(tsdn_t *tsdn, unsigned ind, const arena_config_t *config);
|
||||||
bool arena_init_huge(void);
|
bool arena_init_huge(arena_t *a0);
|
||||||
bool arena_is_huge(unsigned arena_ind);
|
bool arena_is_huge(unsigned arena_ind);
|
||||||
arena_t *arena_choose_huge(tsd_t *tsd);
|
arena_t *arena_choose_huge(tsd_t *tsd);
|
||||||
bin_t *arena_bin_choose(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
bin_t *arena_bin_choose(tsdn_t *tsdn, arena_t *arena, szind_t binind,
|
||||||
|
@ -28,14 +28,18 @@ arena_choose_maybe_huge(tsd_t *tsd, arena_t *arena, size_t size) {
|
|||||||
* 1) is using auto arena selection (i.e. arena == NULL), and 2) the
|
* 1) is using auto arena selection (i.e. arena == NULL), and 2) the
|
||||||
* thread is not assigned to a manual arena.
|
* thread is not assigned to a manual arena.
|
||||||
*/
|
*/
|
||||||
if (unlikely(size >= oversize_threshold)) {
|
|
||||||
arena_t *tsd_arena = tsd_arena_get(tsd);
|
arena_t *tsd_arena = tsd_arena_get(tsd);
|
||||||
if (tsd_arena == NULL || arena_is_auto(tsd_arena)) {
|
if (tsd_arena == NULL) {
|
||||||
return arena_choose_huge(tsd);
|
tsd_arena = arena_choose(tsd, NULL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return arena_choose(tsd, NULL);
|
size_t threshold = atomic_load_zu(
|
||||||
|
&tsd_arena->pa_shard.pac.oversize_threshold, ATOMIC_RELAXED);
|
||||||
|
if (unlikely(size >= threshold) && arena_is_auto(tsd_arena)) {
|
||||||
|
return arena_choose_huge(tsd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tsd_arena;
|
||||||
}
|
}
|
||||||
|
|
||||||
JEMALLOC_ALWAYS_INLINE void
|
JEMALLOC_ALWAYS_INLINE void
|
||||||
|
@ -1770,7 +1770,7 @@ arena_choose_huge(tsd_t *tsd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
arena_init_huge(void) {
|
arena_init_huge(arena_t *a0) {
|
||||||
bool huge_enabled;
|
bool huge_enabled;
|
||||||
|
|
||||||
/* The threshold should be large size class. */
|
/* The threshold should be large size class. */
|
||||||
@ -1783,6 +1783,9 @@ arena_init_huge(void) {
|
|||||||
/* Reserve the index for the huge arena. */
|
/* Reserve the index for the huge arena. */
|
||||||
huge_arena_ind = narenas_total_get();
|
huge_arena_ind = narenas_total_get();
|
||||||
oversize_threshold = opt_oversize_threshold;
|
oversize_threshold = opt_oversize_threshold;
|
||||||
|
/* a0 init happened before malloc_conf_init. */
|
||||||
|
atomic_store_zu(&a0->pa_shard.pac.oversize_threshold,
|
||||||
|
oversize_threshold, ATOMIC_RELAXED);
|
||||||
huge_enabled = true;
|
huge_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2090,7 +2090,7 @@ malloc_init_narenas(void) {
|
|||||||
narenas_auto);
|
narenas_auto);
|
||||||
}
|
}
|
||||||
narenas_total_set(narenas_auto);
|
narenas_total_set(narenas_auto);
|
||||||
if (arena_init_huge()) {
|
if (arena_init_huge(a0)) {
|
||||||
narenas_total_inc();
|
narenas_total_inc();
|
||||||
}
|
}
|
||||||
manual_arena_base = narenas_total_get();
|
manual_arena_base = narenas_total_get();
|
||||||
|
Loading…
Reference in New Issue
Block a user