[jdk17u-dev] RFR: 8340547: Starting many threads can delay safepoints

Sergey Nazarkin snazarki at openjdk.org
Mon Feb 3 08:41:40 UTC 2025


I'd like to backport this fix to fix the issue with starting a lot of threads in a burst. 

Despite the low priority of this issue, some users have found this to be a barrier to migrating from JDK8. 

The backport is not clean as it needs to adjust `globals.hpp` and replace `ConditionalMutexLocker` with classic MutexLocker. The rank `nonleaf` of `UseThreadsLockThrottleLock` has been chosen to be as close as possible to the rank of `Threads_lock` and to not cause a crash in debug mode:

#  Internal Error (/home/ubuntu/jdk17u-dev/src/hotspot/share/runtime/mutex.cpp:398), pid=1777, tid=1782
#  assert(false) failed: Attempting to acquire lock Threads_lock/22 out of order with lock ThreadsLockThrottle_lock/22 -- possible deadlock


Field `_allow_vm_block` is set to `false` to prevent 

#  Internal Error (/home/ubuntu/jdk17u-dev/src/hotspot/share/runtime/thread.cpp:981), pid=56846, tid=56851
#  assert(false) failed: Possible safepoint reached by thread that does not allow it


Similar PR is on review at [jdk21](https://github.com/openjdk/jdk21u-dev/pull/1365)
Original fix and discussion are https://github.com/openjdk/jdk/pull/21111

Tested with tier1 (release), tier2(fastdebug), and reproducers from [JDK-8340547](https://bugs.openjdk.org/browse/JDK-8340547), [JDK-8307970](https://bugs.openjdk.org/browse/JDK-8307970)

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

Commit messages:
 - Fix lock rank
 - Fix absence of ConditionalMutexLocker

Changes: https://git.openjdk.org/jdk17u-dev/pull/3263/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk17u-dev&pr=3263&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8340547
  Stats: 14 lines in 5 files changed: 11 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk17u-dev/pull/3263.diff
  Fetch: git fetch https://git.openjdk.org/jdk17u-dev.git pull/3263/head:pull/3263

PR: https://git.openjdk.org/jdk17u-dev/pull/3263


More information about the jdk-updates-dev mailing list