-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Batch mark waiters as unblocked when resuming in the deadlock handler #138874
Conversation
r? @davidtwco rustbot has assigned @davidtwco. Use |
@@ -232,7 +225,8 @@ impl QueryLatch { | |||
info.complete = true; | |||
let registry = rayon_core::Registry::current(); | |||
for waiter in info.waiters.drain(..) { | |||
waiter.notify(®istry); | |||
rayon_core::mark_unblocked(®istry); | |||
waiter.condvar.notify_one(); |
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.
Do we also need to unblock all the waiters first here,which helps reduce the chance of deadlocks due to work-stealing?
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.
No, this runs on an active Rayon thread, which prevents it from hitting the deadlock handler until all threads are unblocked.
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.
OK, it makes sense
@bors r=SparrowLii,davidtwco |
Rollup of 11 pull requests Successful merges: - rust-lang#138128 (Stabilize `#![feature(precise_capturing_in_traits)]`) - rust-lang#138834 (Group test diffs by stage in post-merge analysis) - rust-lang#138867 (linker: Fix staticlib naming for UEFI) - rust-lang#138874 (Batch mark waiters as unblocked when resuming in the deadlock handler) - rust-lang#138875 (Trusty: Fix build for anonymous pipes and std::sys::process) - rust-lang#138877 (Ignore doctests only in specified targets) - rust-lang#138885 (Fix ui pattern_types test for big-endian platforms) - rust-lang#138905 (Add target maintainer information for powerpc64-unknown-linux-musl) - rust-lang#138911 (Allow defining opaques in statics and consts) - rust-lang#138917 (rustdoc: remove useless `Symbol::is_empty` checks.) - rust-lang#138945 (Override PartialOrd methods for bool) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#138874 - Zoxc:waiter-race, r=SparrowLii,davidtwco Batch mark waiters as unblocked when resuming in the deadlock handler This fixes a race when resuming multiple threads to resolve query cycles. This now marks all threads as unblocked before resuming any of them. Previously if one was resumed and marked as unblocked at a time. The first thread resumed could fall asleep then Rayon would detect a second false deadlock. Later the initial deadlock handler thread would resume further threads. This also reverts the workaround added in rust-lang#137731. cc `@SparrowLii` `@lqd`
This fixes a race when resuming multiple threads to resolve query cycles. This now marks all threads as unblocked before resuming any of them. Previously if one was resumed and marked as unblocked at a time. The first thread resumed could fall asleep then Rayon would detect a second false deadlock. Later the initial deadlock handler thread would resume further threads.
This also reverts the workaround added in #137731.
cc @SparrowLii @lqd