From 1d8e7a2a1429330ea3d03ad4b216bcfb9d6629b7 Mon Sep 17 00:00:00 2001 From: William Kemper Date: Thu, 15 Jan 2026 16:33:59 -0800 Subject: [PATCH] Go even lower, don't check for safepoint when taking the locks --- src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp | 6 +++--- src/hotspot/share/gc/shenandoah/shenandoahController.cpp | 4 ++-- src/hotspot/share/gc/shenandoah/shenandoahController.hpp | 4 ++-- .../gc/shenandoah/shenandoahGenerationalControlThread.cpp | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp index 72258a575c9..737bb82a3e2 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp @@ -44,7 +44,7 @@ ShenandoahControlThread::ShenandoahControlThread() : ShenandoahController(), _requested_gc_cause(GCCause::_no_gc), _degen_point(ShenandoahGC::_degenerated_outside_cycle), - _control_lock(LOCK_RANK, "ShenandoahGCRequest_lock", true) { + _control_lock(LOCK_RANK - 1, "ShenandoahControl_lock", true) { set_name("Shenandoah Control Thread"); create_and_start(); } @@ -380,7 +380,7 @@ void ShenandoahControlThread::handle_requested_gc(GCCause::Cause cause) { // opportunities for cleanup that were made available before the caller // requested the GC. - MonitorLocker ml(&_gc_waiters_lock); + MonitorLocker ml(&_gc_waiters_lock, Mutex::_no_safepoint_check_flag); size_t current_gc_id = get_gc_id(); size_t required_gc_id = current_gc_id + 1; while (current_gc_id < required_gc_id && !should_terminate()) { @@ -392,6 +392,6 @@ void ShenandoahControlThread::handle_requested_gc(GCCause::Cause cause) { void ShenandoahControlThread::notify_gc_waiters() { _gc_requested.unset(); - MonitorLocker ml(&_gc_waiters_lock); + MonitorLocker ml(&_gc_waiters_lock, Mutex::_no_safepoint_check_flag); ml.notify_all(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahController.cpp b/src/hotspot/share/gc/shenandoah/shenandoahController.cpp index 220f3df8d4f..fa4c30e9a41 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahController.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahController.cpp @@ -51,7 +51,7 @@ void ShenandoahController::handle_alloc_failure(const ShenandoahAllocRequest& re } if (block) { - MonitorLocker ml(&_alloc_failure_waiters_lock); + MonitorLocker ml(&_alloc_failure_waiters_lock, Mutex::_no_safepoint_check_flag); while (!should_terminate() && ShenandoahCollectorPolicy::is_allocation_failure(heap->cancelled_cause())) { ml.wait(); } @@ -70,6 +70,6 @@ void ShenandoahController::handle_alloc_failure_evac(size_t words) { } void ShenandoahController::notify_alloc_failure_waiters() { - MonitorLocker ml(&_alloc_failure_waiters_lock); + MonitorLocker ml(&_alloc_failure_waiters_lock, Mutex::_no_safepoint_check_flag); ml.notify_all(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahController.hpp b/src/hotspot/share/gc/shenandoah/shenandoahController.hpp index deca9644174..bbd83dad13d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahController.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahController.hpp @@ -56,8 +56,8 @@ protected: public: ShenandoahController(): _gc_id(0), - _alloc_failure_waiters_lock(LOCK_RANK, "ShenandoahAllocFailureGC_lock", true), - _gc_waiters_lock(LOCK_RANK, "ShenandoahRequestedGC_lock", true) + _alloc_failure_waiters_lock(LOCK_RANK, "ShenandoahAllocFailureWaiters_lock", true), + _gc_waiters_lock(LOCK_RANK, "ShenandoahGCWaiters_lock", true) { } // Request a collection cycle. This handles "explicit" gc requests diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp index 0cdcda29fe6..d7c0de42cb3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp @@ -47,7 +47,7 @@ #include "utilities/events.hpp" ShenandoahGenerationalControlThread::ShenandoahGenerationalControlThread() : - _control_lock(LOCK_RANK, "ShenandoahGCRequest_lock", true), + _control_lock(LOCK_RANK - 1, "ShenandoahControl_lock", true), _requested_gc_cause(GCCause::_no_gc), _requested_generation(nullptr), _gc_mode(none), @@ -759,7 +759,7 @@ void ShenandoahGenerationalControlThread::handle_requested_gc(GCCause::Cause cau // opportunities for cleanup that were made available before the caller // requested the GC. - MonitorLocker ml(&_gc_waiters_lock); + MonitorLocker ml(&_gc_waiters_lock, Mutex::_no_safepoint_check_flag); size_t current_gc_id = get_gc_id(); const size_t required_gc_id = current_gc_id + 1; while (current_gc_id < required_gc_id && !should_terminate()) { @@ -771,7 +771,7 @@ void ShenandoahGenerationalControlThread::handle_requested_gc(GCCause::Cause cau } void ShenandoahGenerationalControlThread::notify_gc_waiters() { - MonitorLocker ml(&_gc_waiters_lock); + MonitorLocker ml(&_gc_waiters_lock, Mutex::_no_safepoint_check_flag); ml.notify_all(); }