Skip to content

Commit c1e39fa

Browse files
committedSep 10, 2021
8273482: Remove "foreground work" concept from WorkGang
Reviewed-by: tschatzl, kbarrett
1 parent 2eaf374 commit c1e39fa

File tree

6 files changed

+8
-25
lines changed

6 files changed

+8
-25
lines changed
 

‎src/hotspot/share/gc/shared/workgroup.cpp

+3-16
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@
3434
#include "runtime/semaphore.hpp"
3535
#include "runtime/thread.inline.hpp"
3636

37-
static void run_foreground_task_if_needed(AbstractGangTask* task, uint num_workers,
38-
bool add_foreground_work) {
39-
if (add_foreground_work) {
40-
log_develop_trace(gc, workgang)("Running work gang: %s task: %s worker: foreground",
41-
Thread::current()->name(), task->name());
42-
task->work(num_workers);
43-
log_develop_trace(gc, workgang)("Finished work gang: %s task: %s worker: foreground "
44-
"thread: " PTR_FORMAT, Thread::current()->name(), task->name(), p2i(Thread::current()));
45-
}
46-
}
47-
4837
// WorkGang dispatcher implemented with semaphores.
4938
//
5039
// Semaphores don't require the worker threads to re-claim the lock when they wake up.
@@ -79,16 +68,14 @@ class GangTaskDispatcher : public CHeapObj<mtGC> {
7968

8069
// Distributes the task out to num_workers workers.
8170
// Returns when the task has been completed by all workers.
82-
void coordinator_execute_on_workers(AbstractGangTask* task, uint num_workers, bool add_foreground_work) {
71+
void coordinator_execute_on_workers(AbstractGangTask* task, uint num_workers) {
8372
// No workers are allowed to read the state variables until they have been signaled.
8473
_task = task;
8574
_not_finished = num_workers;
8675

8776
// Dispatch 'num_workers' number of tasks.
8877
_start_semaphore->signal(num_workers);
8978

90-
run_foreground_task_if_needed(task, num_workers, add_foreground_work);
91-
9279
// Wait for the last worker to signal the coordinator.
9380
_end_semaphore->wait();
9481

@@ -198,14 +185,14 @@ void WorkGang::run_task(AbstractGangTask* task) {
198185
run_task(task, active_workers());
199186
}
200187

201-
void WorkGang::run_task(AbstractGangTask* task, uint num_workers, bool add_foreground_work) {
188+
void WorkGang::run_task(AbstractGangTask* task, uint num_workers) {
202189
guarantee(num_workers <= total_workers(),
203190
"Trying to execute task %s with %u workers which is more than the amount of total workers %u.",
204191
task->name(), num_workers, total_workers());
205192
guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name());
206193
uint old_num_workers = _active_workers;
207194
update_active_workers(num_workers);
208-
_dispatcher->coordinator_execute_on_workers(task, num_workers, add_foreground_work);
195+
_dispatcher->coordinator_execute_on_workers(task, num_workers);
209196
update_active_workers(old_num_workers);
210197
}
211198

‎src/hotspot/share/gc/shared/workgroup.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,8 @@ class WorkGang : public CHeapObj<mtInternal> {
167167
// Run a task with the given number of workers, returns
168168
// when the task is done. The number of workers must be at most the number of
169169
// active workers. Additional workers may be created if an insufficient
170-
// number currently exists. If the add_foreground_work flag is true, the current thread
171-
// is used to run the task too.
172-
void run_task(AbstractGangTask* task, uint num_workers, bool add_foreground_work = false);
170+
// number currently exists.
171+
void run_task(AbstractGangTask* task, uint num_workers);
173172
};
174173

175174
// Temporarily try to set the number of active workers.

‎src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ ShenandoahCodeRootsIterator::ShenandoahCodeRootsIterator() :
355355
_par_iterator(CodeCache::heaps()),
356356
_table_snapshot(NULL) {
357357
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");
358-
assert(!Thread::current()->is_Worker_thread(), "Should not be acquired by workers");
359358
CodeCache_lock->lock_without_safepoint_check();
360359
_table_snapshot = ShenandoahCodeRoots::table()->snapshot_for_iteration();
361360
}

‎src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ ShenandoahHeapIterationRootScanner::ShenandoahHeapIterationRootScanner() :
258258
}
259259

260260
void ShenandoahHeapIterationRootScanner::roots_do(OopClosure* oops) {
261-
assert(Thread::current()->is_VM_thread(), "Only by VM thread");
262261
// Must use _claim_none to avoid interfering with concurrent CLDG iteration
263262
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
264263
MarkingCodeBlobClosure code(oops, !CodeBlobToOopClosure::FixRelocations);

‎src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::ShenandoahClassLoad
8686
ClassLoaderDataGraph_lock->lock();
8787
}
8888

89-
// Non-concurrent mode only runs at safepoints by VM thread
89+
// Non-concurrent mode only runs at safepoints
9090
assert(CONCURRENT || SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
91-
assert(CONCURRENT || Thread::current()->is_VM_thread(), "Can only be done by VM thread");
9291
}
9392

9493
template <bool CONCURRENT, bool SINGLE_THREADED>

‎src/hotspot/share/services/heapDumper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ void VM_HeapDumper::doit() {
17711771
if (gang == NULL) {
17721772
work(0);
17731773
} else {
1774-
gang->run_task(this, gang->active_workers(), true);
1774+
gang->run_task(this);
17751775
}
17761776

17771777
// Now we clear the global variables, so that a future dumper can run.
@@ -1780,7 +1780,7 @@ void VM_HeapDumper::doit() {
17801780
}
17811781

17821782
void VM_HeapDumper::work(uint worker_id) {
1783-
if (!Thread::current()->is_VM_thread()) {
1783+
if (worker_id != 0) {
17841784
writer()->writer_loop();
17851785
return;
17861786
}

0 commit comments

Comments
 (0)
Please sign in to comment.