-
Notifications
You must be signed in to change notification settings - Fork 20
Add StoreLoad barriers to ObjectMonitor::try_spin() for ARM64 Dekker … #50
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
base: macarte/PR1-winarm64
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2439,6 +2439,16 @@ bool ObjectMonitor::try_spin(JavaThread* current) { | |
| if (!has_successor()) { | ||
| set_successor(current); | ||
| } | ||
| // Dekker/Lamport duality with exit(): ST _succ; MEMBAR; LD _owner. | ||
| // The exiter's side (release_clear_owner + storeload) is in exit(). | ||
| // Here on the spinner's side, we need a StoreLoad barrier between | ||
| // setting _succ and reading _owner to prevent the CPU from reordering | ||
| // the _owner load before the _succ store. On ARM64 with MSVC | ||
| // /volatile:iso, Atomic::store/load are plain STR/LDR with no | ||
| // barrier, so without this fence the Dekker protocol is broken and | ||
| // the exiter may not see our successor designation while we may not | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this fence still needed now that Atomic::store/load are no longer plain STR/LDRs?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
One reason this might not be needed is the explanation in https://github.com/openjdk/jdk/blob/9d4fbbe36d85d71ce850bb83bbfb1ce1d3e8dd23/src/hotspot/share/runtime/objectMonitor.cpp#L1586 - "the try_set_owner_from() below uses cmpxchg() so we get the fence down there." (this would be line 2492 in the right view of this file) |
||
| // see its lock release — leading to missed wakeups and starvation. | ||
| OrderAccess::storeload(); | ||
| int64_t prv = NO_OWNER; | ||
|
|
||
| // There are three ways to exit the following loop: | ||
|
|
@@ -2514,6 +2524,8 @@ bool ObjectMonitor::try_spin(JavaThread* current) { | |
|
|
||
| if (!has_successor()) { | ||
| set_successor(current); | ||
| // See Dekker/storeload comment before the loop. | ||
| OrderAccess::storeload(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
This comment should probably be reworded to remove the statement that /volatile:iso is in use if we intend to switch to /volatile:ms