RFR: 8315373: Change VirtualThread to unmount after freezing, re-mount before thawing
Alan Bateman
alanb at openjdk.org
Thu Aug 31 11:44:01 UTC 2023
On Thu, 31 Aug 2023 10:38:32 GMT, Markus Grönlund <mgronlun at openjdk.org> wrote:
>> In the virtual thread implementation, thread identity switches to the carrier before freezing and switches back to the virtual thread after thawing. This was a forced move due to issues getting JVMTI to work with virtual threads. JVMTI can now hide events during transitions so we can invert the sequence back to mounting before running the continuation, unmounting after freezing, and re-mounting after thawing. This sequence is important for future changes that will initiate the freezing from the VM.
>>
>> The change requires an update to the JFR thread sampler to skip sampling when it samples during a transition.
>>
>> Testing: tier1-5
>
> 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.
Is JfrNativeSamplerCallback
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15492#discussion_r1311502783
More information about the serviceability-dev
mailing list