From 533211af73d2df79fb041055a7a5de1b92bf5e3d Mon Sep 17 00:00:00 2001 From: Johannes Bechberger Date: Wed, 16 Jul 2025 07:31:23 +0000 Subject: [PATCH] 8358621: Reduce busy waiting in worse case at the synchronization point returning from native in CPU Time Profiler Reviewed-by: shade Backport-of: d2082c58ff086eb37c6211a8d1b813cdfedc2259 --- src/hotspot/share/jfr/support/jfrThreadLocal.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/jfr/support/jfrThreadLocal.cpp b/src/hotspot/share/jfr/support/jfrThreadLocal.cpp index 67d311e2a6e..e38e0427a05 100644 --- a/src/hotspot/share/jfr/support/jfrThreadLocal.cpp +++ b/src/hotspot/share/jfr/support/jfrThreadLocal.cpp @@ -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() {