JDK-8243326 : Cleanup use of volatile in taskqueue code
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-22
  • Updated: 2020-10-08
  • Resolved: 2020-04-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 15
11.0.9Fixed 15 b21Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Description
The array elements in a GenericTaskQueue are declared volatile.  This doesn't serve any useful purpose.  If the necessary memory and compiler barriers are present then making the elements volatile doesn't provide any needed ordering.  If if those barriers are not present then the volatile usage isn't sufficient, at least on platforms with weak memory ordering.

On the contrary, having the array elements declared volatile forces element type to support volatile copy assignment. That leads to problems. For C++14 we need to have some additional user-defined special functions to avoid deprecation warnings from gcc9.  But if we have multiple assignment operators then we need to suppress warnings from Visual Studio. And really, we want the element type to be trivially copyable.  By removing the unneeded volatile qualification of the array element type we can change most of the used classes to be trivially copyable.  (oop is an exception.)

Another place where the current use of volatile leads to problems is around the manipulation of the _age member.  By using explicit relaxed Atomic accesses we can simplify the Age class and its use, eliminating the need for all the volatile-qualified functions in the Age class.


Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/252a1602b4c6 User: kbarrett Date: 2020-04-29 11:45:16 +0000
29-04-2020

StarTask and ObjArrayTask require some change in this area to eliminate deprecation warnings. An alternative to modifying the taskqueue code would be to add more user-defined special operations and/or suppress warnings.
22-04-2020