RFR: 8233061: ZGC: Enforce memory ordering in segmented bit maps
Erik Österlund
erik.osterlund at oracle.com
Mon Oct 28 15:53:05 UTC 2019
Hi,
In ZGC, bitmaps are lazily cleared in a segmented fashion. In this
scheme, liveness is determined by looking at a counter, a segment bit
map and finally the flat bit map structure. The accesses for the various
stages need to be ordered properly. This patch sprinkles some
OrderAccess calls to enforce this ordering.
Out of curiosity, I disassembled libjvm.so with and without this patch
to see if the reordering has bitten us in practice on x86_64.
Fortunately, according to my analysis, it has not; we seem to have been
lucky. But there is a lot of machine code, so I could have missed
something. However, given that we now have an AArch64 port which is
definitely affected by this problem, and compilers really are free to do
whatever they want to in the future, it seems in order to enforce this
explicitly.
This patch depends on https://bugs.openjdk.java.net/browse/JDK-8233073
which exposes some memory ordering aware getters on BitMap. I did not
want to just wrap the existing API in ZGC, so I split that out to a
separate RFE.
CR:
http://cr.openjdk.java.net/~eosterlund/8233061/webrev.00/
Bug:
https://bugs.openjdk.java.net/browse/JDK-8233061
Thanks,
/Erik
More information about the hotspot-gc-dev
mailing list