From 86a59dcddcd823694097a7c4a74351484233e4a0 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 28 Jul 2025 16:42:55 +0200 Subject: [PATCH] 8364197 Hi all, please review this change to put together G1 mutex definitions/declarations and sort them. That makes it easier for me to verify changes in that area. Testing: local compilation Thanks, Thomas --- src/hotspot/share/runtime/mutexLocker.cpp | 28 +++++++++++++---------- src/hotspot/share/runtime/mutexLocker.hpp | 24 ++++++++++--------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index 179772f692701..8cfecd098f616 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -97,16 +97,18 @@ Mutex* RawMonitor_lock = nullptr; Mutex* PerfDataMemAlloc_lock = nullptr; Mutex* PerfDataManager_lock = nullptr; +#if INCLUDE_G1GC Monitor* G1CGC_lock = nullptr; +Mutex* G1DetachedRefinementStats_lock = nullptr; Mutex* G1FreeList_lock = nullptr; +Mutex* G1MarkStackChunkList_lock = nullptr; +Mutex* G1MarkStackFreeList_lock = nullptr; +Monitor* G1OldGCCount_lock = nullptr; Mutex* G1OldSets_lock = nullptr; Mutex* G1Uncommit_lock = nullptr; Monitor* G1RootRegionScan_lock = nullptr; -Monitor* G1OldGCCount_lock = nullptr; Mutex* G1RareEvent_lock = nullptr; -Mutex* G1DetachedRefinementStats_lock = nullptr; -Mutex* G1MarkStackFreeList_lock = nullptr; -Mutex* G1MarkStackChunkList_lock = nullptr; +#endif Mutex* Management_lock = nullptr; Monitor* MonitorDeflation_lock = nullptr; @@ -209,19 +211,19 @@ void mutex_init() { MUTEX_DEFN(STS_lock , PaddedMonitor, nosafepoint); +#if INCLUDE_G1GC if (UseG1GC) { MUTEX_DEFN(G1CGC_lock , PaddedMonitor, nosafepoint); - MUTEX_DEFN(G1DetachedRefinementStats_lock, PaddedMutex , nosafepoint-2); - MUTEX_DEFN(G1FreeList_lock , PaddedMutex , service-1); + MUTEX_DEFN(G1MarkStackChunkList_lock , PaddedMutex , nosafepoint); + MUTEX_DEFN(G1MarkStackFreeList_lock , PaddedMutex , nosafepoint); MUTEX_DEFN(G1OldSets_lock , PaddedMutex , nosafepoint); - MUTEX_DEFN(G1Uncommit_lock , PaddedMutex , service-2); MUTEX_DEFN(G1RootRegionScan_lock , PaddedMonitor, nosafepoint-1); - - MUTEX_DEFN(G1MarkStackFreeList_lock , PaddedMutex , nosafepoint); - MUTEX_DEFN(G1MarkStackChunkList_lock , PaddedMutex , nosafepoint); + MUTEX_DEFN(G1Uncommit_lock , PaddedMutex , service-2); } +#endif + MUTEX_DEFN(MonitoringSupport_lock , PaddedMutex , service-1); // used for serviceability monitoring support MUTEX_DEFN(StringDedup_lock , PaddedMonitor, nosafepoint); @@ -340,10 +342,12 @@ void mutex_init() { MUTEX_DEFL(VMOperation_lock , PaddedMonitor, Heap_lock, true); MUTEX_DEFL(ClassInitError_lock , PaddedMonitor, Threads_lock); +#if INCLUDE_G1GC if (UseG1GC) { - MUTEX_DEFL(G1OldGCCount_lock , PaddedMonitor, Threads_lock, true); - MUTEX_DEFL(G1RareEvent_lock , PaddedMutex , Threads_lock, true); + MUTEX_DEFL(G1OldGCCount_lock , PaddedMonitor, Threads_lock, true); + MUTEX_DEFL(G1RareEvent_lock , PaddedMutex , Threads_lock, true); } +#endif MUTEX_DEFL(CompileTaskWait_lock , PaddedMonitor, MethodCompileQueue_lock); diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 01fa8e8f60f5c..f888c789eb738 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -70,13 +70,7 @@ extern Monitor* Threads_lock; // a lock on the Threads table // (also used by Safepoints too to block threads creation/destruction) extern Mutex* NonJavaThreadsList_lock; // a lock on the NonJavaThreads list extern Mutex* NonJavaThreadsListSync_lock; // a lock for NonJavaThreads list synchronization -extern Monitor* G1CGC_lock; // used for coordination between fore- & background G1 concurrent GC threads. extern Monitor* STS_lock; // used for joining/leaving SuspendibleThreadSet. -extern Monitor* G1OldGCCount_lock; // in support of "concurrent" full gc -extern Mutex* G1RareEvent_lock; // Synchronizes (rare) parallel GC operations. -extern Mutex* G1DetachedRefinementStats_lock; // Lock protecting detached refinement stats for G1. -extern Mutex* G1MarkStackFreeList_lock; // Protects access to the G1 global mark stack free list. -extern Mutex* G1MarkStackChunkList_lock; // Protects access to the G1 global mark stack chunk list. extern Mutex* MonitoringSupport_lock; // Protects updates to the serviceability memory pools and allocated memory high water mark. extern Monitor* ConcurrentGCBreakpoints_lock; // Protects concurrent GC breakpoint management extern Mutex* Compile_lock; // a lock held when Compilation is updating code (used to block CodeCache traversal, CHA updates, etc) @@ -98,14 +92,22 @@ extern Mutex* ExceptionCache_lock; // a lock used to synchronize e extern Mutex* FullGCALot_lock; // a lock to make FullGCALot MT safe #endif // PRODUCT -extern Mutex* RawMonitor_lock; -extern Mutex* PerfDataMemAlloc_lock; // a lock on the allocator for PerfData memory for performance data -extern Mutex* PerfDataManager_lock; // a long on access to PerfDataManager resources - +#if INCLUDE_G1GC +extern Monitor* G1CGC_lock; // used for coordination between fore- & background G1 concurrent GC threads. +extern Mutex* G1DetachedRefinementStats_lock; // Lock protecting detached refinement stats for G1. extern Mutex* G1FreeList_lock; // protects the G1 free region list during safepoints +extern Mutex* G1MarkStackChunkList_lock; // Protects access to the G1 global mark stack chunk list. +extern Mutex* G1MarkStackFreeList_lock; // Protects access to the G1 global mark stack free list. +extern Monitor* G1OldGCCount_lock; // in support of "concurrent" full gc extern Mutex* G1OldSets_lock; // protects the G1 old region sets -extern Mutex* G1Uncommit_lock; // protects the G1 uncommit list when not at safepoints +extern Mutex* G1RareEvent_lock; // Synchronizes (rare) parallel GC operations. extern Monitor* G1RootRegionScan_lock; // used to notify that the G1 CM threads have finished scanning the root regions +extern Mutex* G1Uncommit_lock; // protects the G1 uncommit list when not at safepoints +#endif + +extern Mutex* RawMonitor_lock; +extern Mutex* PerfDataMemAlloc_lock; // a lock on the allocator for PerfData memory for performance data +extern Mutex* PerfDataManager_lock; // a long on access to PerfDataManager resources extern Mutex* Management_lock; // a lock used to serialize JVM management extern Monitor* MonitorDeflation_lock; // a lock used for monitor deflation thread operation