Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void ShenandoahRegulatorThread::run_service() {

void ShenandoahRegulatorThread::regulate_young_and_old_cycles() {
while (!should_terminate()) {
SuspendibleThreadSetJoiner joiner;
ShenandoahGenerationalControlThread::GCMode mode = _control_thread->gc_mode();
if (mode == ShenandoahGenerationalControlThread::none) {
if (should_start_metaspace_gc()) {
Expand Down Expand Up @@ -95,6 +96,7 @@ void ShenandoahRegulatorThread::regulate_young_and_old_cycles() {

void ShenandoahRegulatorThread::regulate_young_and_global_cycles() {
while (!should_terminate()) {
SuspendibleThreadSetJoiner joiner;
if (_control_thread->gc_mode() == ShenandoahGenerationalControlThread::none) {
if (start_global_cycle()) {
log_debug(gc)("Heuristics request for global collection accepted.");
Expand Down Expand Up @@ -122,6 +124,7 @@ void ShenandoahRegulatorThread::regulator_sleep() {
_last_sleep_adjust_time = current;
}

SuspendibleThreadSetLeaver leaver;
os::naked_short_sleep(_sleep);
if (LogTarget(Debug, gc, thread)::is_enabled()) {
double elapsed = os::elapsedTime() - current;
Expand All @@ -146,6 +149,13 @@ bool ShenandoahRegulatorThread::start_global_cycle() const {

bool ShenandoahRegulatorThread::request_concurrent_gc(ShenandoahGeneration* generation) const {
double now = os::elapsedTime();

// This call may find the control thread waiting on workers which have suspended
// to allow a safepoint to run. If this regulator thread does not yield, the safepoint
// will not run. The worker threads won't progress, the control thread won't progress,
// and the regulator thread may never yield. Therefore, we leave the suspendible
// thread set before making this call.
SuspendibleThreadSetLeaver leaver;
bool accepted = _control_thread->request_concurrent_gc(generation);
if (LogTarget(Debug, gc, thread)::is_enabled() && accepted) {
double wait_time = os::elapsedTime() - now;
Expand Down