On Tue, 19 Dec 2023 04:09:47 GMT, Alex Menkov <amen...@openjdk.org> wrote:

>> src/hotspot/share/services/heapDumper.cpp line 1647:
>> 
>>> 1645:   static bool is_vthread_mounted(oop vt) {
>>> 1646:     return JvmtiEnvBase::get_JavaThread_or_null(vt) != nullptr;
>>> 1647:   }
>> 
>> It doesn't seem appropriate to couple this to the JVMTI code (can this code 
>> be present if JVMTI is not part of the build?). Doesn't the VT state give 
>> you a good enough approximation of whether it is mounted i.e. RUNNABLE?
>
> Good point. I'll remove dependency on JVMTI.
> I don't think approximation would be good here (comparing state to 
> RUNNABLE/PINNED/TIMED_PINNED or comparing carrierThread with null).
> It's racy and we have a chance to not dump unmounted vthread or dump mounted 
> vthread twice.
> Maybe `is_vthread_mounted` should check if the virtual thread continuation 
> has non-empty chunk.

If that is racy then any solution is going to be racy. I assumed this was all 
happening at a global safepoint, otherwise threads could be mounting/unmounting 
at any time.

I said "approximation" only because I'm unsure exactly when the thread state 
gets updated in the mounting/unmounting process.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17134#discussion_r1430924428

Reply via email to