Skip to content

Conversation

tkiriyama
Copy link
Member

@tkiriyama tkiriyama commented Oct 21, 2025

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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8303215 needs maintainer approval

Issue

  • JDK-8303215: Make thread stacks not use huge pages (Enhancement - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk11u-dev.git pull/3106/head:pull/3106
$ git checkout pull/3106

Update a local copy of the PR:
$ git checkout pull/3106
$ git pull https://git.openjdk.org/jdk11u-dev.git pull/3106/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3106

View PR using the GUI difftool:
$ git pr show -t 3106

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk11u-dev/pull/3106.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 21, 2025

👋 Welcome back tkiriyama! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 21, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 21, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 21, 2025

Webrevs

@phohensee
Copy link
Member

phohensee commented Oct 21, 2025

Hi, @tkiriyama. As the bot says, you need to change the PR title to "Backport 59d9d9fcb93c26dd8931d70934b889245b050acc" (I looked it up).

There are two follow-up issues, and they in turn also have follow-up issues. Please check them to see if they need to be included.

@tkiriyama tkiriyama changed the title 8303215: Make thread stacks not use huge pages Backport 59d9d9fcb93c26dd8931d70934b889245b050acc Oct 22, 2025
@openjdk openjdk bot changed the title Backport 59d9d9fcb93c26dd8931d70934b889245b050acc 8303215: Make thread stacks not use huge pages Oct 22, 2025
@openjdk
Copy link

openjdk bot commented Oct 22, 2025

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added the backport Port of a pull request already in a different code base label Oct 22, 2025
@tkiriyama
Copy link
Member Author

tkiriyama commented Oct 22, 2025

Hi, @phohensee ,
Sorry, I fixed the title as you suggested.
Are you referring to JDK-8312182 and JDK-8310687?
They have not been verified yet, but they might also be needed for jdk11. If so, I'll create new pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Port of a pull request already in a different code base rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants