RFR: 8341544: Restore fence() in Mutex

David Holmes dholmes at openjdk.org
Thu May 15 11:47:31 UTC 2025


On Thu, 15 May 2025 02:21:41 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> I'm conflicted. One the one hand we added the fence there because of the missing fence in the mutex, so if we fix mutex we should undo what we (only recently) did. On the other hand, the lack of a fence suggests to me we really don't need the SystemMemoryBarrier either.
>
>> the lack of a fence suggests to me we really don't need the SystemMemoryBarrier either.
> 
> No that is my ignorance/forgetfulness about what SMB does. On the platforms that set UseSMB true, they elide barriers in other parts of the code and then use the SMB here to account for that. Thanks @pchilano for refreshing my memory here.

> if we fix mutex we should undo what we (only recently) did.

Okay so I understand the argument for keeping these fences. The argument is that although we only discovered the missing mutex fence because of this code, this code (the handshake protocol) requires that a fence exist and it is better to be explicit about it rather than relying on the action-at-a-distance fence buried in the mutex code. We are fixing mutex to have the full fence, not so we can undo this change, but to ensure any other code that may be unknowingly broken by the missing mutex fence is now fixed again.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25033#discussion_r2090086158


More information about the hotspot-runtime-dev mailing list