On Thu, 15 Aug 2024 11:20:23 GMT, Markus Grönlund <mgron...@openjdk.org> wrote:
>> Greetings, >> >> Explicitly pin a virtual thread before acquiring the JFR string pool monitor >> because migrating a carrier thread local event writer object onto another >> carrier thread is impossible. >> >> During event commit, the thread is in a critical section because it has >> loaded a carrier thread local event writer object. For virtual threads, a >> contended monitor, such as a synchronized block, is a point where a thread >> could become unmounted. >> >> A monitor guards the JFR string pool, but remounting a virtual thread onto >> another carrier is impossible because of the event writer. >> >> Therefore, it's imperative to use explicit pin constructs to prevent >> unmounting at this location. >> >> Testing: jdk_jfr >> >> Thanks >> Markus > > Markus Grönlund has updated the pull request incrementally with one > additional commit since the last revision: > > update test comment Functionally seems fine. Could be optimised a bit. src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java line 86: > 84: > 85: private static void unpinVirtualThread() { > 86: if (Thread.currentThread().isVirtual() && > ContinuationSupport.isSupported()) { If you are at all concerned about overhead here then pin could return a boolean to indicate if the pin happened and oyu could then unpin just by checking that boolean and avoid doing the isVirtual and isSupported checks again. ------------- Marked as reviewed by dholmes (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/20588#pullrequestreview-2240268782 PR Review Comment: https://git.openjdk.org/jdk/pull/20588#discussion_r1718332618