changeset 3695:2e6857353b2c

8000311: G1: ParallelGCThreads==0 broken Summary: Divide by zero error, if ParallelGCThreads is 0, when adjusting the PLAB size. Reviewed-by: jmasa, jcoomes
author johnc
date Thu, 04 Oct 2012 10:04:13 -0700
parents 22b8d3d181d9
children ca70b919819f
files src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp src/share/vm/gc_implementation/parNew/parNewGeneration.cpp src/share/vm/gc_implementation/shared/parGCAllocBuffer.cpp src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp
diffstat 5 files changed, 33 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Oct 03 20:31:41 2012 +0200
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Oct 04 10:04:13 2012 -0700
@@ -4151,7 +4151,7 @@
   }
 }
 
-void G1CollectedHeap::release_gc_alloc_regions() {
+void G1CollectedHeap::release_gc_alloc_regions(uint no_of_gc_workers) {
   _survivor_gc_alloc_region.release();
   // If we have an old GC alloc region to release, we'll save it in
   // _retained_old_gc_alloc_region. If we don't
@@ -4161,8 +4161,8 @@
   _retained_old_gc_alloc_region = _old_gc_alloc_region.release();
 
   if (ResizePLAB) {
-    _survivor_plab_stats.adjust_desired_plab_sz();
-    _old_plab_stats.adjust_desired_plab_sz();
+    _survivor_plab_stats.adjust_desired_plab_sz(no_of_gc_workers);
+    _old_plab_stats.adjust_desired_plab_sz(no_of_gc_workers);
   }
 }
 
@@ -5427,7 +5427,7 @@
 };
 
 // Weak Reference processing during an evacuation pause (part 1).
-void G1CollectedHeap::process_discovered_references() {
+void G1CollectedHeap::process_discovered_references(uint no_of_gc_workers) {
   double ref_proc_start = os::elapsedTime();
 
   ReferenceProcessor* rp = _ref_processor_stw;
@@ -5454,15 +5454,14 @@
   // referents points to another object which is also referenced by an
   // object discovered by the STW ref processor.
 
-  uint active_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
-                        workers()->active_workers() : 1);
-
   assert(!G1CollectedHeap::use_parallel_gc_threads() ||
-           active_workers == workers()->active_workers(),
-           "Need to reset active_workers");
-
-  set_par_threads(active_workers);
-  G1ParPreserveCMReferentsTask keep_cm_referents(this, active_workers, _task_queues);
+           no_of_gc_workers == workers()->active_workers(),
+           "Need to reset active GC workers");
+
+  set_par_threads(no_of_gc_workers);
+  G1ParPreserveCMReferentsTask keep_cm_referents(this,
+                                                 no_of_gc_workers,
+                                                 _task_queues);
 
   if (G1CollectedHeap::use_parallel_gc_threads()) {
     workers()->run_task(&keep_cm_referents);
@@ -5528,10 +5527,10 @@
                                       NULL);
   } else {
     // Parallel reference processing
-    assert(rp->num_q() == active_workers, "sanity");
-    assert(active_workers <= rp->max_num_q(), "sanity");
-
-    G1STWRefProcTaskExecutor par_task_executor(this, workers(), _task_queues, active_workers);
+    assert(rp->num_q() == no_of_gc_workers, "sanity");
+    assert(no_of_gc_workers <= rp->max_num_q(), "sanity");
+
+    G1STWRefProcTaskExecutor par_task_executor(this, workers(), _task_queues, no_of_gc_workers);
     rp->process_discovered_references(&is_alive, &keep_alive, &drain_queue, &par_task_executor);
   }
 
@@ -5546,7 +5545,7 @@
 }
 
 // Weak Reference processing during an evacuation pause (part 2).
-void G1CollectedHeap::enqueue_discovered_references() {
+void G1CollectedHeap::enqueue_discovered_references(uint no_of_gc_workers) {
   double ref_enq_start = os::elapsedTime();
 
   ReferenceProcessor* rp = _ref_processor_stw;
@@ -5560,13 +5559,12 @@
   } else {
     // Parallel reference enqueuing
 
-    uint active_workers = (ParallelGCThreads > 0 ? workers()->active_workers() : 1);
-    assert(active_workers == workers()->active_workers(),
-           "Need to reset active_workers");
-    assert(rp->num_q() == active_workers, "sanity");
-    assert(active_workers <= rp->max_num_q(), "sanity");
-
-    G1STWRefProcTaskExecutor par_task_executor(this, workers(), _task_queues, active_workers);
+    assert(no_of_gc_workers == workers()->active_workers(),
+           "Need to reset active workers");
+    assert(rp->num_q() == no_of_gc_workers, "sanity");
+    assert(no_of_gc_workers <= rp->max_num_q(), "sanity");
+
+    G1STWRefProcTaskExecutor par_task_executor(this, workers(), _task_queues, no_of_gc_workers);
     rp->enqueue_discovered_references(&par_task_executor);
   }
 
@@ -5658,7 +5656,7 @@
   // as we may have to copy some 'reachable' referent
   // objects (and their reachable sub-graphs) that were
   // not copied during the pause.
-  process_discovered_references();
+  process_discovered_references(n_workers);
 
   // Weak root processing.
   // Note: when JSR 292 is enabled and code blobs can contain
@@ -5670,7 +5668,7 @@
     JNIHandles::weak_oops_do(&is_alive, &keep_alive);
   }
 
-  release_gc_alloc_regions();
+  release_gc_alloc_regions(n_workers);
   g1_rem_set()->cleanup_after_oops_into_collection_set_do();
 
   concurrent_g1_refine()->clear_hot_cache();
@@ -5694,7 +5692,7 @@
   // will log these updates (and dirty their associated
   // cards). We need these updates logged to update any
   // RSets.
-  enqueue_discovered_references();
+  enqueue_discovered_references(n_workers);
 
   if (G1DeferredRSUpdate) {
     RedirtyLoggedCardTableEntryFastClosure redirty;
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Oct 03 20:31:41 2012 +0200
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Thu Oct 04 10:04:13 2012 -0700
@@ -326,7 +326,7 @@
   void init_gc_alloc_regions();
 
   // It releases the GC alloc regions at the end of a GC.
-  void release_gc_alloc_regions();
+  void release_gc_alloc_regions(uint no_of_gc_workers);
 
   // It does any cleanup that needs to be done on the GC alloc regions
   // before a Full GC.
@@ -652,11 +652,11 @@
 
   // Process any reference objects discovered during
   // an incremental evacuation pause.
-  void process_discovered_references();
+  void process_discovered_references(uint no_of_gc_workers);
 
   // Enqueue any remaining discovered references
   // after processing.
-  void enqueue_discovered_references();
+  void enqueue_discovered_references(uint no_of_gc_workers);
 
 public:
 
--- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	Wed Oct 03 20:31:41 2012 +0200
+++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	Thu Oct 04 10:04:13 2012 -0700
@@ -1037,7 +1037,7 @@
 
   adjust_desired_tenuring_threshold();
   if (ResizePLAB) {
-    plab_stats()->adjust_desired_plab_sz();
+    plab_stats()->adjust_desired_plab_sz(n_workers);
   }
 
   if (PrintGC && !PrintGCDetails) {
--- a/src/share/vm/gc_implementation/shared/parGCAllocBuffer.cpp	Wed Oct 03 20:31:41 2012 +0200
+++ b/src/share/vm/gc_implementation/shared/parGCAllocBuffer.cpp	Thu Oct 04 10:04:13 2012 -0700
@@ -87,7 +87,7 @@
 // Compute desired plab size and latch result for later
 // use. This should be called once at the end of parallel
 // scavenge; it clears the sensor accumulators.
-void PLABStats::adjust_desired_plab_sz() {
+void PLABStats::adjust_desired_plab_sz(uint no_of_gc_workers) {
   assert(ResizePLAB, "Not set");
   if (_allocated == 0) {
     assert(_unused == 0,
@@ -107,7 +107,7 @@
     target_refills = 1;
   }
   _used = _allocated - _wasted - _unused;
-  size_t plab_sz = _used/(target_refills*ParallelGCThreads);
+  size_t plab_sz = _used/(target_refills*no_of_gc_workers);
   if (PrintPLAB) gclog_or_tty->print(" (plab_sz = %d ", plab_sz);
   // Take historical weighted average
   _filter.sample(plab_sz);
--- a/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp	Wed Oct 03 20:31:41 2012 +0200
+++ b/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp	Thu Oct 04 10:04:13 2012 -0700
@@ -204,7 +204,8 @@
     return _desired_plab_sz;
   }
 
-  void adjust_desired_plab_sz(); // filter computation, latches output to
+  void adjust_desired_plab_sz(uint no_of_gc_workers);
+                                 // filter computation, latches output to
                                  // _desired_plab_sz, clears sensor accumulators
 
   void add_allocated(size_t v) {