RFR: 8338417: Explicitly pin a virtual thread before acquiring the JFR string pool monitor
David Holmes
dholmes at openjdk.org
Thu Aug 15 04:14:48 UTC 2024
On Wed, 14 Aug 2024 20:53:33 GMT, Markus Grönlund <mgronlun at 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
Changes requested by dholmes (Reviewer).
src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java line 93:
> 91: private static long storeString(String s) {
> 92: try {
> 93: pinVirtualThread();
The pin should be outside the try so that the finally can only happen if pinning was succesful.
-------------
PR Review: https://git.openjdk.org/jdk/pull/20588#pullrequestreview-2239597266
PR Review Comment: https://git.openjdk.org/jdk/pull/20588#discussion_r1717852378
More information about the hotspot-jfr-dev
mailing list