# HG changeset patch # User Jin # Date 1462298232 14400 # Node ID 76df293e57aad419e9c6fd290b537ebcbffbf120 # Parent 52672a450193dd8ab6185b5a4e9a691a9249a577 [3A2000-B/4way] ParallelOldGC: add SYNC in BlockData When running on 3A2000B-4way, compiler crashes in Full GC. In BlockData, multiple threads writes to the same memory location without explict synchronization, Sync is required for access correctness. Ref: http://10.2.5.21:8000/projects/java/wiki/Jgj-log-2016-5-4_ [List.java] public class List extends Thread { public List sub[]; public List next; public List() { this.next = null; } public void insert(int n) { List p = new List(); p.next = this.next; this.next = p; p.sub = new List[404]; for (int i = 0; i < 404; i++) p.sub[i] = new List(); } public void run() { int i = 0; while(true) insert(i++); } public static void main(String[] args) throws Exception { int N = 16; Thread[] threads = new Thread[N]; for (int i = 0; i < N; i++) { List th = new List(); threads[i] = th; th.start(); } System.err.println(N + " threads Created."); for (int i = 0; i < N; i++) { threads[i].join(); } System.err.println("Done."); } } [1.sh] i=1 while true; do echo === $i === date #/opt/j2sdk-image-test/bin/java \ time \ numactl --cpunodebind=0 --membind=0 \ /mnt/j2sdk-image/bin/java \ -Xmx62M -Xms62M \ -XX:+PrintGC \ -XX:-UseCompressedOops \ -XX:+UnlockDiagnosticVMOptions \ -XX:ParallelGCThreads=2 \ -XX:+ScavengeBeforeFullGC \ -XX:+VerifyAfterGC \ List & #-XX:+UseNUMA \ sleep 10 killall -9 java i=$(($i+1)) done Effect: * Before: crashed in VerifyAfterGC * After: 50 times OK * compiler(-bt 16): OK, 97.86 ops/m% diff -r 52672a450193 -r 76df293e57aa src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Fri Apr 29 12:46:05 2016 -0400 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Tue May 03 13:57:12 2016 -0400 @@ -3233,6 +3233,13 @@ if (new_block != cur_block) { cur_block = new_block; sd.block(cur_block)->set_offset(bitmap->bits_to_words(live_bits)); + +#ifdef MIPS64 + /* 2016/5/4 Jin: On 3A2000-B, when multiple threads write to + the same memory location without explict synchronization, + sync is required for access correctness. */ + OrderAccess::fence(); +#endif } const size_t end_bit = bitmap->find_obj_end(beg_bit, range_end);