Remove validation for HPA ratios

Config validation was introduced at 3aae792b with main intention to fix
infinite purging loop, but it didn't actually fix the underlying
problem, just masked it. Later 47d69b4ea was merged to address the same
problem.

Options `hpa_dirty_mult` and `hpa_hugification_threshold` have different
application dimensions: `hpa_dirty_mult` applied to active memory on the
shard, but `hpa_hugification_threshold` is a threshold for single
pageslab (hugepage). It doesn't make much sense to sum them up together.

While it is true that too high value of `hpa_dirty_mult` and too low
value of `hpa_hugification_threshold` can lead to pathological
behaviour, it is true for other options as well. Poor configurations
might lead to suboptimal and sometimes completely unacceptable
behaviour and that's OK, that is exactly the reason why they are called
poor.

There are other mechanism exist to prevent extreme behaviour, when we
hugified and then immediately purged page, see
`hpa_hugify_blocked_by_ndirty` function, which exist to prevent exactly
this case.

Lastly, `hpa_dirty_mult + hpa_hugification_threshold >= 1` constraint is
too tight and prevents a lot of valid configurations.
This commit is contained in:
Dmitry Ilvokhin 2024-11-15 08:53:20 -08:00 committed by stanjo74
parent 0ce13c6fb5
commit 3820e38dc1
5 changed files with 1 additions and 102 deletions

View file

@ -1041,44 +1041,6 @@ obtain_malloc_conf(unsigned which_source, char readlink_buf[PATH_MAX + 1]) {
return ret;
}
static bool
validate_hpa_ratios(void) {
size_t hpa_threshold = fxp_mul_frac(HUGEPAGE, opt_hpa_opts.dirty_mult) +
opt_hpa_opts.hugification_threshold;
if (hpa_threshold > HUGEPAGE) {
return false;
}
char hpa_dirty_mult[FXP_BUF_SIZE];
char hugification_threshold[FXP_BUF_SIZE];
char normalization_message[256] = {0};
fxp_print(opt_hpa_opts.dirty_mult, hpa_dirty_mult);
fxp_print(fxp_div(FXP_INIT_INT((unsigned)
(opt_hpa_opts.hugification_threshold >> LG_PAGE)),
FXP_INIT_INT(HUGEPAGE_PAGES)), hugification_threshold);
if (!opt_abort_conf) {
char normalized_hugification_threshold[FXP_BUF_SIZE];
opt_hpa_opts.hugification_threshold +=
HUGEPAGE - hpa_threshold;
fxp_print(fxp_div(FXP_INIT_INT((unsigned)
(opt_hpa_opts.hugification_threshold >> LG_PAGE)),
FXP_INIT_INT(HUGEPAGE_PAGES)),
normalized_hugification_threshold);
malloc_snprintf(normalization_message,
sizeof(normalization_message), "<jemalloc>: Normalizing "
"HPA settings to avoid pathological behavior, setting "
"hpa_hugification_threshold_ratio: to %s.\n",
normalized_hugification_threshold);
}
malloc_printf(
"<jemalloc>: Invalid combination of options "
"hpa_hugification_threshold_ratio: %s and hpa_dirty_mult: %s. "
"These values should sum to > 1.0.\n%s", hugification_threshold,
hpa_dirty_mult, normalization_message);
return true;
}
static void
validate_hpa_settings(void) {
if (!hpa_supported() || !opt_hpa) {
@ -1090,9 +1052,6 @@ validate_hpa_settings(void) {
"<jemalloc>: huge page size (%zu) greater than expected."
"May not be supported or behave as expected.", HUGEPAGE);
}
if (opt_hpa_opts.dirty_mult != (fxp_t)-1 && validate_hpa_ratios()) {
had_conf_error = true;
}
#ifndef JEMALLOC_HAVE_MADVISE_COLLAPSE
if (opt_hpa_opts.hugify_sync) {
had_conf_error = true;