[jdk21u-dev] RFR: 8315373: Change VirtualThread to unmount after freezing, re-mount before thawing

Aleksey Shipilev shade at openjdk.org
Thu Feb 15 12:40:31 UTC 2024


This is a series of Loom backports that brings in the fixes from JDK 22 and mainline into JDK 21, where Loom is production-ready. This batch fixes a few thread state and JVMTI problems.

Unfortunately, these backports are tied together, as they change the same code a few times. It is very hard to make them into separate backports without breaking stuff along the way, so instead I clobbered them together in this PR. They follow the application order from mainline. All patches together touch only the Virtual Thread parts, so the risk for the rest of the code should be minimal.

Brief explanation of fixes:

* [JDK-8315373](https://bugs.openjdk.org/browse/JDK-8315373): In mainline since Sep 2023, there is no bug tail. Changes how VTs interact with JVMTI. We want this fix to provide the ground for the rest of backports. Notably, it makes [JDK-8312777](https://bugs.openjdk.org/browse/JDK-8312777) backport clean. 
* [JDK-8312498](https://bugs.openjdk.org/browse/JDK-8312498): In mainline since Sep 2023. There is a bug tail, [JDK-8322818](https://bugs.openjdk.org/browse/JDK-8322818). Fixes what thread state VT reports when timed-parked. This fixes the actual Loom bug.
* [JDK-8312777](https://bugs.openjdk.org/browse/JDK-8312777): In mainline since Oct 2023, there is no bug tail. Fixes the JVMTI race with mount/unmount events. Makes [JDK-8322818](https://bugs.openjdk.org/browse/JDK-8322818) backport clean. This fixes the actual Loom bug.
* [JDK-8321270](https://bugs.openjdk.org/browse/JDK-8321270): In mainline since Dec 2023, there is no bug tail. Makes [JDK-8322818](https://bugs.openjdk.org/browse/JDK-8322818) a clean backport. This fixes the actual Loom performance problem.
* [JDK-8322818](https://bugs.openjdk.org/browse/JDK-8322818): In mainline since Jan 2023. Fixes the bug introduced by [JDK-8312498](https://bugs.openjdk.org/browse/JDK-8312498). Has two additional follow-ups: [JDK-8323002](https://bugs.openjdk.org/browse/JDK-8323002) and [JDK-8323296](https://bugs.openjdk.org/browse/JDK-8323296).
* [JDK-8323002](https://bugs.openjdk.org/browse/JDK-8323002): In mainline since Jan 2023. Follow-up test fix for [JDK-8322818](https://bugs.openjdk.org/browse/JDK-8322818). Test-only change.
* [JDK-8323296](https://bugs.openjdk.org/browse/JDK-8323296): In mainline since Jan 2023. Follow-up test fix for [JDK-8322818](https://bugs.openjdk.org/browse/JDK-8322818). Test-only change.
* [JDK-8316924](https://bugs.openjdk.org/browse/JDK-8316924): In mainline since Sep 2023. Follow-up test fix for [JDK-8322818](https://bugs.openjdk.org/browse/JDK-8322818). Test-only change.

Before I undraft this, which would trigger JBS updates:

@AlanBateman, does this make sense to you?

@jerboaa, how do you feel about this?

Additional testing:
 - [x] MacOS AArch64 server fastdebug, `jdk_loom hotspot_loom`
 - [x] Linux AArch64 server fastdebug, `jdk_loom hotspot_loom`
 - [x] Linux x86_64 server fastdebug, `jdk_loom hotspot_loom`
 - [x] Linux x86_64 server fastdebug, `tier{1,2,3}`

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

Commit messages:
 - JDK-8316924: java/lang/Thread/virtual/stress/ParkALot.java times out
 - JDK-8323296: java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java#id1 timed out
 - JDK-8323002: test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java times out on macosx-x64
 - JDK-8322818: Thread::getStackTrace can fail with InternalError if virtual thread is timed-parked when pinned
 - JDK-8321270: Virtual Thread.yield consumes parking permit
 - JDK-8312777: notifyJvmtiMount before notifyJvmtiUnmount
 - JDK-8312498: Thread::getState and JVM TI GetThreadState should return TIMED_WAITING virtual thread is timed parked
 - JDK-8315373: Change VirtualThread to unmount after freezing, re-mount before thawing

Changes: https://git.openjdk.org/jdk21u-dev/pull/245/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk21u-dev&pr=245&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8315373
  Stats: 1194 lines in 13 files changed: 909 ins; 92 del; 193 mod
  Patch: https://git.openjdk.org/jdk21u-dev/pull/245.diff
  Fetch: git fetch https://git.openjdk.org/jdk21u-dev.git pull/245/head:pull/245

PR: https://git.openjdk.org/jdk21u-dev/pull/245


More information about the jdk-updates-dev mailing list