8312585: Rename DisableTHPStackMitigation flag to THPStackMitigation

Reviewed-by: dholmes, stuefe
This commit is contained in:
Aleksey Shipilev 2023-08-07 10:45:14 +00:00
parent dc01604756
commit 226cdc696d
3 changed files with 10 additions and 10 deletions
src/hotspot/os/linux
test/hotspot/jtreg/runtime/os

@ -89,10 +89,10 @@
"to disable both the override and the printouts." \
"See prctl(PR_SET_TIMERSLACK) for more info.") \
\
product(bool, DisableTHPStackMitigation, false, DIAGNOSTIC, \
product(bool, THPStackMitigation, true, DIAGNOSTIC, \
"If THPs are unconditionally enabled on the system (mode " \
"\"always\"), the JVM will prevent THP from forming in " \
"thread stacks. This switch disables that mitigation and " \
"thread stacks. When disabled, the absence of this mitigation"\
"allows THPs to form in thread stacks.") \
\
develop(bool, DelayThreadStartALot, false, \

@ -936,7 +936,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
}
assert(is_aligned(stack_size, os::vm_page_size()), "stack_size not aligned");
if (!DisableTHPStackMitigation) {
if (THPStackMitigation) {
// In addition to the glibc guard page that prevents inter-thread-stack hugepage
// coalescing (see comment in os::Linux::default_guard_size()), we also make
// sure the stack size itself is not huge-page-size aligned; that makes it much
@ -3102,7 +3102,7 @@ bool os::Linux::libnuma_init() {
size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
if (!DisableTHPStackMitigation) {
if (THPStackMitigation) {
// If THPs are unconditionally enabled, the following scenario can lead to huge RSS
// - parent thread spawns, in quick succession, multiple child threads
// - child threads are slow to start
@ -3764,15 +3764,15 @@ void os::large_page_init() {
// coalesce small pages in thread stacks to huge pages. That costs a lot of memory and
// is usually unwanted for thread stacks. Therefore we attempt to prevent THP formation in
// thread stacks unless the user explicitly allowed THP formation by manually disabling
// -XX:+DisableTHPStackMitigation.
// -XX:-THPStackMitigation.
if (HugePages::thp_mode() == THPMode::always) {
if (DisableTHPStackMitigation) {
log_info(pagesize)("JVM will *not* prevent THPs in thread stacks. This may cause high RSS.");
} else {
if (THPStackMitigation) {
log_info(pagesize)("JVM will attempt to prevent THPs in thread stacks.");
} else {
log_info(pagesize)("JVM will *not* prevent THPs in thread stacks. This may cause high RSS.");
}
} else {
FLAG_SET_ERGO(DisableTHPStackMitigation, true); // Mitigation not needed
FLAG_SET_ERGO(THPStackMitigation, false); // Mitigation not needed
}
// 1) Handle the case where we do not want to use huge pages

@ -208,7 +208,7 @@ public class THPsInThreadStackPreventionTest {
// explicitly disable the no-THP-workaround:
finalargs.add("-XX:+UnlockDiagnosticVMOptions");
finalargs.add("-XX:+DisableTHPStackMitigation");
finalargs.add("-XX:-THPStackMitigation");
finalargs.add(TestMain.class.getName());
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs);