changeset 39231:e6aa09b4f1b9

8157620: Guarantee in run_task(task, num_workers) fails Reviewed-by: tschatzl, drwhite
author jmasa
date Wed, 25 May 2016 09:28:20 -0700
parents b991240ffb0d
children 1fe5a068bdab
files hotspot/src/share/vm/gc/shared/workgroup.cpp hotspot/src/share/vm/gc/shared/workgroup.hpp hotspot/test/gc/stress/TestGCOld.java
diffstat 3 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/gc/shared/workgroup.cpp	Fri Jun 10 14:06:36 2016 +0200
+++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp	Wed May 25 09:28:20 2016 -0700
@@ -60,6 +60,10 @@
 }
 
 void AbstractWorkGang::add_workers(bool initializing) {
+  add_workers(_active_workers, initializing);
+}
+
+void AbstractWorkGang::add_workers(uint active_workers, bool initializing) {
 
   os::ThreadType worker_type;
   if (are_ConcurrentGC_threads()) {
@@ -69,7 +73,7 @@
   }
 
   _created_workers = WorkerManager::add_workers(this,
-                                                _active_workers,
+                                                active_workers,
                                                 _total_workers,
                                                 _created_workers,
                                                 worker_type,
@@ -268,10 +272,11 @@
 }
 
 void WorkGang::run_task(AbstractGangTask* task, uint num_workers) {
-  guarantee(num_workers <= active_workers(),
-            "Trying to execute task %s with %u workers which is more than the amount of active workers %u.",
-            task->name(), num_workers, active_workers());
+  guarantee(num_workers <= total_workers(),
+            "Trying to execute task %s with %u workers which is more than the amount of total workers %u.",
+            task->name(), num_workers, total_workers());
   guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name());
+  add_workers(num_workers, false);
   _dispatcher->coordinator_execute_on_workers(task, num_workers);
 }
 
--- a/hotspot/src/share/vm/gc/shared/workgroup.hpp	Fri Jun 10 14:06:36 2016 +0200
+++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp	Wed May 25 09:28:20 2016 -0700
@@ -170,6 +170,9 @@
   // Add GC workers as needed.
   void add_workers(bool initializing);
 
+  // Add GC workers as needed to reach the specified number of workers.
+  void add_workers(uint active_workers, bool initializing);
+
   // Return the Ith worker.
   AbstractGangWorker* worker(uint i) const;
 
@@ -214,7 +217,8 @@
   virtual void run_task(AbstractGangTask* task);
   // Run a task with the given number of workers, returns
   // when the task is done. The number of workers must be at most the number of
-  // active workers.
+  // active workers.  Additional workers may be created if an insufficient
+  // number currently exists.
   void run_task(AbstractGangTask* task, uint num_workers);
 
 protected:
--- a/hotspot/test/gc/stress/TestGCOld.java	Fri Jun 10 14:06:36 2016 +0200
+++ b/hotspot/test/gc/stress/TestGCOld.java	Wed May 25 09:28:20 2016 -0700
@@ -32,6 +32,7 @@
  * @run main/othervm -Xmx384M -XX:+UseParallelGC -XX:-UseParallelOldGC TestGCOld 50 1 20 10 10000
  * @run main/othervm -Xmx384M -XX:+UseConcMarkSweepGC TestGCOld 50 1 20 10 10000
  * @run main/othervm -Xmx384M -XX:+UseG1GC TestGCOld 50 1 20 10 10000
+ * @run main/othervm -Xms64m -Xmx128m -XX:+UseG1GC -XX:+UseDynamicNumberOfGCThreads -Xlog:gc,gc+task=trace TestGCOld 50 5 20 1 5000
  */
 
 import java.text.*;