RFR: 8243326: Cleanup use of volatile in taskqueue code

Kim Barrett kim.barrett at oracle.com
Wed Apr 22 08:49:02 UTC 2020


Please review this change that eliminates most uses of the volatile
qualifier in the taskqueue code.  The remaining uses are in the
declarations of the queue's _bottom and _age members.  That's just our
current style of tagging "atomic" variables manipulated by multiple
threads.

To help with readability, all relaxed atomic operations on _bottom and
_age are now explicit.

Restructured the API and usage for the Age class so that we no longer
need any volatile-qualified operations.  This was also part of making
the relaxed atomic operations explicit.

One of the removed volatile qualifiers was for the elements of the
queue's array of elements, along with the push and pop_local/global
arguments.  This allowed StarTask, ObjArrayTask, and G1TaskQueueEntry
to be changed to be "trivially copyable" (C++14 3.9/9).  We needed to
make *some* change to StarTask and ObjArrayTask for C++14, as gcc9
would otherwise warning about deprecated implicit copy constructors
(C++14 12.8/7 and 12.8/18).

Swapped the argument order for the cmpxchg helper for updating _age to
be consistent with Atomic::cmpxchg.

Added padding for false sharing avoidance around the _bottom and _top
members, since they are frequently accessed by multiple threads.

Added a comment to pop_global describing the requirements for the
element type in order to cope with possible concurrent read and
write by push and pop_global.

There are other refactorings that I considered but decided to leave
to another time (if ever) because they changed the code a bit too
much.

CR:
https://bugs.openjdk.java.net/browse/JDK-8243326

Webrev:
https://cr.openjdk.java.net/~kbarrett/8243326/open.00/

Testing:
mach5 tier1-7, which includes some stress tests.

There might be a small performance benefit from the added padding
around _bottom and _age, but I didn't try to measure that.




More information about the hotspot-gc-dev mailing list