Refactor (MALLOCX_ARENA_MAX + 1) to be MALLOCX_ARENA_LIMIT.
This resolves #673.
This commit is contained in:
parent
909f0482e4
commit
18a83681cf
@ -83,9 +83,9 @@ typedef struct ctl_arenas_s {
|
||||
* Element 0 corresponds to merged stats for extant arenas (accessed via
|
||||
* MALLCTL_ARENAS_ALL), element 1 corresponds to merged stats for
|
||||
* destroyed arenas (accessed via MALLCTL_ARENAS_DESTROYED), and the
|
||||
* remaining MALLOCX_ARENA_MAX+1 elements correspond to arenas.
|
||||
* remaining MALLOCX_ARENA_LIMIT elements correspond to arenas.
|
||||
*/
|
||||
ctl_arena_t *arenas[MALLOCX_ARENA_MAX + 3];
|
||||
ctl_arena_t *arenas[2 + MALLOCX_ARENA_LIMIT];
|
||||
} ctl_arenas_t;
|
||||
|
||||
int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
|
||||
|
@ -13,10 +13,10 @@ extent_arena_get(const extent_t *extent) {
|
||||
* The following check is omitted because we should never actually read
|
||||
* a NULL arena pointer.
|
||||
*/
|
||||
if (false && arena_ind > MALLOCX_ARENA_MAX) {
|
||||
if (false && arena_ind >= MALLOCX_ARENA_LIMIT) {
|
||||
return NULL;
|
||||
}
|
||||
assert(arena_ind <= MALLOCX_ARENA_MAX);
|
||||
assert(arena_ind < MALLOCX_ARENA_LIMIT);
|
||||
return (arena_t *)atomic_load_p(&arenas[arena_ind], ATOMIC_ACQUIRE);
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ static inline arena_t *
|
||||
arena_get(tsdn_t *tsdn, unsigned ind, bool init_if_missing) {
|
||||
arena_t *ret;
|
||||
|
||||
assert(ind <= MALLOCX_ARENA_MAX);
|
||||
assert(ind < MALLOCX_ARENA_LIMIT);
|
||||
|
||||
ret = (arena_t *)atomic_load_p(&arenas[ind], ATOMIC_ACQUIRE);
|
||||
if (unlikely(ret == NULL)) {
|
||||
|
@ -29,7 +29,7 @@ typedef int malloc_cpuid_t;
|
||||
#define MALLOCX_ARENA_MASK \
|
||||
(((1 << MALLOCX_ARENA_BITS) - 1) << MALLOCX_ARENA_SHIFT)
|
||||
/* NB: Arena index bias decreases the maximum number of arenas by 1. */
|
||||
#define MALLOCX_ARENA_MAX ((1 << MALLOCX_ARENA_BITS) - 2)
|
||||
#define MALLOCX_ARENA_LIMIT ((1 << MALLOCX_ARENA_BITS) - 1)
|
||||
#define MALLOCX_TCACHE_MASK \
|
||||
(((1 << MALLOCX_TCACHE_BITS) - 1) << MALLOCX_TCACHE_SHIFT)
|
||||
#define MALLOCX_TCACHE_MAX ((1 << MALLOCX_TCACHE_BITS) - 3)
|
||||
|
@ -70,7 +70,7 @@ static malloc_mutex_t arenas_lock;
|
||||
* Points to an arena_t.
|
||||
*/
|
||||
JEMALLOC_ALIGNED(CACHELINE)
|
||||
atomic_p_t arenas[MALLOCX_ARENA_MAX + 1];
|
||||
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. */
|
||||
@ -400,7 +400,7 @@ arena_init_locked(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
|
||||
arena_t *arena;
|
||||
|
||||
assert(ind <= narenas_total_get());
|
||||
if (ind > MALLOCX_ARENA_MAX) {
|
||||
if (ind >= MALLOCX_ARENA_LIMIT) {
|
||||
return NULL;
|
||||
}
|
||||
if (ind == narenas_total_get()) {
|
||||
@ -1318,7 +1318,7 @@ malloc_init_narenas(void) {
|
||||
abort();
|
||||
}
|
||||
} else {
|
||||
if (ncpus > MALLOCX_ARENA_MAX) {
|
||||
if (ncpus >= MALLOCX_ARENA_LIMIT) {
|
||||
malloc_printf("<jemalloc>: narenas w/ percpu"
|
||||
"arena beyond limit (%d)\n", ncpus);
|
||||
if (opt_abort) {
|
||||
@ -1364,8 +1364,8 @@ malloc_init_narenas(void) {
|
||||
/*
|
||||
* Limit the number of arenas to the indexing range of MALLOCX_ARENA().
|
||||
*/
|
||||
if (narenas_auto > MALLOCX_ARENA_MAX) {
|
||||
narenas_auto = MALLOCX_ARENA_MAX;
|
||||
if (narenas_auto >= MALLOCX_ARENA_LIMIT) {
|
||||
narenas_auto = MALLOCX_ARENA_LIMIT - 1;
|
||||
malloc_printf("<jemalloc>: Reducing narenas to limit (%d)\n",
|
||||
narenas_auto);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user