mirror of
https://github.com/openjdk/jdk.git
synced 2026-06-12 13:35:06 +00:00
HCC sample_all_java_threads finishes if contention with JFR is detected
This commit is contained in:
parent
c22a639862
commit
d609551899
@ -29,6 +29,12 @@
|
||||
#include "runtime/hotCodeSampler.hpp"
|
||||
#include "runtime/javaThread.inline.hpp"
|
||||
|
||||
#if INCLUDE_JFR
|
||||
#include "jfr/utilities/jfrTryLock.hpp"
|
||||
|
||||
using SuspendedThreadTaskTryLock = JfrMutexTryLock;
|
||||
#endif
|
||||
|
||||
void ThreadSampler::sample_all_java_threads() {
|
||||
// Collect samples for each JavaThread
|
||||
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) {
|
||||
@ -39,7 +45,17 @@ void ThreadSampler::sample_all_java_threads() {
|
||||
}
|
||||
|
||||
GetPCTask task(jt);
|
||||
task.request_pc();
|
||||
{
|
||||
#if INCLUDE_JFR
|
||||
SuspendedThreadTaskTryLock try_lock(SuspendedThreadTask_lock);
|
||||
if (!try_lock.acquired()) {
|
||||
log_debug(hotcode)("Suspend lock held by JFR sampler; ending sampling pass, will retry next round");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
task.run();
|
||||
}
|
||||
|
||||
address pc = task.pc();
|
||||
if (pc == nullptr) {
|
||||
continue;
|
||||
|
||||
@ -27,8 +27,6 @@
|
||||
#define SHARE_RUNTIME_HOTCODESAMPLER_HPP
|
||||
|
||||
#include "runtime/javaThread.hpp"
|
||||
#include "runtime/mutex.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "runtime/suspendedThreadTask.hpp"
|
||||
#include "runtime/threadSMR.hpp"
|
||||
#include "utilities/pair.hpp"
|
||||
@ -77,17 +75,6 @@ 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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user