Add opt hpa_hugify_sync to hugify synchronously

Linux 6.1 introduced `MADV_COLLAPSE` flag to perform a best-effort
synchronous collapse of the native pages mapped by the memory range into
transparent huge pages.

Synchronous hugification might be beneficial for at least two reasons:
we are not relying on khugepaged anymore and get an instant feedback if
range wasn't hugified.

If `hpa_hugify_sync` option is on, we'll try to perform synchronously
collapse and if it wasn't successful, we'll fallback to asynchronous
behaviour.
This commit is contained in:
Dmitry Ilvokhin 2024-10-31 11:43:11 -07:00 committed by stanjo74
parent a361e886e2
commit 0ce13c6fb5
15 changed files with 141 additions and 8 deletions

View file

@ -1093,6 +1093,15 @@ validate_hpa_settings(void) {
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;
malloc_printf(
"<jemalloc>: hpa_hugify_sync config option is enabled, "
"but MADV_COLLAPSE support was not detected at build "
"time.");
}
#endif
}
static void
@ -1566,6 +1575,9 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
0, 0, CONF_DONT_CHECK_MIN, CONF_DONT_CHECK_MAX,
false);
CONF_HANDLE_BOOL(
opt_hpa_opts.hugify_sync, "hpa_hugify_sync");
CONF_HANDLE_UINT64_T(
opt_hpa_opts.min_purge_interval_ms,
"hpa_min_purge_interval_ms", 0, 0,