Adapt hpa to the usize changes.

This commit is contained in:
Guangli Dai 2024-06-07 16:18:22 -07:00
parent d01d5b8f4a
commit 9ce475a135
4 changed files with 12 additions and 4 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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 {

View file

@ -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,