[concurrency-interest] Does StampedLock need a releaseFence in theory?

Doug Lea dl at cs.oswego.edu
Fri Jul 15 13:49:03 EDT 2016


On 07/15/2016 10:27 AM, Will Deacon wrote:

> a fence would be required to maintain order with a subsequent store.

Thanks.

I now agree with Martin that we should add VarHandle.storeStoreFence
to write-unlock.

Backing up: We've long known that versioned locks (seqlocks, StampedLock)
should not in general allow "roach-motel" reorderings. We couldn't
introduce StampedLock until we had fence intrinsics for the load-load
case. But no one considered that the implementation of write-unlock
via CAS might permit hardware write reorderings. Thanks to the ARM
folks for finding the tiny bit of wiggle room in CAS specs that
might in theory (if not in practice) require the complementary
fence on unlock. Too bad this will slow down some implementations
for no good reason, but probably not noticeably. I wonder if/how
this impacts other versioned lock implementations in other
languages.

-Doug




More information about the Concurrency-interest mailing list