Skip to content

[5.6] Fix priority inversions when waiting on a task status lock #40594

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

Merged

Conversation

rjmccall
Copy link
Contributor

Since locking the task status is a presumed-uncommon case, the trade-offs inherent in the allocation patterns of AtomicWaitQueue are very appropriate here, even more than they are for metadata completion.

rdar://86100232

5.6 version of #40586
Reviewed by Mike Ash

The existing uses of AWQ don't need arguments during construction,
but uses that do almost certainly need to update existing instances
if createQueue happens to re-use one.  Users probably aren't going
to think about this proactively by doing something wild like reading
the documentation.  We can point this mistake out to them by making
their code not compile if they call createQueue with arguments
without providing a special method.  This pattern also makes the
actual update code much easier to write, since callers don't need
to specially detect this case.
Add a tryReloadAndWait method to Worker (which can only be used
when not the worker thread).  Revise the docs to describe this
sort of pattern as the more standard pattern, which I think is
likely to better reflect common use.
Since locking the task status is a presumed-uncommon case, the
trade-offs inherent in the allocation patterns of AtomicWaitQueue
are very appropriate here, even more than they are for metadata
completion.

rdar://86100232
@rjmccall rjmccall changed the base branch from main to release/5.6 December 16, 2021 19:17
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 9ec4747

@rjmccall
Copy link
Contributor Author

LLDB test failure seems unrelated.

@swift-ci Please smoke test OS X

@rjmccall
Copy link
Contributor Author

@swift-ci Please test macOS

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 9ec4747

@rjmccall
Copy link
Contributor Author

@swift-ci Please test macOS

@rjmccall rjmccall merged commit db805fe into swiftlang:release/5.6 Dec 18, 2021
@rjmccall rjmccall deleted the task-status-atomic-wait-queue-5.6 branch December 18, 2021 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants