--- old/src/share/vm/gc/shared/workerManager.hpp 2016-07-20 13:16:02.072290534 -0700 +++ new/src/share/vm/gc/shared/workerManager.hpp 2016-07-20 13:16:01.960290538 -0700 @@ -47,11 +47,11 @@ // threads and a failure would not be optimal but should not be fatal. template static uint add_workers (WorkerType* holder, - uint active_workers, - uint total_workers, - uint created_workers, - os::ThreadType worker_type, - bool initializing) { + uint active_workers, + uint total_workers, + uint created_workers, + os::ThreadType worker_type, + bool initializing) { uint start = created_workers; uint end = MIN2(active_workers, total_workers); for (uint worker_id = start; worker_id < end; worker_id += 1) { @@ -61,8 +61,8 @@ } if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) { log_trace(gc, task)("WorkerManager::add_workers() : " - "creation failed due to failed allocation of native %s", - new_worker == NULL ? "memory" : "thread"); + "creation failed due to failed allocation of native %s", + new_worker == NULL ? "memory" : "thread"); if (new_worker != NULL) { delete new_worker; } @@ -76,7 +76,7 @@ } log_trace(gc, task)("WorkerManager::add_workers() : " - "created_workers: %u", created_workers); + "created_workers: %u", created_workers); return created_workers; } --- old/src/share/vm/gc/shared/workgroup.cpp 2016-07-20 13:16:02.708290512 -0700 +++ new/src/share/vm/gc/shared/workgroup.cpp 2016-07-20 13:16:02.580290516 -0700 @@ -271,11 +271,13 @@ "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()); - // num_workers may have been calculated based on different criteria - // than _active_workers so use num_workers limited by the number of - // created workers. - uint active_workers = MIN2(_created_workers, num_workers); - _dispatcher->coordinator_execute_on_workers(task, active_workers); + uint old_num_workers = _active_workers; + log_debug(gc)("run_task: updating active workers for %s from %u to %u", task->name(), old_num_workers, num_workers); + update_active_workers(num_workers); + guarantee(_active_workers == num_workers, "active workers %u num_workers %u", _active_workers, num_workers); + _dispatcher->coordinator_execute_on_workers(task, num_workers); + log_debug(gc)("run_task: restoring active workers from %u to %u", num_workers, old_num_workers); + update_active_workers(old_num_workers); } AbstractGangWorker::AbstractGangWorker(AbstractWorkGang* gang, uint id) { --- old/src/share/vm/gc/shared/workgroup.hpp 2016-07-20 13:16:03.176290495 -0700 +++ new/src/share/vm/gc/shared/workgroup.hpp 2016-07-20 13:16:03.068290499 -0700 @@ -162,8 +162,6 @@ _active_workers = MIN2(v, _total_workers); add_workers(false /* exit_on_failure */); assert(v != 0, "Trying to set active workers to 0"); - assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers, - "Unless dynamic should use total workers"); log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers); return _active_workers; }