From dfb5773845ba552483314574822cc08f0764e8a1 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Tue, 24 Jun 2025 14:09:41 -0700 Subject: [PATCH 1/4] Make JfrRecorderThread known to SA --- .../share/jfr/recorder/service/jfrRecorderThread.cpp | 8 -------- .../share/jfr/recorder/service/jfrRecorderThread.hpp | 10 +++++++++- src/hotspot/share/runtime/vmStructs.cpp | 2 ++ .../share/classes/sun/jvm/hotspot/runtime/Threads.java | 4 +++- .../sa/ClhsdbJstackWithConcurrentLock.java | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp b/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp index 71b7014e6ec13..aa594ea6d1ffe 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp +++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp @@ -36,14 +36,6 @@ #include "utilities/preserveException.hpp" #include "utilities/macros.hpp" -class JfrRecorderThread : public JavaThread { - public: - JfrRecorderThread(ThreadFunction entry_point) : JavaThread(entry_point) {} - virtual ~JfrRecorderThread() {} - - virtual bool is_JfrRecorder_thread() const { return true; } -}; - static Thread* start_thread(instanceHandle thread_oop, ThreadFunction proc, TRAPS) { assert(thread_oop.not_null(), "invariant"); assert(proc != nullptr, "invariant"); diff --git a/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.hpp b/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.hpp index df8b1f55a4e9f..34993e4e6cfee 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.hpp +++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.hpp @@ -26,9 +26,9 @@ #define SHARE_JFR_RECORDER_SERVICE_JFRRECORDERTHREAD_HPP #include "memory/allStatic.hpp" +#include "runtime/javaThread.hpp" #include "utilities/debug.hpp" -class JavaThread; class JfrCheckpointManager; class JfrPostBox; class Thread; @@ -42,4 +42,12 @@ class JfrRecorderThreadEntry : AllStatic { static bool start(JfrCheckpointManager* cp_manager, JfrPostBox* post_box, TRAPS); }; +class JfrRecorderThread : public JavaThread { + public: + JfrRecorderThread(ThreadFunction entry_point) : JavaThread(entry_point) {} + virtual ~JfrRecorderThread() {} + + virtual bool is_JfrRecorder_thread() const { return true; } +}; + #endif // SHARE_JFR_RECORDER_SERVICE_JFRRECORDERTHREAD_HPP diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index e248e0f05be12..4e56c090d3c02 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -40,6 +40,7 @@ #include "code/vmreg.hpp" #include "compiler/compileBroker.hpp" #include "compiler/oopMap.hpp" +#include "jfr/recorder/service/jfrRecorderThread.hpp" #include "gc/shared/stringdedup/stringDedupThread.hpp" #include "gc/shared/vmStructs_gc.hpp" #include "interpreter/bytecodes.hpp" @@ -1027,6 +1028,7 @@ declare_type(TrainingReplayThread, JavaThread) \ declare_type(StringDedupThread, JavaThread) \ declare_type(AttachListenerThread, JavaThread) \ + declare_type(JfrRecorderThread, JavaThread) \ DEBUG_ONLY(COMPILER2_OR_JVMCI_PRESENT( \ declare_type(DeoptimizeObjectsALotThread, JavaThread))) \ declare_toplevel_type(OSThread) \ diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index dfc49d1a81fdf..1c4462271e157 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -158,6 +158,7 @@ private static synchronized void initialize(TypeDataBase db) { virtualConstructor.addMapping("JvmtiAgentThread", JavaThread.class); virtualConstructor.addMapping("NotificationThread", JavaThread.class); virtualConstructor.addMapping("AttachListenerThread", JavaThread.class); + virtualConstructor.addMapping("JfrRecorderThread", JavaThread.class); // These are all the hidden JavaThread subclasses that don't execute java code. virtualConstructor.addMapping("StringDedupThread", HiddenJavaThread.class); @@ -195,7 +196,8 @@ public JavaThread createJavaThreadWrapper(Address threadAddr) { } catch (Exception e) { throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr + " (expected type JavaThread, CompilerThread, MonitorDeflationThread, AttachListenerThread," + - " DeoptimizeObjectsALotThread, StringDedupThread, NotificationThread, ServiceThread or JvmtiAgentThread)", e); + " DeoptimizeObjectsALotThread, StringDedupThread, NotificationThread, ServiceThread," + + "JfrRecorderThread, or JvmtiAgentThread)", e); } } diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java index 43926941a1a67..02d11422c74e0 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception { theApp = new LingeredAppWithConcurrentLock(); // Use a small heap so the scan is quick. - LingeredApp.startApp(theApp, "-Xmx4m"); + LingeredApp.startApp(theApp, "-Xmx8m"); System.out.println("Started LingeredApp with pid " + theApp.getPid()); // Run the 'jstack -l' command to get the stack and have java.util.concurrent From a679b2368dd38f1e95f37e80a62df306444d6c9c Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Tue, 24 Jun 2025 17:18:29 -0700 Subject: [PATCH 2/4] revisit my ABC's --- src/hotspot/share/runtime/vmStructs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 4e56c090d3c02..71cba9ec08533 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -40,11 +40,11 @@ #include "code/vmreg.hpp" #include "compiler/compileBroker.hpp" #include "compiler/oopMap.hpp" -#include "jfr/recorder/service/jfrRecorderThread.hpp" #include "gc/shared/stringdedup/stringDedupThread.hpp" #include "gc/shared/vmStructs_gc.hpp" #include "interpreter/bytecodes.hpp" #include "interpreter/interpreter.hpp" +#include "jfr/recorder/service/jfrRecorderThread.hpp" #include "logging/logAsyncWriter.hpp" #include "memory/allocation.hpp" #include "memory/allocation.inline.hpp" From 28a97a119aaa3d96e07269c5aaa62e27d4ae01d9 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Tue, 24 Jun 2025 23:28:17 -0700 Subject: [PATCH 3/4] fix copyright --- .../jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java index 02d11422c74e0..64080b252c5ba 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it From 8de192766f7d2e64fb13cf6085140be3df76f01d Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Wed, 25 Jun 2025 10:27:52 -0700 Subject: [PATCH 4/4] add missing space --- .../share/classes/sun/jvm/hotspot/runtime/Threads.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index 1c4462271e157..c913c6645f669 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -197,7 +197,7 @@ public JavaThread createJavaThreadWrapper(Address threadAddr) { throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr + " (expected type JavaThread, CompilerThread, MonitorDeflationThread, AttachListenerThread," + " DeoptimizeObjectsALotThread, StringDedupThread, NotificationThread, ServiceThread," + - "JfrRecorderThread, or JvmtiAgentThread)", e); + " JfrRecorderThread, or JvmtiAgentThread)", e); } }