-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8278241: Implement JVM SpinPause on linux-aarch64 #6803
Conversation
👋 Welcome back eastig! A progress list of the required criteria for merging this PR into |
@nick-arm @theRealAph @stooart-mon |
Webrevs
|
This is way too complicated. I'd use |
|
||
SpinWait(Inst inst = NONE, int count = 0, InstRunner inst_runner = run_none) : | ||
_inst(inst), _count(count), _inst_runner(inst_runner) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense to have _inst_runner initialized in the constructor based on the value of Inst inst?
You aren't differentiating between the two in get_spin_wait_desc anyway.
Hi @theRealAph, Thank you for advice. It was a good exercise to learn how to write a stub generator. |
return 0; | ||
if (VM_Version::spin_wait_desc().inst() == SpinWait::NONE) { | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be safe and more efficient to test func for NULL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
spin_wait_func_ptr_t func = CAST_TO_FN_PTR(spin_wait_func_ptr_t, StubRoutines::aarch64::spin_wait()); | ||
if (func == nullptr) { | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better simply to give _spin_wait
a default value that points to a ret
instruction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -382,7 +382,13 @@ int os::extra_bang_size_in_bytes() { | |||
|
|||
extern "C" { | |||
int SpinPause() { | |||
return 0; | |||
using spin_wait_func_ptr_t = void (*)(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll want ThreadWXEnable wx(WXExec, thread);
for Apple here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, why do we need it here? This is linux-aarch64 implementation of SpinPause.
I think it should be in SpinPause in os_cpu/bsd_aarch64/os_bsd_aarch64.cpp
. Am I right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are indeed right. We can worry about Apple another day.
Two more changes. The first makes the code simpler, and the second makes it less fragile.
|
Thank you! I forgot Done. |
@eastig 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:
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 162 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@theRealAph, @phohensee) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
/sponsor |
Going to push as commit bcb79fd.
Your commit was automatically rebased without conflicts. |
@phohensee @eastig Pushed as commit bcb79fd. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This JVM SpinPause uses a spin wait stub. The stub is generated based on the
SpinWait
description which is defined withOnSpinWaitInst
/OnSpinWaitInstCount
options. TheSpinWait
provides the description of the instruction and the instruction count.The
SpinWait
description is also used for the_onSpinWait()
intrinsic. We don't have use cases when we need different implementations for the_onSpinWait()
intrinsic and JVM SpinPause.Testing results for fastdebug and release builds:
gtest
: Passedtier1
...tier4
: Passedhotspot/jtreg/runtime/Thread/TestSpinPause.java
: PassedJVM SpinPause is used for the synchronised statements and can benchmarked with
org.openjdk.bench.vm.lang.LockUnlock.testContendedLock
.Benchmarking results (number of samples per an experiment: 150) for Graviton2 (Neoverse N1), 1 ISB instruction:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6803/head:pull/6803
$ git checkout pull/6803
Update a local copy of the PR:
$ git checkout pull/6803
$ git pull https://git.openjdk.java.net/jdk pull/6803/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6803
View PR using the GUI difftool:
$ git pr show -t 6803
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6803.diff