diff --git a/src/jemalloc.c b/src/jemalloc.c index 94949cc0..32d72392 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1585,8 +1585,8 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS], "hpa_sec_nshards", 0, 0, CONF_CHECK_MIN, CONF_DONT_CHECK_MAX, true); CONF_HANDLE_SIZE_T(opt_hpa_sec_opts.max_alloc, - "hpa_sec_max_alloc", PAGE, 0, CONF_CHECK_MIN, - CONF_DONT_CHECK_MAX, true); + "hpa_sec_max_alloc", PAGE, USIZE_GROW_SLOW_THRESHOLD, + CONF_CHECK_MIN, CONF_CHECK_MAX, true); CONF_HANDLE_SIZE_T(opt_hpa_sec_opts.max_bytes, "hpa_sec_max_bytes", PAGE, 0, CONF_CHECK_MIN, CONF_DONT_CHECK_MAX, true); diff --git a/src/sec.c b/src/sec.c index 19d69ff4..fe504054 100644 --- a/src/sec.c +++ b/src/sec.c @@ -24,6 +24,14 @@ bool sec_init(tsdn_t *tsdn, sec_t *sec, base_t *base, pai_t *fallback, const sec_opts_t *opts) { assert(opts->max_alloc >= PAGE); + /* + * Same as tcache, sec do not cache allocs/dallocs larger than + * USIZE_GROW_SLOW_THRESHOLD because the usize above this increases + * by PAGE and the number of usizes is too large. + */ +#ifdef LIMIT_USIZE_GAP + assert(opts->max_alloc <= USIZE_GROW_SLOW_THRESHOLD); +#endif size_t max_alloc = PAGE_FLOOR(opts->max_alloc); pszind_t npsizes = sz_psz2ind(max_alloc) + 1; diff --git a/test/unit/hpa.c b/test/unit/hpa.c index 50b96a87..6c42729a 100644 --- a/test/unit/hpa.c +++ b/test/unit/hpa.c @@ -5,7 +5,7 @@ #define SHARD_IND 111 -#define ALLOC_MAX (HUGEPAGE / 4) +#define ALLOC_MAX (HUGEPAGE) typedef struct test_data_s test_data_t; struct test_data_s { diff --git a/test/unit/sec.c b/test/unit/sec.c index 0b5e1c31..a6e6b8b8 100644 --- a/test/unit/sec.c +++ b/test/unit/sec.c @@ -412,7 +412,7 @@ TEST_BEGIN(test_expand_shrink_delegate) { bool deferred_work_generated = false; - test_sec_init(&sec, &ta.pai, /* nshards */ 1, /* max_alloc */ 10 * PAGE, + test_sec_init(&sec, &ta.pai, /* nshards */ 1, /* max_alloc */ 8 * PAGE, /* max_bytes */ 1000 * PAGE); edata_t *edata = pai_alloc(tsdn, &sec.pai, PAGE, PAGE, /* zero */ false, /* guarded */ false, /* frequent_reuse */ false,