Check if the huge page size is expected when enabling HPA.
This commit is contained in:
parent
cd05b19f10
commit
3383b98f1b
|
@ -27,6 +27,14 @@ extern size_t os_page;
|
|||
#define HUGEPAGE ((size_t)(1U << LG_HUGEPAGE))
|
||||
#define HUGEPAGE_MASK ((size_t)(HUGEPAGE - 1))
|
||||
|
||||
/*
|
||||
* Used to validate that the hugepage size is not unexpectedly high. The huge
|
||||
* page features (HPA, metadata_thp) are primarily designed with a 2M THP size
|
||||
* in mind. Much larger sizes are not tested and likely to cause issues such as
|
||||
* bad fragmentation or simply broken.
|
||||
*/
|
||||
#define HUGEPAGE_MAX_EXPECTED_SIZE ((size_t)(16U << 20))
|
||||
|
||||
#if LG_HUGEPAGE != 0
|
||||
# define HUGEPAGE_PAGES (HUGEPAGE / PAGE)
|
||||
#else
|
||||
|
|
|
@ -1041,18 +1041,14 @@ obtain_malloc_conf(unsigned which_source, char readlink_buf[PATH_MAX + 1]) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
validate_hpa_settings(void) {
|
||||
if (!hpa_supported() || !opt_hpa || opt_hpa_opts.dirty_mult == (fxp_t)-1) {
|
||||
return;
|
||||
}
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
had_conf_error = true;
|
||||
char hpa_dirty_mult[FXP_BUF_SIZE];
|
||||
char hugification_threshold[FXP_BUF_SIZE];
|
||||
char normalization_message[256] = {0};
|
||||
|
@ -1079,6 +1075,24 @@ validate_hpa_settings(void) {
|
|||
"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) {
|
||||
return;
|
||||
}
|
||||
if (HUGEPAGE > HUGEPAGE_MAX_EXPECTED_SIZE) {
|
||||
had_conf_error = true;
|
||||
malloc_printf(
|
||||
"<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;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue