Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8312585: Rename DisableTHPStackMitigation flag to THPStackMitigation #1699

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hotspot/os/linux/globals_linux.hpp
Expand Up @@ -98,10 +98,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, \
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/os/linux/os_linux.cpp
Expand Up @@ -882,7 +882,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
Expand Down Expand Up @@ -3144,7 +3144,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
Expand Down Expand Up @@ -3831,15 +3831,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
Expand Down
Expand Up @@ -208,7 +208,7 @@ public static void main(String[] args) throws Exception {

// 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);
Expand Down