Allow the 'n' option to decrease the number of arenas below the default,
to as little as one arena. Also, limit the number of arenas to avoid a potential invariant violation in base_alloc().
This commit is contained in:
parent
4328edf534
commit
9f9bc9367c
@ -3200,8 +3200,22 @@ malloc_init_hard(void)
|
||||
|
||||
/* Determine how many arenas to use. */
|
||||
narenas = ncpus;
|
||||
if (opt_narenas_lshift > 0)
|
||||
narenas <<= opt_narenas_lshift;
|
||||
if (opt_narenas_lshift > 0) {
|
||||
if ((narenas << opt_narenas_lshift) > narenas)
|
||||
narenas <<= opt_narenas_lshift;
|
||||
/*
|
||||
* Make sure not to exceed the limits of what base_malloc()
|
||||
* can handle.
|
||||
*/
|
||||
if (narenas * sizeof(arena_t *) > chunk_size)
|
||||
narenas = chunk_size / sizeof(arena_t *);
|
||||
} else if (opt_narenas_lshift < 0) {
|
||||
if ((narenas << opt_narenas_lshift) < narenas)
|
||||
narenas <<= opt_narenas_lshift;
|
||||
/* Make sure there is at least one arena. */
|
||||
if (narenas == 0)
|
||||
narenas = 1;
|
||||
}
|
||||
|
||||
#ifdef NO_TLS
|
||||
if (narenas > 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user