From 30be94086aad42b99a15a05fe5115f552e8efb8b Mon Sep 17 00:00:00 2001 From: Jonas Norlinder Date: Tue, 16 Dec 2025 21:33:27 +0000 Subject: [PATCH] 8373625: CPUTimeCounters creates a total counter for unsupported GCs Reviewed-by: sjohanss, tschatzl --- src/hotspot/share/runtime/cpuTimeCounters.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/cpuTimeCounters.hpp b/src/hotspot/share/runtime/cpuTimeCounters.hpp index 9ad00492731..c2e636bdb1d 100644 --- a/src/hotspot/share/runtime/cpuTimeCounters.hpp +++ b/src/hotspot/share/runtime/cpuTimeCounters.hpp @@ -28,6 +28,7 @@ #define SHARE_RUNTIME_CPUTIMECOUNTERS_HPP +#include "gc/shared/gc_globals.hpp" #include "memory/iterator.hpp" #include "runtime/os.hpp" #include "runtime/perfData.hpp" @@ -83,7 +84,9 @@ public: assert(_instance == nullptr, "we can only allocate one CPUTimeCounters object"); if (UsePerfData && os::is_thread_cpu_time_supported()) { _instance = new CPUTimeCounters(); - create_counter(SUN_THREADS, CPUTimeGroups::CPUTimeType::gc_total); + if (UseG1GC || UseParallelGC) { + create_counter(SUN_THREADS, CPUTimeGroups::CPUTimeType::gc_total); + } } }