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

8229147: Linux os::create_thread() overcounts guardpage size with newer glibc (>=2.27) #2035

Closed
wants to merge 3 commits into from

Conversation

RealLucy
Copy link
Contributor

@RealLucy RealLucy commented Jul 10, 2023

This backport is for parity with 11.0.21-oracle.
Fix didn't apply at all, os/linux/os_linux.cpp was too different in particular.
I managed to create a working version by massaging and applying the changes manually.

There is some risk involved. It is not caused by the intentional change of behavior but by potential collateral damage.

Tests (SAP nightly test suite) do not indicate any issues.
All the additional commits were as well tested overnight with no issues found.
Reviews received.


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

Issue

  • JDK-8229147: Linux os::create_thread() overcounts guardpage size with newer glibc (>=2.27) (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2035

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 10, 2023

👋 Welcome back lucy! 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 openjdk bot changed the title Backport 9ebcda2165c42e3f7b82a9ae8074badb69c0d270 8229147: Linux os::create_thread() overcounts guardpage size with newer glibc (>=2.27) Jul 10, 2023
@openjdk
Copy link

openjdk bot commented Jul 10, 2023

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

@openjdk openjdk bot added backport rfr Pull request is ready for review labels Jul 10, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 10, 2023

Webrevs

Copy link
Member

@GoeLin GoeLin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bummer "8225035: Thread stack size issue caused by large TLS size"
is not in 11. But that was a quite unstable change and has a CSR,
so no good candidate to backport.

This backport contains parts of 8225035, though, but they are blocked
by setting the corresponding flag statically to false.
I think this makes sense as this keeps the code similar
and thus easier to maintai

}

#if defined(__GLIBC__) // TLS not in jdk11
static bool AdjustStackSizeForTLS = false; // Dumy decl as substitute for cmdline parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AdjustStackSizeForTLS is declared under ifdef GLIBC, but
the usage is not. Is this correct?
I think the comment " // TLS not in jdk11" should go into a new line.
Also, maybe we should make this "const" so it can be optimized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well,
I tried to keep the code around the usage of AdjustStackSizeForTLS as close to the original as possible. I was successful with that, but forgot about the protected declaration.

This did not pop up in the builds because we obviously always use glibc on linux platforms. Will fix.

@tstuefe
Copy link
Member

tstuefe commented Jul 19, 2023

I am unsure about this change. I think in itself it's not that important. Effectively it increases stack size of Non-Java-Threads by one page (Java threads should not use glibc guard pages).

Thing is, JDK-8225035 in itself is a lot more important than this change since it affects stack size for running hotspot embedded in a native app that uses a lot of TLS. And that delta is unpredictable, whereas here we are talking about one page.

But as @GoeLin writes, it is also more risky. And 11 is long out in the field; all native apps did have time getting used to the current VM behavior.

With downporting JDK-8229147, I don't see why we need the TLS parts of JDK-8225035 at all if all we want to have is "+ 1 page if glibc >= 2.27". You even hardcode AdjustStackSizeForTLS to false. Why not leave it out completely?

@GoeLin
Copy link
Member

GoeLin commented Jul 19, 2023

This one is a fix that takes effect for everybody.
8225025 needs to be enabled by setting a flag. I don't think these should be compared.
I assume there is a good reason this made it's way to jdk8 of Oracle and I don't see a reason not to go along.
The implementation is not that complex that the risk is too high to integrate it.

@tstuefe
Copy link
Member

tstuefe commented Jul 19, 2023

The implementation is not that complex that the risk is too high to integrate it.

Okay. Yes, you are right, its simple.

My only suggestion would be to remove all that TLS stuff, since it is not needed, and if we later want to downport 8225025, it would be more straightforward.

See https://gist.github.com/tstuefe/8a0fd30618f1d0e085b5ca12d7c156cd . Tested, works.

@RealLucy
Copy link
Contributor Author

The new commit reflects the changes requested by @GoeLin
Without the TLS stuff, this no longer feels like a backport to me. It is a separate fix then, triggered by JDK-8229147.

I'm only the backport person. You (@tstuefe and @GoeLin) decide and let me know.

@GoeLin
Copy link
Member

GoeLin commented Jul 19, 2023

it probably would be more clean if you movee AdjustStackSizeForTLS out from the ifdef glibc, then you don't need the ifdef you just added below.
But as this change does not touch get_static_tls_area_size() nor the block that calls it, I am also fine with removing both. We won't loose parts of this change as I understand.
After all it makes no big difference as the code is dead.

@tstuefe
Copy link
Member

tstuefe commented Jul 19, 2023

But as this change does not touch get_static_tls_area_size() nor the block that calls it, I am also fine with removing both. We won't loose parts of this change as I understand.

I leave it up to Lutz. I think less is better, but he is the patch author so his opinion has preference.

Copy link
Member

@GoeLin GoeLin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the edits!

@openjdk
Copy link

openjdk bot commented Jul 20, 2023

@RealLucy This change now passes all automated pre-integration checks.

After integration, the commit message for the final commit will be:

8229147: Linux os::create_thread() overcounts guardpage size with newer glibc (>=2.27)

Reviewed-by: goetz, stuefe

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 24 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 20, 2023
Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

}

// Dummy decl as substitute for cmdline parameter. TLS not in jdk11.
static const bool AdjustStackSizeForTLS = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could even be constexpr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just personal preference: I'd like to keep the integrated fix close to the original. I understand the KISS approach, though. It's just that I'm biased a bit more to the other side this time.

Very important: thank you for the discussion and for the reviews!

@RealLucy
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 25, 2023

Going to push as commit b49e8b2.
Since your change was applied there have been 28 commits pushed to the master branch:

  • 7051296: 8257993: vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/TestDescription.java crash intermittently
  • 6747c78: 8297923: java.awt.ScrollPane broken after multiple scroll up/down
  • 93419e5: 8295894: Remove SECOM certificate that is expiring in September 2023
  • f0b10f2: 8297681: Unnecessary color conversion during 4BYTE_ABGR_PRE to INT_ARGB_PRE blit
  • 864baf7: 8222323: ChildAlwaysOnTopTest.java fails with "RuntimeException: Failed to unset alwaysOnTop"
  • c06d748: 8277353: java/security/MessageDigest/ThreadSafetyTest.java test times out
  • 581b34f: 8305766: ProblemList runtime/CompressedOops/CompressedClassPointers.java
  • 35ec241: 8228341: SignTwice.java fails intermittently on Windows
  • 9774653: Merge
  • a829804: 8311465: [11u] Remove designator DEFAULT_PROMOTED_VERSION_PRE=ea for release 11.0.20
  • ... and 18 more: https://git.openjdk.org/jdk11u-dev/compare/667acaf9e33516ad003a857a5477e91beee8bd63...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 25, 2023
@openjdk openjdk bot closed this Jul 25, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 25, 2023
@openjdk
Copy link

openjdk bot commented Jul 25, 2023

@RealLucy Pushed as commit b49e8b2.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport integrated Pull request has been integrated
3 participants