Refactor arena_is_auto.
This commit is contained in:
parent
94a88c26f4
commit
79522b2fc2
@ -25,6 +25,9 @@ extern unsigned ncpus;
|
||||
/* Number of arenas used for automatic multiplexing of threads and arenas. */
|
||||
extern unsigned narenas_auto;
|
||||
|
||||
/* Base index for manual arenas. */
|
||||
extern unsigned manual_arena_base;
|
||||
|
||||
/*
|
||||
* Arenas that are used to service external requests. Not all elements of the
|
||||
* arenas array are necessarily used; arenas are created lazily as needed.
|
||||
|
@ -71,9 +71,8 @@ arena_ichoose(tsd_t *tsd, arena_t *arena) {
|
||||
static inline bool
|
||||
arena_is_auto(arena_t *arena) {
|
||||
assert(narenas_auto > 0);
|
||||
unsigned offset = (opt_huge_threshold != 0) ? 1 : 0;
|
||||
|
||||
return (arena_ind_get(arena) < narenas_auto + offset);
|
||||
return (arena_ind_get(arena) < manual_arena_base);
|
||||
}
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE extent_t *
|
||||
|
@ -86,8 +86,10 @@ malloc_mutex_t arenas_lock;
|
||||
JEMALLOC_ALIGNED(CACHELINE)
|
||||
atomic_p_t arenas[MALLOCX_ARENA_LIMIT];
|
||||
static atomic_u_t narenas_total; /* Use narenas_total_*(). */
|
||||
static arena_t *a0; /* arenas[0]; read-only after initialization. */
|
||||
unsigned narenas_auto; /* Read-only after initialization. */
|
||||
/* Below three are read-only after initialization. */
|
||||
static arena_t *a0; /* arenas[0]. */
|
||||
unsigned narenas_auto;
|
||||
unsigned manual_arena_base;
|
||||
|
||||
typedef enum {
|
||||
malloc_init_uninitialized = 3,
|
||||
@ -1322,6 +1324,7 @@ malloc_init_hard_a0_locked() {
|
||||
* malloc_ncpus().
|
||||
*/
|
||||
narenas_auto = 1;
|
||||
manual_arena_base = narenas_auto + 1;
|
||||
memset(arenas, 0, sizeof(arena_t *) * narenas_auto);
|
||||
/*
|
||||
* Initialize one arena here. The rest are lazily created in
|
||||
@ -1472,6 +1475,7 @@ malloc_init_narenas(void) {
|
||||
if (arena_init_huge()) {
|
||||
narenas_total_inc();
|
||||
}
|
||||
manual_arena_base = narenas_total_get();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user