Print this page
rev 2755 : 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:

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp
          +++ new/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp
↓ open down ↓ 139 lines elided ↑ open up ↑
 140  140          }
 141  141  
 142  142          if (cm()->restart_for_overflow()) {
 143  143            if (PrintGC) {
 144  144              gclog_or_tty->date_stamp(PrintGCDateStamps);
 145  145              gclog_or_tty->stamp(PrintGCTimeStamps);
 146  146              gclog_or_tty->print_cr("[GC concurrent-mark-restart-for-overflow]");
 147  147            }
 148  148          }
 149  149        } while (cm()->restart_for_overflow());
 150      -      double counting_start_time = os::elapsedVTime();
 151      -
 152      -      // YSR: These look dubious (i.e. redundant) !!! FIX ME
 153      -      slt()->manipulatePLL(SurrogateLockerThread::acquirePLL);
 154      -      slt()->manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
 155  150  
      151 +      double counting_start_time = os::elapsedVTime();
 156  152        if (!cm()->has_aborted()) {
 157  153          double count_start_sec = os::elapsedTime();
 158  154          if (PrintGC) {
 159  155            gclog_or_tty->date_stamp(PrintGCDateStamps);
 160  156            gclog_or_tty->stamp(PrintGCTimeStamps);
 161  157            gclog_or_tty->print_cr("[GC concurrent-count-start]");
 162  158          }
 163  159  
 164  160          _sts.join();
 165  161          _cm->calcDesiredRegions();
↓ open down ↓ 2 lines elided ↑ open up ↑
 168  164          if (!cm()->has_aborted()) {
 169  165            double count_end_sec = os::elapsedTime();
 170  166            if (PrintGC) {
 171  167              gclog_or_tty->date_stamp(PrintGCDateStamps);
 172  168              gclog_or_tty->stamp(PrintGCTimeStamps);
 173  169              gclog_or_tty->print_cr("[GC concurrent-count-end, %1.7lf]",
 174  170                                     count_end_sec - count_start_sec);
 175  171            }
 176  172          }
 177  173        }
      174 +
 178  175        double end_time = os::elapsedVTime();
 179  176        _vtime_count_accum += (end_time - counting_start_time);
 180  177        // Update the total virtual time before doing this, since it will try
 181  178        // to measure it to get the vtime for this marking.  We purposely
 182  179        // neglect the presumably-short "completeCleanup" phase here.
 183  180        _vtime_accum = (end_time - _vtime_start);
 184  181        if (!cm()->has_aborted()) {
 185  182          if (g1_policy->adaptive_young_list_length()) {
 186  183            double now = os::elapsedTime();
 187  184            double cleanup_prediction_ms = g1_policy->predict_cleanup_time_ms();
↓ open down ↓ 140 lines elided ↑ open up ↑
 328  325    assert(!in_progress(), "should have been cleared");
 329  326  
 330  327    MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
 331  328    while (!started()) {
 332  329      CGC_lock->wait(Mutex::_no_safepoint_check_flag);
 333  330    }
 334  331    set_in_progress();
 335  332    clear_started();
 336  333  }
 337  334  
 338      -// Note: this method, although exported by the ConcurrentMarkSweepThread,
      335 +// Note: this method, although exported by the ConcurrentMarkThread,
 339  336  // which is a non-JavaThread, can only be called by a JavaThread.
 340  337  // Currently this is done at vm creation time (post-vm-init) by the
 341  338  // main/Primordial (Java)Thread.
 342      -// XXX Consider changing this in the future to allow the CMS thread
      339 +// XXX Consider changing this in the future to allow the CM thread
 343  340  // itself to create this thread?
 344  341  void ConcurrentMarkThread::makeSurrogateLockerThread(TRAPS) {
      342 +  assert(UseG1GC, "SLT thread needed only for concurrent GC");
      343 +  assert(THREAD->is_Java_thread(), "must be a Java thread");
 345  344    assert(_slt == NULL, "SLT already created");
 346  345    _slt = SurrogateLockerThread::make(THREAD);
 347  346  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX