JDK-8067331 : Zero: Atomic::xchg and Atomic::xchg_ptr need full memory barrier
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-12-12
  • Updated: 2015-09-29
  • Resolved: 2015-01-08
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 8 JDK 9
8u60Fixed 9 b48Fixed
Description
Some code in hotspot depends on Atomic::xchg to be a full memory barrier. Example:


void Parker::park(bool isAbsolute, jlong time) {
  // Ideally we'd do something useful while spinning, such
  // as calling unpackTime().

  // Optional fast-path check:
  // Return immediately if a permit is available.
  // We depend on Atomic::xchg() having full barrier semantics
  // since we are doing a lock-free update to _counter.
  if (Atomic::xchg(0, &_counter) > 0) return;


However, the Zero implementation is not implemented as a full memory barrier.
Comments
Posted for review: http://mail.openjdk.java.net/pipermail/hotspot-dev/2014-December/016507.html
18-12-2014

Thanks, David. Since these are the only two Atomic::* implementations that use GCC's built-in __sync_lock_test_and_set (which is an aquire barrier) those are the only ones which need fixing AFAIUI.
15-12-2014

All Atomic operations are expected to be full memory barriers as described in atomic.hpp.
14-12-2014