RFR: 8369019: Improve timed-park mechanism in ObjectMonitor for virtual thread support [v4]

David Holmes dholmes at openjdk.org
Tue Oct 7 04:13:49 UTC 2025


On Fri, 3 Oct 2025 15:25:41 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:

>> src/hotspot/share/runtime/objectMonitor.cpp line 997:
>> 
>>> 995:   // prevents this load from floating up previous store.
>>> 996:   // Note that we can have false positives where timed-park is not necessary.
>>> 997:   bool do_timed_parked = has_unmounted_vthreads();
>> 
>> Don't we still only need the timed-park if the current thread is a pinned vthread?
>
> Yes, except if the monitor is also used in the context of a carrier thread. Currently there are only very few such cases and we disable preemption for them (e.g. `interruptLock`), so it’s likely not needed. With the upcoming changes to preempt on klass initialization, we could also have this situation if a class can be initialized both in the context of a carrier and a vthread. Since code executed in the context of the carriers is limited to library code there will also be very few cases of this, but I’ve seen at least one such case with `LockSupport`.

So you are saying the current code is insufficient and could still deadlock?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27597#discussion_r2409280439


More information about the core-libs-dev mailing list