comparison src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp @ 2365:a181f3a124dd

6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent Summary: Count enable_icms() and disable_icms() events so as to prevent inteference between concurrent calls, which can cause the iCMS thread to be left stranded in icms_wait() with an unserviced request and no young allocations to unwedge it. Reviewed-by: jcoomes, poonam
author ysr
date Mon, 14 Mar 2011 21:52:24 -0700
parents f95d63e2154a
children 436b4a3231bf
comparison
equal deleted inserted replaced
2364:04d1138b4cce 2365:a181f3a124dd
1 /* 1 /*
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
190 (GC_locker::is_active() /* gc may have been skipped */ 190 (GC_locker::is_active() /* gc may have been skipped */
191 && (_gc_count_before == gch->total_collections())), 191 && (_gc_count_before == gch->total_collections())),
192 "total_collections() should be monotonically increasing"); 192 "total_collections() should be monotonically increasing");
193 193
194 MutexLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag); 194 MutexLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
195 assert(_full_gc_count_before <= gch->total_full_collections(), "Error");
195 if (gch->total_full_collections() == _full_gc_count_before) { 196 if (gch->total_full_collections() == _full_gc_count_before) {
196 // Disable iCMS until the full collection is done. 197 // Disable iCMS until the full collection is done, and
198 // remember that we did so.
197 CMSCollector::disable_icms(); 199 CMSCollector::disable_icms();
200 _disabled_icms = true;
198 // In case CMS thread was in icms_wait(), wake it up. 201 // In case CMS thread was in icms_wait(), wake it up.
199 CMSCollector::start_icms(); 202 CMSCollector::start_icms();
200 // Nudge the CMS thread to start a concurrent collection. 203 // Nudge the CMS thread to start a concurrent collection.
201 CMSCollector::request_full_gc(_full_gc_count_before); 204 CMSCollector::request_full_gc(_full_gc_count_before);
202 } else { 205 } else {
206 assert(_full_gc_count_before < gch->total_full_collections(), "Error");
203 FullGCCount_lock->notify_all(); // Inform the Java thread its work is done 207 FullGCCount_lock->notify_all(); // Inform the Java thread its work is done
204 } 208 }
205 } 209 }
206 210
207 bool VM_GenCollectFullConcurrent::evaluate_at_safepoint() const { 211 bool VM_GenCollectFullConcurrent::evaluate_at_safepoint() const {
257 // witness to our request. 261 // witness to our request.
258 while (gch->total_full_collections_completed() <= _full_gc_count_before) { 262 while (gch->total_full_collections_completed() <= _full_gc_count_before) {
259 FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag); 263 FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag);
260 } 264 }
261 } 265 }
262 // Enable iCMS back. 266 // Enable iCMS back if we disabled it earlier.
263 CMSCollector::enable_icms(); 267 if (_disabled_icms) {
264 } 268 CMSCollector::enable_icms();
269 }
270 }