8303908: Add missing check in VTMS_transition_disable_for_all() for suspend mode#12956
8303908: Add missing check in VTMS_transition_disable_for_all() for suspend mode#12956pchilano wants to merge 1 commit intoopenjdk:masterfrom
Conversation
|
👋 Welcome back pchilanomate! A progress list of the required criteria for merging this PR into |
sspitsyn
left a comment
There was a problem hiding this comment.
This looks good.
Thank you for catching and taking care about it!
Serguei
|
@pchilano This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 40 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
| MonitorLocker ml(JvmtiVTMSTransition_lock); | ||
| java_lang_Thread::dec_VTMS_transition_disable_count(vth()); | ||
| Atomic::dec(&_VTMS_transition_disable_for_one_count); | ||
| if (_VTMS_transition_disable_for_one_count == 0 || _is_SR) { |
There was a problem hiding this comment.
Sorry I don't understand why this _is_SR check was removed. I admit I can't really figure out what this field means anyway, but there is nothing in the issue description that suggests this also needs changing - and it is now different to VTMS_transition_enable_for_all.
There was a problem hiding this comment.
A JvmtiVTMSTransitionDisabler instance that is a "single disabler" only blocks other virtual threads trying to transition or JvmtiVTMSTransitionDisabler monopolists. Both of them will check for _VTMS_transition_disable_for_one_count (the JvmtiVTMSTransitionDisabler monopolist was missing that check) so just checking when that counter is zero is enough. In fact, for a "single disabler" _is_SR is always false so that check wasn't doing anything. Yes, this is not actually needed for the fix, but when looking at which condition we use to wait and which one to notify I caught this, sorry for not explaining that part.
And looking closer at VTMS_transition_enable_for_all() now I see the check for _is_SR is not doing anything too, because if _VTMS_transition_disable_for_all_count was not zero after the decrement then this can't be a JvmtiVTMSTransitionDisabler monopolist, i.e _is_SR will be false. When a monopolist is running all other "disable all" JvmtiVTMSTransitionDisabler instances if any will be waiting in the first "while (_SR_mode)" loop in VTMS_transition_disable_for_all(), so _VTMS_transition_disable_for_all_count will be one through the monopolist run. So this should be an assert after the decrement: assert(!_is_SR || _VTMS_transition_disable_for_all_count == 0, "").
There was a problem hiding this comment.
Thanks for clarifying - I was puzzled by the way is_SR was being used.
Thanks for the review Serguei! |
Thanks for the review David! |
|
/integrate |
|
Going to push as commit a8f662e.
Your commit was automatically rebased without conflicts. |
Please review this small fix. A suspender is a JvmtiVTMSTransitionDisabler monopolist, meaning VTMS_transition_disable_for_all() should not return while there is any active jvmtiVTMSTransitionDisabler. The code though is checking for active "all-disablers" but it's missing the check for active "single disablers".
I attached a simple reproducer to the bug which I used to test the patch. Not sure if it was worth adding a test so the patch contains just the fix.
Thanks,
Patricio
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12956/head:pull/12956$ git checkout pull/12956Update a local copy of the PR:
$ git checkout pull/12956$ git pull https://git.openjdk.org/jdk pull/12956/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12956View PR using the GUI difftool:
$ git pr show -t 12956Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12956.diff