comparison src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp @ 1887:cd3ef3fd20dd

6992998: CMSWaitDuration=0 causes hangs with +ExplicitGCInvokesConcurrent Summary: Closed a timing hole during which concurrent full gc requests can be missed. The hole can increase the latency of the response to a full gc request by up to the value of CMSWaitDuration. If CMSWaitDuration=0 is, as currently, interpreted as an unbounded wait, suitable in certain tuning scenarios, the application can potentially hang. Made two obscure tunables, including CMSWaitDuration, manageable. Reviewed-by: jcoomes, tonyp
author ysr
date Thu, 21 Oct 2010 17:29:24 -0700
parents c18cbe5936b8
children f95d63e2154a
comparison
equal deleted inserted replaced
1886:72a161e62cc4 1887:cd3ef3fd20dd
1 /* 1 /*
2 * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2010, 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.
270 assert(!CMS_flag_is_set(CMS_cms_has_token | CMS_cms_wants_token), 270 assert(!CMS_flag_is_set(CMS_cms_has_token | CMS_cms_wants_token),
271 "Should have been cleared"); 271 "Should have been cleared");
272 } 272 }
273 } 273 }
274 274
275 // Wait until the next synchronous GC or a timeout, whichever is earlier. 275 // Wait until the next synchronous GC, a concurrent full gc request,
276 void ConcurrentMarkSweepThread::wait_on_cms_lock(long t) { 276 // or a timeout, whichever is earlier.
277 void ConcurrentMarkSweepThread::wait_on_cms_lock(long t_millis) {
277 MutexLockerEx x(CGC_lock, 278 MutexLockerEx x(CGC_lock,
278 Mutex::_no_safepoint_check_flag); 279 Mutex::_no_safepoint_check_flag);
280 if (_should_terminate || _collector->_full_gc_requested) {
281 return;
282 }
279 set_CMS_flag(CMS_cms_wants_token); // to provoke notifies 283 set_CMS_flag(CMS_cms_wants_token); // to provoke notifies
280 CGC_lock->wait(Mutex::_no_safepoint_check_flag, t); 284 CGC_lock->wait(Mutex::_no_safepoint_check_flag, t_millis);
281 clear_CMS_flag(CMS_cms_wants_token); 285 clear_CMS_flag(CMS_cms_wants_token);
282 assert(!CMS_flag_is_set(CMS_cms_has_token | CMS_cms_wants_token), 286 assert(!CMS_flag_is_set(CMS_cms_has_token | CMS_cms_wants_token),
283 "Should not be set"); 287 "Should not be set");
284 } 288 }
285 289
287 while (!_should_terminate) { 291 while (!_should_terminate) {
288 if (CMSIncrementalMode) { 292 if (CMSIncrementalMode) {
289 icms_wait(); 293 icms_wait();
290 return; 294 return;
291 } else { 295 } else {
292 // Wait until the next synchronous GC or a timeout, whichever is earlier 296 // Wait until the next synchronous GC, a concurrent full gc
297 // request or a timeout, whichever is earlier.
293 wait_on_cms_lock(CMSWaitDuration); 298 wait_on_cms_lock(CMSWaitDuration);
294 } 299 }
295 // Check if we should start a CMS collection cycle 300 // Check if we should start a CMS collection cycle
296 if (_collector->shouldConcurrentCollect()) { 301 if (_collector->shouldConcurrentCollect()) {
297 return; 302 return;