RFR: 8341544: Restore fence() in Mutex

Erik Österlund eosterlund at openjdk.org
Thu May 15 11:47:30 UTC 2025


On Wed, 14 May 2025 11:52:58 GMT, David Holmes <dholmes at openjdk.org> wrote:

> > > As per JBS comment I still think we only need to add the missing storeload part of the full-fence, to complement the existing barriers the platform sync primitives provide.
> 
> > 
> 
> > Pretty sure the comment that the old mutex implementation we removed had, describing the API guarantees, said the semantics was fence() lock() acquire(). Since we are putting back what used to be there - shouldn't that simply be fence()?
> 
> 
> 
> @fisk you seemed to agree with my JBS comment that what we are missing is only the storeload part of the combined "fence". The sync primitives already provide the necessary roach-motel barriers, they just lack the storeload that would provide the full "fence". The old code simply used a CAS that had "full bi-directional fence semantics" which itself implemented the lock part.

While that's true, I'm more concerned with restoring the previously documented API contract than anything else. And it said fence() lock() acquire().

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

PR Comment: https://git.openjdk.org/jdk/pull/25033#issuecomment-2879934740


More information about the hotspot-runtime-dev mailing list