8358621: Reduce busy waiting in worse case at the synchronization point returning from native in CPU Time Profiler

Reviewed-by: shade
Backport-of: d2082c58ff086eb37c6211a8d1b813cdfedc2259
This commit is contained in:
Johannes Bechberger 2025-07-16 07:31:23 +00:00
parent 07bb0e3e2f
commit 533211af73

View File

@ -45,6 +45,7 @@
#include "runtime/os.hpp"
#include "runtime/threadIdentifier.hpp"
#include "utilities/sizes.hpp"
#include "utilities/spinYield.hpp"
JfrThreadLocal::JfrThreadLocal() :
_sample_request(),
@ -600,7 +601,10 @@ bool JfrThreadLocal::try_acquire_cpu_time_jfr_dequeue_lock() {
}
void JfrThreadLocal::acquire_cpu_time_jfr_dequeue_lock() {
while (Atomic::cmpxchg(&_cpu_time_jfr_locked, UNLOCKED, DEQUEUE) != UNLOCKED);
SpinYield s;
while (Atomic::cmpxchg(&_cpu_time_jfr_locked, UNLOCKED, DEQUEUE) != UNLOCKED) {
s.wait();
}
}
void JfrThreadLocal::release_cpu_time_jfr_queue_lock() {