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

8261649: AArch64: Optimize LSE atomics in C++ code #2611

Closed
wants to merge 9 commits into from

Conversation

theRealAph
Copy link
Contributor

@theRealAph theRealAph commented Feb 17, 2021

Now that we have support for LSE atomics in C++ HotSpot source, we can generate much better code for them. In particular, the sequence we generate for CMPXCHG with a full two-way barrier using two DMBs is way suboptimal.

This patch:

Moves memory barriers from the atomic_linux_aarch64 file into the stubs.
Rewrites the LSE versions of the stubs to be more efficient.
Fixes a race condition in stub generation.
Mostly leaves the pre-LSE stubs alone, except that I added a PRFM which according to kernel engineers improves performance.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8261649: AArch64: Optimize LSE atomics in C++ code

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2611/head:pull/2611
$ git checkout pull/2611

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 17, 2021

👋 Welcome back aph! 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 added rfr Pull request is ready for review hotspot hotspot-dev@openjdk.org labels Feb 17, 2021
@openjdk
Copy link

openjdk bot commented Feb 17, 2021

@theRealAph
The hotspot label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Feb 17, 2021

Webrevs

exchange_val = c_rarg2;
__ mov(prev, compare_val);
__ lse_cas(prev, exchange_val, ptr, size, acquire, release, /*not_pair*/true);
if (acquire && release) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These two flags are only ever passed as true,true or false,false. Does any other combination make sense? If not then should you not be using a single flag? or at least asserting (pro tem) that they are both equal?

Copy link
Contributor Author

@theRealAph theRealAph Feb 18, 2021

Choose a reason for hiding this comment

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

Today HotSpot only really supports mo_conservative and mo_relaxed, but there are many places in HotSpot where release on its own would make sense; I think Aleksey recently found some. Having said that, it would be clearer here to expose mo_conservative as well. I'll do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clearer now?

Copy link
Contributor

@adinn adinn left a comment

Choose a reason for hiding this comment

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

Ok, this looks good enough to me.

@openjdk
Copy link

openjdk bot commented Feb 18, 2021

@theRealAph 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:

8261649: AArch64: Optimize LSE atomics in C++ code

Reviewed-by: adinn

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

  • 0e9c5ae: 8075909: [TEST_BUG] The regression-swing case failed as it does not have the 'Open' button when select 'subdir' folder with NimbusLAF
  • e9f3aab: 8261912: Code IfNode::fold_compares_helper more defensively
  • fd098e7: 8261838: Shenandoah: reconsider heap region iterators memory ordering
  • f94a845: 8261600: NMT: Relax memory order for updating MemoryCounter and fix racy updating of peak values
  • 1a7adc8: 8260416: Remove unused method ReferenceProcessor::is_mt_processing_set_up()
  • 3a21e1d: 8260653: Unreachable nodes keep speculative types alive
  • b695c7e: 8261925: ProblemList com/sun/jdi/AfterThreadDeathTest.java on Linux
  • 97e1657: 8261846: [JVMCI] c2v_iterateFrames can get out of sync with the StackFrameStream
  • b8fd614: 8261939: os::strdup_check_oom() should be used in os::same_files() in os_windows.cpp
  • 5f30829: 8202750: Reduce the use of get_canonical_path() in CDS
  • ... and 3 more: https://git.openjdk.java.net/jdk/compare/05301f5fd2b5f2357024a3d7bb788270861220a8...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 added the ready Pull request is ready to be integrated label Feb 18, 2021
@theRealAph
Copy link
Contributor Author

Ok, this looks good enough to me.

I pulled the vm_version.cpp change, which I committed by mistake. I think it's the right thing to do, but it needs a separate discussion. OK?

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Passer-by comments...

src/hotspot/cpu/aarch64/vm_version_aarch64.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp Outdated Show resolved Hide resolved
@adinn
Copy link
Contributor

adinn commented Feb 18, 2021

The memory_order_conservative/relaxed change is better. still good to go.

@theRealAph
Copy link
Contributor Author

/integrate

@theRealAph theRealAph closed this Feb 19, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 19, 2021
@openjdk
Copy link

openjdk bot commented Feb 19, 2021

@theRealAph Since your change was applied there have been 24 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

Pushed as commit 1b0c36b.

💡 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
Development

Successfully merging this pull request may close these issues.

3 participants