Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shipilev committed Jul 24, 2023
1 parent ab821aa commit 75b831e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/os/linux/globals_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3086,7 +3086,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 @@ -3773,15 +3773,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
Original file line number Diff line number Diff line change
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

0 comments on commit 75b831e

Please sign in to comment.