RFR: 8256474: Migrate Mutex _owner accesses to use Atomic operations

Kim Barrett kbarrett at openjdk.java.net
Tue Nov 24 02:16:56 UTC 2020


On Mon, 23 Nov 2020 23:08:28 GMT, David Holmes <dholmes at openjdk.org> wrote:

> Simple update to move away from volatile fields and use Atomic::load/store on racy accesses.
> 
> Thanks,
> David

Changes requested by kbarrett (Reviewer).

src/hotspot/share/runtime/mutex.hpp line 89:

> 87:   // the low-level _lock, or to NULL after it has released the _lock. Accesses by any thread other
> 88:   // than the lock owner are inherently racy.
> 89:   Thread* _owner;

My understanding of the idiom of using Atomic always rather than relying on any semantics for volatile is that the volatile qualifier is left on the variable, as a marker/indicator/clue that it is interesting.  This will also help us find such if/when we adopt some kind of atomic class for encapsulation (whether std::atomic or something like what was proposed for JDK-8247213) and help track adoption progress.  So I think the volatile qualifier should be retained.

src/hotspot/share/runtime/mutex.hpp line 87:

> 85:  private:
> 86:   // The _owner field is only set by the current thread, either to itself after it has acquired
> 87:   // the low-level _lock, or to NULL after it has released the _lock. Accesses by any thread other

s/after/before/

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

PR: https://git.openjdk.java.net/jdk/pull/1402


More information about the hotspot-runtime-dev mailing list