mirror of
https://github.com/openjdk/jdk.git
synced 2026-06-10 04:25:35 +00:00
Add SuspendedThreadTask_lock to guard SuspendedThreadTask::run
This commit is contained in:
parent
51c0737ed1
commit
a40ee18fc7
@ -32,6 +32,9 @@
|
||||
#include "jfr/utilities/jfrTryLock.hpp"
|
||||
#include "jfr/utilities/jfrTypes.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#ifdef COMPILER2
|
||||
#include "opto/c2_globals.hpp"
|
||||
#endif
|
||||
#include "runtime/atomicAccess.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "runtime/javaThread.inline.hpp"
|
||||
@ -288,7 +291,13 @@ class OSThreadSampler : public SuspendedThreadTask {
|
||||
public:
|
||||
OSThreadSampler(JavaThread* jt) : SuspendedThreadTask(jt),
|
||||
_result(THREAD_SUSPENSION_ERROR) {}
|
||||
void request_sample() { run(); }
|
||||
void request_sample() {
|
||||
ConditionalMutexLocker ml(Thread::current(), SuspendedThreadTask_lock,
|
||||
COMPILER2_PRESENT(HotCodeHeap) NOT_COMPILER2(false),
|
||||
Mutex::_no_safepoint_check_flag);
|
||||
run();
|
||||
}
|
||||
|
||||
JfrSampleResult result() const { return _result; }
|
||||
|
||||
void do_task(const SuspendedThreadTaskContext& context) {
|
||||
|
||||
@ -30,9 +30,6 @@
|
||||
#include "runtime/javaThread.inline.hpp"
|
||||
|
||||
void ThreadSampler::sample_all_java_threads() {
|
||||
// Hold Threads_lock to coordinate with other samplers (such as JFR)
|
||||
MutexLocker ml(Threads_lock);
|
||||
|
||||
// Collect samples for each JavaThread
|
||||
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
|
||||
if (jt->is_hidden_from_external_view() ||
|
||||
@ -42,7 +39,7 @@ void ThreadSampler::sample_all_java_threads() {
|
||||
}
|
||||
|
||||
GetPCTask task(jt);
|
||||
task.run();
|
||||
task.request_pc();
|
||||
address pc = task.pc();
|
||||
if (pc == nullptr) {
|
||||
continue;
|
||||
|
||||
@ -22,6 +22,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/mutex.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#ifdef COMPILER2
|
||||
#ifndef SHARE_RUNTIME_HOTCODESAMPLER_HPP
|
||||
#define SHARE_RUNTIME_HOTCODESAMPLER_HPP
|
||||
@ -75,6 +77,17 @@ class GetPCTask : public SuspendedThreadTask {
|
||||
public:
|
||||
GetPCTask(JavaThread* thread) : SuspendedThreadTask(thread), _pc(nullptr) {}
|
||||
|
||||
void request_pc() {
|
||||
#if INCLUDE_JFR
|
||||
if (SuspendedThreadTask_lock->try_lock()) {
|
||||
run();
|
||||
SuspendedThreadTask_lock->unlock();
|
||||
}
|
||||
#else
|
||||
run();
|
||||
#endif
|
||||
}
|
||||
|
||||
address pc() const {
|
||||
return _pc;
|
||||
}
|
||||
|
||||
@ -121,6 +121,7 @@ Mutex* Verify_lock = nullptr;
|
||||
Mutex* JfrStacktrace_lock = nullptr;
|
||||
Monitor* JfrMsg_lock = nullptr;
|
||||
Mutex* JfrBuffer_lock = nullptr;
|
||||
Mutex* SuspendedThreadTask_lock = nullptr;
|
||||
#endif
|
||||
|
||||
Mutex* CodeHeapStateAnalytics_lock = nullptr;
|
||||
@ -280,6 +281,7 @@ void mutex_init() {
|
||||
MUTEX_DEFN(JfrBuffer_lock , PaddedMutex , event);
|
||||
MUTEX_DEFN(JfrMsg_lock , PaddedMonitor, event);
|
||||
MUTEX_DEFN(JfrStacktrace_lock , PaddedMutex , event);
|
||||
MUTEX_DEFN(SuspendedThreadTask_lock , PaddedMutex , nosafepoint);
|
||||
#endif
|
||||
|
||||
MUTEX_DEFN(ContinuationRelativize_lock , PaddedMonitor, nosafepoint-3);
|
||||
|
||||
@ -139,6 +139,7 @@ extern Mutex* FinalImageRecipes_lock; // Protecting the tables used b
|
||||
extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table
|
||||
extern Monitor* JfrMsg_lock; // protects JFR messaging
|
||||
extern Mutex* JfrBuffer_lock; // protects JFR buffer operations
|
||||
extern Mutex* SuspendedThreadTask_lock; // used to guard SuspendedThreadTask::run
|
||||
#endif
|
||||
|
||||
extern Mutex* Metaspace_lock; // protects Metaspace virtualspace and chunk expansions
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user