Skip to content

Conversation

snazarkin
Copy link
Contributor

@snazarkin snazarkin commented Feb 3, 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
Original fix and discussion are openjdk/jdk#21111

Tested with tier1 (release), tier2(fastdebug), and reproducers from JDK-8340547, JDK-8307970


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8340547 needs maintainer approval

Issue

  • JDK-8340547: Starting many threads can delay safepoints (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk17u-dev.git pull/3263/head:pull/3263
$ git checkout pull/3263

Update a local copy of the PR:
$ git checkout pull/3263
$ git pull https://git.openjdk.org/jdk17u-dev.git pull/3263/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3263

View PR using the GUI difftool:
$ git pr show -t 3263

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk17u-dev/pull/3263.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 3, 2025

👋 Welcome back snazarki! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 3, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title Backport e704c055a4cf2aab77cc2b3d034f5a8b8d9e3331 8340547: Starting many threads can delay safepoints Feb 3, 2025
@openjdk
Copy link

openjdk bot commented Feb 3, 2025

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added backport Port of a pull request already in a different code base rfr Pull request is ready for review labels Feb 3, 2025
@mlbridge
Copy link

mlbridge bot commented Feb 3, 2025

Webrevs

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 3, 2025

@snazarkin This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 31, 2025

@snazarkin This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Mar 31, 2025
@xiezhaokun
Copy link
Member

@snazarkin Can you reopen this pull request ?

@snazarkin
Copy link
Contributor Author

/open

@openjdk openjdk bot reopened this Aug 26, 2025
@openjdk
Copy link

openjdk bot commented Aug 26, 2025

@snazarkin This pull request is now open

@snazarkin
Copy link
Contributor Author

/reviewer credit @olivergillespie
/reviewer credit @dimitryc

@openjdk
Copy link

openjdk bot commented Aug 26, 2025

@snazarkin
Reviewer ogillespie successfully credited.

@openjdk
Copy link

openjdk bot commented Aug 26, 2025

@snazarkin
Reviewer dcherepanov successfully credited.

@snazarkin
Copy link
Contributor Author

/reviewers 1

@openjdk
Copy link

openjdk bot commented Aug 26, 2025

@snazarkin
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 1 (with at least 1 Reviewer).

@snazarkin
Copy link
Contributor Author

@olivergillespie could you please review the patch?

Copy link
Contributor

@olivergillespie olivergillespie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks fine, but I don't know enough about any changes between 17 and 21/tip to be totally confident - we left vm_block as default false in tip, too, so that seems right, but 17 does seem to set vm_block=true a lot more than tip, I don't know why, maybe JDK-817639.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Port of a pull request already in a different code base rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants