[SYCL][Graph] Fix lock order inversion during native recording host task submission - #22758
Open
mmichel11 wants to merge 2 commits into
Open
[SYCL][Graph] Fix lock order inversion during native recording host task submission#22758mmichel11 wants to merge 2 commits into
mmichel11 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a potential deadlock during SYCL graph native recording by removing a graph_impl::MMutex acquisition from the restricted host-task submission path (which runs under the queue mutex), eliminating a queue -> graph lock order that could invert with end_recording()’s graph -> queue order.
Changes:
- Add a new e2e regression test that races
Graph.end_recording()against concurrent restricted host task submissions. - Introduce a dedicated mutex guarding the native host-task callback lifetime container in
graph_impl. - Switch
graph_impl::addNativeHostTaskCallback()to use the new leaf mutex instead of the graph-wide mutex.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sycl/test-e2e/Graph/RecordReplay/NativeRecording/Threading/host_task_concurrent_end_recording.cpp | Adds a concurrency regression test intended to reproduce the prior lock-order inversion/deadlock scenario. |
| sycl/source/detail/graph/graph_impl.hpp | Adds a dedicated mutex for the native host-task callback container to avoid taking the graph-wide lock in the submit path. |
| sycl/source/detail/graph/graph_impl.cpp | Updates addNativeHostTaskCallback() to lock the new mutex instead of MMutex. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If a user concurrently ends capture while submitting a native host task, then the thread ending capture acquires the
graph lock -> queue lockand the host task submission thread acquiresqueue lock -> graph lockthrough the handler. This was introduced after we added locking around graph capture in #22604.The graph lock is acquired during host task submission to extend the lifetime of the user's callback. This container can be given its own mutex as it is just a lifetime extender that does not require locking the full graph and prevents deadlock.