HPA: add size-exclusion functionality.

I.e. only allowing allocations under or over certain sizes.
This commit is contained in:
David Goldblatt
2020-09-04 18:29:28 -07:00
committed by David Goldblatt
parent 484f04733e
commit 534504d4a7
11 changed files with 84 additions and 16 deletions

View File

@@ -136,8 +136,10 @@ malloc_mutex_t arenas_lock;
/* The global hpa, and whether it's on. */
bool opt_hpa = false;
size_t opt_hpa_slab_goal = 512 * 1024;
size_t opt_hpa_slab_goal = 128 * 1024;
size_t opt_hpa_slab_max_alloc = 256 * 1024;
size_t opt_hpa_small_max = 32 * 1024;
size_t opt_hpa_large_min = 4 * 1024 * 1024;
/*
* Arenas that are used to service external requests. Not all elements of the
@@ -1493,6 +1495,10 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
CONF_HANDLE_SIZE_T(opt_hpa_slab_max_alloc,
"hpa_slab_max_alloc", PAGE, 512 * PAGE,
CONF_CHECK_MIN, CONF_CHECK_MAX, true)
CONF_HANDLE_SIZE_T(opt_hpa_small_max, "hpa_small_max",
PAGE, 0, CONF_CHECK_MIN, CONF_DONT_CHECK_MAX, true)
CONF_HANDLE_SIZE_T(opt_hpa_large_min, "hpa_large_min",
PAGE, 0, CONF_CHECK_MIN, CONF_DONT_CHECK_MAX, true)
if (CONF_MATCH("slab_sizes")) {
if (CONF_MATCH_VALUE("default")) {
@@ -1801,7 +1807,8 @@ malloc_init_hard_a0_locked() {
return true;
}
if (pa_shard_enable_hpa(&a0->pa_shard, &arena_hpa_global,
opt_hpa_slab_goal, opt_hpa_slab_max_alloc)) {
opt_hpa_slab_goal, opt_hpa_slab_max_alloc,
opt_hpa_small_max, opt_hpa_large_min)) {
return true;
}
}