On Thu, 31 Aug 2023 11:41:03 GMT, Alan Bateman <al...@openjdk.org> wrote:

>> src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp line 410:
>> 
>>> 408:   }
>>> 409:   if (JAVA_SAMPLE == type) {
>>> 410:     if (thread_state_in_java(thread) && 
>>> !is_vthread_in_transition(thread)) {
>> 
>> I think this check can be postponed until after the thread is suspended.
>
> Is the check in OSThreadSampler::protected_task in the right place? That 
> seems to be a suspended context.
> 
> For JfrThreadSampleClosure::do_sample_thread, I think I may have mis-read the 
> code. I thought it was suspended but looking at it again them maybe it should 
> be the JfrNativeSamplerCallback implementation. This is probably an area 
> where I need help to get right.

OSThreadSampler::protected_task() is the correct place to perform the test. The 
sampled thread is completely suspended at this location. The other locations 
are optimistic, they read the thread state while the sampled thread is running 
to avoid signalling a thread unnecessarily. You don't need the 
is_vthread_in_transtition() check there, especially not for the 
thread_in_native case, since that would not be possible, would it?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15492#discussion_r1311632129

Reply via email to