Repository navigation
drm/asahi: g17: hold one compute cell lock while choosing a channel - #4039
Conversation
A lockdep kernel on J714s (M5 Pro) reports a possible recursive lock on g17::ComputeCell::queue during the GPU stress, from publish_compute_on(): one cell is locked while another is held. select_compute_channel() runs min_by_key() on the locked queues themselves. min_by_key() keeps the best item while it looks at the next one, so the best queue's cell stays locked while the next cell is being locked. All other walks over the cells hold one cell at a time. It cannot deadlock: the cells are distinct, only a holder of the device mutex takes a second one, and direct publishers hold one cell and never wait for the device mutex. But the walk can stall a direct publisher on the held cell, and lockdep turns itself off after the report, so it hides every later one. Read the key and the QID of each queue under its own lock and compare the keys. The choice is unchanged. Fixes: 7bb65ce ("drm/asahi: g17: fan M5 Pro compute out to sibling channels for sustained heavy kicks") Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed 1c7275a. The iterator keeps the same channel selection key and returns an owned key/QID pair, so each cell guard drops before the next cell is locked. The reported host checks pass. A J714s lockdep rerun is pending.
|
J714s (Apple M5 Pro / T6050 / G17S B1) verification on exact head
|
|
Local checks on this head merged with main
Hosted |
What: A lockdep kernel on J714s reported
possible recursive lockingong17::ComputeCell::queueinpublish_compute_on().select_compute_channel()kept the best queue locked while it locked the next one. It now compares plain keys, so it holds one queue at a time. It can't deadlock today, but the report switches lockdep off, so it hides any later one.Tested: J714s (G17S) at
1c7275a8414c, as part of main6985e45ab583+ #4074 + this, lockdep off: 41,844 CTS cases with 0 Fail, queue create/teardown stress and GPUBench pass, 0 faults (row). J700 (G17P): the head arm of #4074's row, module-onlyaurora.koof main6985e45ab583+ #40746aee22f46165+ #34290663be9696f1+ this, no difference from the base arm, one compute channel per owner on both (row; two checks there fail on both arms, so they say nothing about this). Local, merged with main: g17 host tests 343/343,drivers/gpu/drm/asahi/W=1builds with no warning in the changed file.Risk: two-way door · M5 Pro (only there does an owner have more than one compute channel, up to three). J700 and the other G17 Macs run the same function with one channel; its choice is unchanged.
Not yet: the J714s lockdep stress that produced the report, rerun with this fix (follow-up; it needs a lockdep kernel).
Details
min_by_key()ran on the queue guards themselves. It keeps the best item while it pulls the next one, and here an item is a locked cell:Why it isn't a deadlock:
select_compute_channel()always runs with the device mutex held, so only one thread at a time can hold two cells. It takes them in registry order.compute_direct(),compute_readiness(),hold_claim()) hold one cell at a time. While they hold it, they take no second cell, no device mutex and noouter_compute.This was the only walk over the cells that kept a guard while it took the next one. The other
min_by_key()users over the cells already map to a key and a QID first; this one now does the same. The walk also no longer makes a direct publisher of the best queue wait while it is blocked on another queue's lock.Evidence
From the J714s lockdep kernel (main
37a630623169+ #3681, 240 s GPU stress), shortened:debug_locksin/proc/lockdep_statswent from 1 before the stress to 0 after it. #3681 doesn't touch this file; main has the same code.Local checks at this head (base main
5f32aa72fa7e):make W=1 drivers/gpu/drm/asahi/(arm64, LLVM, asahi profile): base 41 warnings, head 41, same text, 0 errors.tools/asahi/run-host-tests.py --only g17: 337/337.--only m3-stamp-admission: 2/2.checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.