Integrated: 8312174: missing JVMTI events from vthreads parked during JVMTI attach

Serguei Spitsyn sspitsyn at openjdk.org
Tue Sep 12 02:49:49 UTC 2023


On Tue, 29 Aug 2023 10:09:21 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:

> This update fixes two important issues:
>  - Issue reported by a bug submitter about missing JVMTI events on virtual threads after an a JVMTI agent dynamic attach
>  -  Known scalability/performance issue: a need to lazily create `JvmtiThreadState's` for virtual threads
> 
> The issue is tricky to fix because the existing mechanism of the JVMTI event management does not support unmounted virtual threads. The JVMTI `SetEventNotificationMode()` calls the function `JvmtiEventControllerPrivate::recompute_enabled()`
> which inspects a `JavaThread's` list and for each thread in the list recomputes enabled event bits with the function `JvmtiEventControllerPrivate::recompute_thread_enabled()`.  The `JvmtiThreadState` of each thread is created but only when it is really needed, eg, if any of the thread filtered events is enabled. There was an initial adjustment of this mechanism for virtual threads which accounted for both carrier and virtual threads when a virtual thread is mounted. However, it does not work for unmounted virtual threads. A temporary work around was to always create `JvmtiThreadState` for each virtual thread eagerly at a thread starting point.
> 
> This fix introduces new function `JvmtiExport::get_jvmti_thread_state()` which checks if thread is virtual and there is a thread filtered event enabled globally, and if so, forces a creation of the `JvmtiThreadState`. Another adjustment was needed because the function `state_for_while_locked()` can be called directly in some contexts. New function `JvmtiEventController::recompute_thread_filtered()` was introduced to make necessary corrections.
> 
> Testing:
>  - new test from the bug report was adopted: `test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadEventTest`
>  - ran mach5 tiers 1-6: all are passed

This pull request has now been integrated.

Changeset: fda142ff
Author:    Serguei Spitsyn <sspitsyn at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/fda142ff6cfefa12ec1ea4d4eb48b3c1b285bc04
Stats:     424 lines in 9 files changed: 376 ins; 20 del; 28 mod

8312174: missing JVMTI events from vthreads parked during JVMTI attach

Reviewed-by: lmesnik, amenkov

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

PR: https://git.openjdk.org/jdk/pull/15467


More information about the serviceability-dev mailing list