-
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
base: master
Are you sure you want to change the base?
8373100: Genshen: Control thread can miss allocation failure notification #28665
Conversation
|
👋 Welcome back wkemper! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@earthling-amzn The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
kdnilsen
left a comment
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.
Thanks.
|
|
||
| // Notifies the control thread, but does not update the requested cause or generation. | ||
| // The overloaded variant should be used when the _control_lock is already held. | ||
| void notify_cancellation(GCCause::Cause cause); |
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_gc is read/written atomically, but ShenandoahGenerationalControlThread::_requested_gc_cause is read/written under a lock. These notify_cancellation methods did not update _requested_gc_cause at all. So, in the failure I observed we had:
- Control thread finishes cycle and sees no cancellation is requested (no lock used).
- Mutator thread fails allocation, cancels GC (again, no lock used), and does not change
_requested_gc_cause. - Control thread takes
_control_lockand checks_requested_gc_causeand sees_no_gc(becausenotify_cancellationdidn't change it) andwaitsforever now.
The fix here is to replace notify_cancellation with notify_control_thread which serializes updates to _requested_gc_cause under _control_lock.
kdnilsen
left a comment
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.
Thanks for diligent testing and analysis. Subtle code here.
In some cases, the control thread may fail to observe an allocation failure. This results in the thread which failed to allocate waiting forever for the control thread to run a cycle. Depending on which thread fails to allocate, the process may not make progress.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28665/head:pull/28665$ git checkout pull/28665Update a local copy of the PR:
$ git checkout pull/28665$ git pull https://git.openjdk.org/jdk.git pull/28665/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28665View PR using the GUI difftool:
$ git pr show -t 28665Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28665.diff
Using Webrev
Link to Webrev Comment