[jdk11u-dev] RFR: 8303215: Make thread stacks not use huge pages

Severin Gehwolf sgehwolf at openjdk.org
Fri Dec 12 13:25:13 UTC 2025


On Wed, 10 Dec 2025 05:31:24 GMT, Takuya Kiriyama <tkiriyama at openjdk.org> wrote:

>> Hi All,  
>> 
>> I would like to backport the fix for bug JDK-8303215 from JDK 17 to JDK 11. This bug addresses an issue with Transparent Huge Pages (THP) and thread stack allocation.
>> Backport is unclean, 
>> 
>> **1. Backport:**
>> The fix in os_linux.cpp cannot be cleanly backported.
>> Since jdk11 does not include JDK-8244752 and JDK-8256155, it differs from the fix in jdk17. It uses setup_large_page_size() instead of scan_default_large_page_size().
>> 
>> 
>> **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.
>
> Hi, @theRealAph , @jerboaa , @gnu-andrew ,
> Would you please approve my Fix Request for the 8303215 backport as a maintainer?

@tkiriyama Please enable testing on your jdk11u-dev fork and trigger a test run. I don't see any GHA runs. Thanks! Once that's done feel free to re-apply for approval.

-------------

PR Comment: https://git.openjdk.org/jdk11u-dev/pull/3106#issuecomment-3646470543


More information about the jdk-updates-dev mailing list