comparison src/share/vm/gc_implementation/g1/vm_operations_g1.cpp @ 4022:db89aa49298f

7099824: G1: we should take the pending list lock before doing the remark pause Summary: Acquire the pending list lock in the prologue method of G1's concurrent VM_Operation and release the lock in the epilogue() method. The locking/unlocking order of the pending list lock and the Heap_lock should match that in the prologue and epilogue methods of VM_GC_Operation. Reviewed-by: tonyp, ysr
author johnc
date Thu, 20 Oct 2011 12:06:20 -0700
parents 20213c8a3c40
children 9509c20bba28
comparison
equal deleted inserted replaced
4021:8d161913dfc3 4022:db89aa49298f
21 * questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
26 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
27 #include "gc_implementation/g1/g1CollectorPolicy.hpp" 28 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
28 #include "gc_implementation/g1/vm_operations_g1.hpp" 29 #include "gc_implementation/g1/vm_operations_g1.hpp"
29 #include "gc_implementation/shared/isGCActiveMark.hpp" 30 #include "gc_implementation/shared/isGCActiveMark.hpp"
30 #include "gc_implementation/g1/vm_operations_g1.hpp" 31 #include "gc_implementation/g1/vm_operations_g1.hpp"
163 } 164 }
164 } 165 }
165 } 166 }
166 } 167 }
167 168
169 void VM_CGC_Operation::acquire_pending_list_lock() {
170 // The caller may block while communicating
171 // with the SLT thread in order to acquire/release the PLL.
172 ConcurrentMarkThread::slt()->
173 manipulatePLL(SurrogateLockerThread::acquirePLL);
174 }
175
176 void VM_CGC_Operation::release_and_notify_pending_list_lock() {
177 // The caller may block while communicating
178 // with the SLT thread in order to acquire/release the PLL.
179 ConcurrentMarkThread::slt()->
180 manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
181 }
182
168 void VM_CGC_Operation::doit() { 183 void VM_CGC_Operation::doit() {
169 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); 184 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
170 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 185 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
171 TraceTime t(_printGCMessage, PrintGC, true, gclog_or_tty); 186 TraceTime t(_printGCMessage, PrintGC, true, gclog_or_tty);
172 SharedHeap* sh = SharedHeap::heap(); 187 SharedHeap* sh = SharedHeap::heap();
178 _cl->do_void(); 193 _cl->do_void();
179 } 194 }
180 } 195 }
181 196
182 bool VM_CGC_Operation::doit_prologue() { 197 bool VM_CGC_Operation::doit_prologue() {
198 // Note the relative order of the locks must match that in
199 // VM_GC_Operation::doit_prologue() or deadlocks can occur
200 acquire_pending_list_lock();
201
183 Heap_lock->lock(); 202 Heap_lock->lock();
184 SharedHeap::heap()->_thread_holds_heap_lock_for_gc = true; 203 SharedHeap::heap()->_thread_holds_heap_lock_for_gc = true;
185 return true; 204 return true;
186 } 205 }
187 206
188 void VM_CGC_Operation::doit_epilogue() { 207 void VM_CGC_Operation::doit_epilogue() {
208 // Note the relative order of the unlocks must match that in
209 // VM_GC_Operation::doit_epilogue()
189 SharedHeap::heap()->_thread_holds_heap_lock_for_gc = false; 210 SharedHeap::heap()->_thread_holds_heap_lock_for_gc = false;
190 Heap_lock->unlock(); 211 Heap_lock->unlock();
191 } 212 release_and_notify_pending_list_lock();
213 }