[core] Enforce a deadlock-free locking order for Mutexes.#5539
[core] Enforce a deadlock-free locking order for Mutexes.#5539jimblandy merged 1 commit intogfx-rs:trunkfrom
Conversation
|
This has already found a cycle, although it might take a lot of threads to hit it. If you uncomment out the indicated code in |
2999c50 to
c4bceef
Compare
c4bceef to
0f1f20b
Compare
|
I'll take on review for this one. I've already done quite a bit of review with Jim as he's explained how the locking mechanism works. We'll both work to polish this up, and document and test properly. 🫡 |
b7de28c to
9e99c27
Compare
|
One wrinkle: This has already detected a deadlock, and I haven't pushed very far yet, so I'd guess there'd be more to come. We'll have to fix them before we can actually land this. [Edit: no, we can just make it only enabled when the feature is turned on, leaving both debug and release builds unaffected. This means we're not getting test coverage for the instrumented lock types, but at least we can have it in tree, rather than sitting on a branch as an indefinitely long list of deadlocks gets addressed.] |
ErichDonGubler
left a comment
There was a problem hiding this comment.
Not gonna commit to a review outcome yet, since this isn't out of draft yet. :^)
5bd0658 to
f30f47b
Compare
f30f47b to
1e2f85f
Compare
cwfitzgerald
left a comment
There was a problem hiding this comment.
This is absolutely amazing stuff!
Have a docs nit, but I love the docs, they are very clear
|
@cwfitzgerald Thanks for the review! @ErichDonGubler and I agreed this should have unit tests, so I'll work on that tomorrow and then ask Erich to take another look. |
6723617 to
2302e24
Compare
|
Sounds good, could @ErichDonGubler just mark it as request changes so I don't accidentally merge something I shouldn't :) |
ErichDonGubler
left a comment
There was a problem hiding this comment.
Just waiting on feedback I've already left. 😊
7d22dd6 to
70aaf44
Compare
0097585 to
d723d15
Compare
|
@ErichDonGubler, I took most of your suggestions but you had one that I didn't want to take. I've explained and left it unresolved; let me know what you think. |
88840af to
510f139
Compare
ErichDonGubler
left a comment
There was a problem hiding this comment.
Only nitpick feedback left. Approving to enable progress, since I trust @jimblandy to duly consider the feedback I've left.
57f184a to
2aa7798
Compare
|
@ErichDonGubler Hmm. Plot twist.
I'm not sure what the best way forward is.
Other ideas?? |
2aa7798 to
dae6efd
Compare
|
In chat we decided to go with Edit: Err, cfgs are compilation-wide, so actually it's |
If `debug_assertions` or the `"validate-locks"` feature are enabled, change `wgpu-core` to use a wrapper around `parking_lot::Mutex` that checks for potential deadlocks. At the moment, `wgpu-core` does contain deadlocks, so the ranking in the `lock::rank` module is incomplete, in the interests of keeping it acyclic. gfx-rs#5572 tracks the work needed to complete the ranking.
dae6efd to
d8a6f55
Compare
If
debug_assertionsor the"validate-locks"feature are enabled, changewgpu-coreto use a wrapper aroundparking_lot::Mutexthat checks for potential deadlocks.