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

8329748: Change default value of AssertWXAtThreadSync to true #19102

Closed
wants to merge 2 commits into from

Conversation

tobiasholenstein
Copy link
Contributor

@tobiasholenstein tobiasholenstein commented May 6, 2024

The debug flag -XX:+AssertWXAtThreadSync conservatively checks for correct W^X thread state at possible safepoints or handshake. The flag is useful to detect missing MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread));. Since the check is cheap and it is a AARCH64_ONLY(develop(..)) only flag it makes sense to enable the flag by default.

There was one missing MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); to make all tests (tier1-7) pass.


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-8329748: Change default value of AssertWXAtThreadSync to true (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19102/head:pull/19102
$ git checkout pull/19102

Update a local copy of the PR:
$ git checkout pull/19102
$ git pull https://git.openjdk.org/jdk.git pull/19102/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19102

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19102.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 6, 2024

👋 Welcome back tholenstein! 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 May 6, 2024

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

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

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

8329748: Change default value of AssertWXAtThreadSync to true

Reviewed-by: kvn, rrich

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 128 new commits pushed to the master branch:

  • a33cb90: 8332098: Add missing @ since tags to jdk.jdi
  • 910d77b: 8331953: ubsan: metaspaceShared.cpp:1305:57: runtime error: applying non-zero offset 12849152 to null pointer
  • f9f8d0b: 8332101: Add an @since to StandardOperation:REMOVE in jdk.dynalink
  • f398cd2: 8331575: C2: crash when ConvL2I is split thru phi at LongCountedLoop
  • 96c5c3f: 8329998: Remove double initialization for parts of small TypeArrays in ZObjArrayAllocator
  • ee4a9d3: 8321622: ClassFile.verify(byte[] bytes) throws unexpected ConstantPoolException, IAE
  • ab8d7b0: 8324517: C2: crash in compiled code because of dependency on removed range check CastIIs
  • fe8a2af: 8307778: com/sun/jdi/cds tests fail with jtreg's Virtual test thread factory
  • 95f79c6: 8332253: Linux arm32 build fails after 8292591
  • b687aa5: 8332176: Refactor ClassListParser::parse()
  • ... and 118 more: https://git.openjdk.org/jdk/compare/15862a2f116331b7f439619c3aa1b5965e737044...master

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 changed the title JDK-8329748: Change default value of AssertWXAtThreadSync to true 8329748: Change default value of AssertWXAtThreadSync to true May 6, 2024
@openjdk
Copy link

openjdk bot commented May 6, 2024

@tobiasholenstein The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label May 6, 2024
@tobiasholenstein tobiasholenstein marked this pull request as ready for review May 6, 2024 11:28
@openjdk openjdk bot added the rfr Pull request is ready for review label May 6, 2024
@mlbridge
Copy link

mlbridge bot commented May 6, 2024

Webrevs

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 6, 2024
@@ -74,6 +74,7 @@ void* JfrIntrinsicSupport::write_checkpoint(JavaThread* jt) {

void* JfrIntrinsicSupport::return_lease(JavaThread* jt) {
DEBUG_ONLY(assert_precondition(jt);)
MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, jt));
Copy link
Member

Choose a reason for hiding this comment

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

It seems like this could be moved down. It doesn't seem to be needed for the Java --> native transition. Is it needed for the JfrJavaEventWriter::flush() call?

Copy link
Member

Choose a reason for hiding this comment

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

If it is only needed for the native --> Java transition below, why don't we do it lazily? The interpreter and compilers already do this by calling check_special_condition_for_native_trans() only if a safepoint is detected.
Normally we would want to be in the WXExec state when executing in _thread_in_native.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WXWrite is needed for

JfrIntrinsicSupport::return_lease ->
ThreadStateTransition::transition_from_native ->
SafepointMechanism::process_if_requested_with_exit_check ->
SafepointMechanism::process_if_requested ->
JavaThread::check_possible_safepoint ->
assert_wx_state(WXWrite)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally we would want to be in the WXExec state when executing in _thread_in_native.
I agree. So we would need to aquire WXWrite twice just for ThreadStateTransition::transition_from_java and again for ThreadStateTransition::transition_from_native. I think its a bit unfortune that WXWrite is needed for the state transition..

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need WXWrite for transition_from_java. I don't know how useful AssertWXAtThreadSync is if it forces us to make unnecessary transitions. It seems to go in the opposite direction from the more lazy approaches discussed in JDK-8307817.

@@ -74,6 +74,7 @@ void* JfrIntrinsicSupport::write_checkpoint(JavaThread* jt) {

void* JfrIntrinsicSupport::return_lease(JavaThread* jt) {
DEBUG_ONLY(assert_precondition(jt);)
MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, jt));
Copy link
Member

Choose a reason for hiding this comment

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

If it is only needed for the native --> Java transition below, why don't we do it lazily? The interpreter and compilers already do this by calling check_special_condition_for_native_trans() only if a safepoint is detected.
Normally we would want to be in the WXExec state when executing in _thread_in_native.

@dean-long
Copy link
Member

FWIW, I decided to look into WXExec as default (JDK-8328306), and in my draft so far I have removedAssertWXAtThreadSync completely, and I suspect that a successful implementation of exec-by-default will make JDK-8307817 no longer needed as well.

Copy link
Member

@reinrich reinrich left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me.
Thanks, Richard.

@tobiasholenstein
Copy link
Contributor Author

FWIW, I decided to look into WXExec as default (JDK-8328306), and in my draft so far I have removedAssertWXAtThreadSync completely, and I suspect that a successful implementation of exec-by-default will make JDK-8307817 no longer needed as well.

Thanks for looking at JDK-8328306. Sounds like an interesting approach that could simplify things with WXExec/WXWrite.
But do you think we can integrate this PR until JDK-8328306 is ready?

@dean-long
Copy link
Member

But do you think we can integrate this PR until JDK-8328306 is ready?

Sure, fine with me!

@tobiasholenstein
Copy link
Contributor Author

Thanks for the reviews @vnkozlov , @reinrich and @dean-long

/integrate

@openjdk
Copy link

openjdk bot commented May 22, 2024

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

  • 67f03f2: 8332533: RISC-V: Enable vector variable shift instructions for machines with RVV
  • 5f804b2: 8329825: Clarify the value type for java.net.SocketOptions.SO_LINGER
  • 52eda79: 8332538: Switch off JIT memory limit check for TestAlignVectorFuzzer.java
  • d999b81: 8331572: Allow using OopMapCache outside of STW GC phases
  • 8291c94: 8331224: ClassCastException in ObjectInputStream hides ClassNotFoundException
  • 42e3c84: 8332086: Remove the usage of ServiceLoader in j.u.r.RandomGeneratorFactory
  • 5cf8288: 8332153: RISC-V: enable tests and add comment for vector shift instruct (shared by vectorization and Vector API)
  • ae9ad86: 8331934: [s390x] Add support for primitive array C1 clone intrinsic
  • 3479b46: 8332595: Serial: Remove unused TenuredGeneration::should_collect
  • 9bfae88: 8332297: annotation processor that generates records sometimes fails due to NPE in javac
  • ... and 169 more: https://git.openjdk.org/jdk/compare/15862a2f116331b7f439619c3aa1b5965e737044...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 22, 2024

@tobiasholenstein Pushed as commit 3d511ff.

💡 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
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
4 participants