-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8373100: Genshen: Control thread can miss allocation failure notification #28665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
earthling-amzn
wants to merge
4
commits into
openjdk:master
from
earthling-amzn:fix-missed-cancellation
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
89af170
Expand scope of control lock so that it can't miss cancellation notif…
earthling-amzn 1081f21
Set requested gc cause under a lock when allocation fails
earthling-amzn baed458
Improve comment
earthling-amzn 4c82d21
Merge remote-tracking branch 'jdk/master' into fix-missed-cancellation
earthling-amzn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods were the root cause here.
ShenandoahHeap::_canceled_gcis read/written atomically, butShenandoahGenerationalControlThread::_requested_gc_causeis read/written under a lock. Thesenotify_cancellationmethods did not update_requested_gc_causeat all. So, in the failure I observed we had:_requested_gc_cause._control_lockand checks_requested_gc_causeand sees_no_gc(becausenotify_cancellationdidn't change it) andwaitsforever now.The fix here is to replace
notify_cancellationwithnotify_control_threadwhich serializes updates to_requested_gc_causeunder_control_lock.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at the places where
ShenandoahHeap::clear_cancelled_gcis called, I feel the problem is more likely from op_final_update_refs:Let's say there is concurrent GC running, right before the final update refs safepoint, there is mutator allocation failure:
_alloc_failure_waiters_lock, claiming safepoint safe as well.The fix seems to work in generational mode, but may not work in non-generational mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I was staring at the code ShenandoahController::handle_alloc_failure today, I found there is discrepancy between ShenandoahGenerationalControlThread and ShenandoahControlThread, I created a bug to unify the behavior, we could fix the issue in ShenandoahControlThread there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scenario I described wasn't supposition, that is actually what happened in the debugger. The scenario you describe with
op_final_update_refswould also be fixed by this PR. The_requested_gc_causefield should always be accessed under a lock. The code change here fixes an issue where an allocation failure might not set_requested_gc_causeat all.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I understand the fix will solve the issue for genshen and also fix scenario I described.
I'll solve the potential issue in non-generational Shenandoah in the PR to fix the behavior differences in Genshen and non-generational Shenandoah.