[aarch64-port-dev ] Question about JVM option "-XX:+UseBarriersForVolatile" usage in aarch64.
Xiaohong Gong
Xiaohong.Gong at arm.com
Mon Mar 30 09:20:11 UTC 2020
Hi,
Recently we met the Renassiance benchmark hang issue on AArch64 when running with VM option "-XX:+UseBarriersForVolatile".
We noticed that it should be the same memory sequentially consistent issue mentioned in JDK-8179954<https://bugs.openjdk.java.net/browse/JDK-8179954> which is caused by mixed
using "LDR, DMB ISHLD" for java volatile load and "STLR/STLXR" for volatile store.
JDK-8179954 resolved it by inserting a full barrier before the volatile load in C1/Interpreter. However it only happens with the VM
option "UseBarriersForVolatile" closed, because C2 only uses "LDAR/STLR" to implement the volatile access under it.
Here is a part of the fixing codes in Interpreter:
if (! UseBarriersForVolatile) {
Label notVolatile;
__ tbz(raw_flags, ConstantPoolCacheEntry::is_volatile_shift, notVolatile);
__ membar(MacroAssembler::AnyAny);
__ bind(notVolatile);
}
However, there are also some other places that use "STLR/STLXR" in hotspot when "UseBarriersForVolatile" is true, like monitor and
atomics. For atomics like CAS, they do not have a trailing "STORE_LOAD" barrier with "-XX:+UseBarriersForVolatile". This might have
the memory consistent issue if there is a subsequent volatile load ("LDR, DMB ISHLD").
Here is the codes generated for CAS by C2 with "-XX:+UseBarriersForVolatile":
dmb ish
retry:
ldxr w0, [address]
cmp w0, w1
b.ne done
stlxr w8, w2, [address]
cbnz w8, retry
done:
dmb ishld // LOAD_LOAD | LOAD_STORE
Without a STORE_LOAD barrier, the subsequent load could be float up before "stlxr" of the CAS. This might expected not to happen
if the load is a volatile one.
So my question is: what does the main usage of the option "-XX:+UseBarriersForVolatile" in real applications? Do we need to concern
the issues with it? If we do, so maybe the issue is valuable to be fixed.
I also created a JBS here: https://bugs.openjdk.java.net/browse/JDK-8241137.
Thanks,
Xiaohong Gong
More information about the aarch64-port-dev
mailing list