[jdk8u-dev] RFR: 8303215: Make thread stacks not use huge pages
Takuya Kiriyama
tkiriyama at openjdk.org
Fri Jan 16 12:17:42 UTC 2026
Hi All,
I would like to backport the fix for bug JDK-8303215 to JDK 8. This bug addresses an issue with Transparent Huge Pages (THP) and thread stack allocation.
This fix is unclean, but almost clean backport from jdk11.
1. Backport:
The fix is almost clean from jdk11, but there is a slight difference.
- os_linux.cpp
Since JDK 8 does not include JDK-8183552, we need to add one more include statement. JDK-8183552 will likely not be backported to 8u.
- globals_linux_aarch64.hpp
In JDK 11, `CompilerThreadStackSize` is set to 2048, whereas JDK 8 originally sets it to `0`. This change to 2048 was introduced in JDK-8140520. Since JDK-8140520 is likely not directly related to this fix, I have excluded it from this fix and changed `CompilerThreadStackSize` to 2040.
2. Bug Reproduction:
The bug was successfully reproduced in Linux x86_64 with THP enabled (/sys/kernel/mm/transparent_hugepage/enabled = always).
Reproduction was confirmed using the following dummy thread program:
public class ThreadStackHugePageTest {
public static void main(String[] args) {
final int NUM_THREADS = 1000;
final long SLEEP_SECONDS = 3600;
final long SLEEP_MILISECONDS = SLEEP_SECONDS * 1000;
List<Thread> threads = new ArrayList<>();
for (int i = 0; i < NUM_THREADS; i++) {
Runnable task = () -> {
try {
Thread.sleep(SLEEP_MILISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
};
Thread thread = new Thread(task);
threads.add(thread);
thread.start();
}
System.out.println("all threads are started");
for (Thread thread : threads) {
try {
thread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
}
The fix significantly reduces the number of anonymous regions with fully occupied RSS.
3. Regression Testing:
I ran the test/hotspot tests on Linux x64 as a regression test. No failures were found.
Thank you.
-------------
Commit messages:
- 8303215: Make thread stacks not use huge pages
Changes: https://git.openjdk.org/jdk8u-dev/pull/746/files
Webrev: https://webrevs.openjdk.org/?repo=jdk8u-dev&pr=746&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8303215
Stats: 29 lines in 2 files changed: 25 ins; 3 del; 1 mod
Patch: https://git.openjdk.org/jdk8u-dev/pull/746.diff
Fetch: git fetch https://git.openjdk.org/jdk8u-dev.git pull/746/head:pull/746
PR: https://git.openjdk.org/jdk8u-dev/pull/746
More information about the jdk8u-dev
mailing list