Repository navigation
drm/asahi: g17: give each open queue a compute channel before headroom - #3985
DjDeveloperr wants to merge 1 commit into
Conversation
A fresh compute QID must leave room for the render pairs of every open logical queue and of RENDER_HEADROOM (24) queues opened later. Once 26 or more queues are open, that headroom alone stops compute growth, even when every open queue runs compute and QIDs are free. A client without a channel then takes another open client's idle channel, and each such handover releases the pool and builds fresh backing before the next kick. With more busy clients than channels this never settles. On the M5 Pro, 16 deqp-vk cross_instance workers keep 35 logical queues open, 32 of them running compute. Compute stopped at 26-27 channels with 25-26 QIDs free, and every clean round made 4,100 to 6,200 channel handovers instead of about 64, running 1.12x to 1.29x slower than before "drm/asahi: g17: rebind a compute owner whose queue was shared away". Before that change, an owner whose queue was shared away before its pool growth stalled for 30 s and failed, and the queues those failures closed let compute grow to 32-33 channels. The change removed what had been hiding this limit. Let the headroom give way to one compute channel per render pair in current demand. The current pairs stay protected, and with every execution context open compute still keeps only its floor. In that workload, 10 more logical queues can still open with dedicated pairs. 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. |
|
Hardware A/B verification at exact head Setup
Results
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: merge, once the J714s and J700 rows pass at this head. The code and tests are correct. I found nothing to change in the code.
Checked at head f3eee42b75be, merged into main 5e9dffbec7d9. The merge is clean and main has no g17 changes since the base. Local merge commit a473d88df2e5, tree 002b9dbb4451.
The new cap (g17/kick.rs, compute_room). I compiled the real QueueIds code from main and from the merge on the host. For every pair demand from 0 to 63, at QID floors 0, 4 and 32, I counted the compute QIDs it grants, both with the current pairs installed and with none installed:
- Floor 0 (M5, Neo): same as main from 0 to 26 pairs and from 58 up. From 27 to 42 pairs, compute reaches one channel per pair; main gave 24 at 27 and 10 from 34. From 43 to 57, compute gets what the pairs leave: 40 at 43, falling to 10 at 58.
- After compute grows, the render pair capacity is never below the pair demand, so current demand stays protected at every count on both trees.
- With all contexts open, compute stops at its floor of 10.
- The head never grants less compute than main.
- There is no underflow:
floor < FULL_RENDER_RESERVE < QID_COUNT, and the new term usessaturating_sub.
Tests.
- Head's
tools/asahi/g17-resource-tests.py, run in the CI image (rust 1.96):- on main it fails with
each open queue keeps a compute channel; left: 26, right: 35; - at the head and on the merge it passes.
- on main it fails with
- KUnit for arm64 can't run here, so I ran the new KUnit case against the same host build. At floors 0/4/32, compute stops at 18/14/10 on main and reaches 30 at the head.
- The runtime case's arithmetic gives 14 on main and 32 at the head, which matches the changed expectation.
Merge-tree checks (pc).
make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/asahi/withCONFIG_DRM_ASAHI_M5=yandCONFIG_KUNIT=y: rc 0, withasahi_core.orebuilt.- No warning names
g17/kick.rsorg17/runtime.rs. - Two dead-code warnings at
driver.rs:297and:336don't appear in the head-only build. They come from main's 33a77d5.
- No warning names
run-host-tests.py --only g17in the CI image: 329/329 passed.- The hosted host-tests failure is only
centauri-scan-tests, which #3987 fixed on main. On the merge it passes (2/2).
Rows. satchlj's J775c PASS covers the target SoC at this head. The owed J714s A/B and a J700 row are enough before merge. Please record the gpubench-stress-vk queue.exhaust count in both: that's where this change costs capacity (on the J775c, 40 queues at the head vs 48 on base).
The Risk line missed one thing; I've fixed it in the body. T6040/T6041 (M4 Pro/Max) run this code with QID floor 32. There the changed range is 16 to 41 pairs instead of 27 to 57. The new KUnit case covers floor 32. We have no T604x, so that row can come after merge and shouldn't hold this PR.
One more note, not a change request: the cap counts pairs in demand, not open queues. On G17C/G17D, a queue with a live sibling counts twice, so compute can reach two channels per queue there. The code comment says exactly that, and the J775c run is clean.
Body edits I made:
- Tested: added the J775c result.
- Risk: added the M4 Pro/Max floor-32 range, the J775c
queue.exhaustnumbers, and that the lost capacity lasts until the firmware stops. - Not yet: added the J700 row and the
queue.exhaustcount. - Details: one channel per pair stops fitting at 43 pairs, not 42.
J700 (MacBook Neo, T8140, G17P): FAIL at
|
| Check | Result |
|---|---|
| 20 compute clients together | PASS. 20/20 clients pass, 21 compute channels (at least one per open queue), 1 rebind across VMs (20 compute QIDs; rebound <= 60 wanted) |
| 35 compute clients together | PASS. 35/35 clients pass, 39 compute channels, 17 rebinds (<= 105 wanted). On the J714s the PR reports main thrashing here; I have no main number on the J700 |
| 40 compute clients together | FAIL. 39/40 clients pass. One client got vkQueueSubmit = VK_ERROR_OUT_OF_DEVICE_MEMORY on its first work. All 40 clients were alive at once, but the all-40-open sample was never taken, so that check is INCOMPLETE |
| s2idle × 3 | PASS. Success 3 → 6, fail 0, GPU render valid after each wake |
| Whole boot | 0 GPU fault, recovery, lost-device or OOM lines, 0 WARN, BUG or Oops, watchdog armed throughout |
What the 40-client refusal is. The driver printed G17 capacity refusal LogicalQueues count=… at g17/runtime.rs:1408, which is the render_fits check for a new queue. Compute QIDs never return to render, so after the 20 and 35 rounds the boot already held 39 compute QIDs (40 after the 40 round). 128 physical QIDs minus 40 leaves 88, which is 44 render pairs, and the desktop already had 4 logical queues open (43 was the highest I saw). One more pair didn't fit. That matches the trade-off in this PR's "Risk" section ("Fewer queues can then open later with dedicated render pairs"), which names 40 for queue.exhaust on the J775c. This is the J700's number after the earlier rounds, not a fresh-boot one.
Other numbers
queue.exhaust(gpubench-stress-vk 7a0dfcf, run after everything above): 32 queues opened (4 devices × 8), then device 5 refused its first work withVK_ERROR_OUT_OF_DEVICE_MEMORY. Information only, and not comparable with a fresh-boot number from main, because the compute QIDs were already taken.- Ten GPU load cases (render.light d1/d8, compute.light d1/d8, compute.heavy-bw d2, two rounds) all passed their own checks.
What would settle it: main at the same 20/35/40 order on the same boot image, plus 40 clients on a fresh boot for both arms. I can run those on the J700; the sealed main 4c6f0f70 kernel exists.
Things worth knowing
- The whole-boot checks are shared with linux#2196, which passed its own row in the same boot.
- The wait loop on Mini gave up early when SSH dropped during the sleeps. I resumed waiting for the same running row and didn't start it again. Recovery was dead-man-only (the M4 mini wasn't held).
Stock restored: boot-ctxr.bin byte-identical to before, no trial marker left, stock 7.3.0-41, PMU boot-error count 00.
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed f3eee42. The reserve still protects all render pairs in current demand and limits the headroom reduction to one compute channel per pair where capacity allows. I checked the reserve across the three tested QID floors. The J775c row measures the benefit and the description records the reduced capacity for queues opened later.
J700 (MacBook Neo, T8140, G17P) at
|
| Clients | main | head |
|---|---|---|
| 20 | 20 of 20, 53,187 submits/s, 1 queue rebind | 20 of 20, 53,040 submits/s, 1 rebind |
| 35 | 24 of 35, 22,946 submits/s, 4,097 rebinds. 11 clients ended with a lost device (GPU work of a client failed (ENOMEM, g17/runtime/backend.rs:75), 11 kernel lines) |
35 of 35, 51,506 submits/s, 17 rebinds, 0 such lines |
| 40, same boot (A) | 40 of 40, 5,442 submits/s, 7,523 rebinds | 39 of 40, 46,690 submits/s, 38 rebinds, 2 refusals at the logical-queue limit |
| 40, fresh boot (B) | 40 of 40, 5,118 submits/s, 8,943 rebinds | 39 of 40, 51,199 submits/s, 0 rebinds, 2 refusals at the logical-queue limit |
queue.exhaust after 40 (information only) |
40 queues opened (5 devices × 8) | 32 queues opened (4 devices × 8) |
What this says about the earlier FAIL (39 of 40): it reproduces twice on the head and not on main, which opens all 40. So the refusal at 40 clients comes with the PR (or #2196), in exchange for about 9 to 10 times the submit rate and no rebind thrash at 35 to 40 clients. At 35 clients it is the other way round: main loses 11 clients to ENOMEM, the head loses none. The gated part of the row (identity, fault lines, watchdog) passes on headA, headB and baseB. It fails on baseA, because main's ENOMEM device losses are GPU fault lines.
Not covered: whether the 39-of-40 limit is wanted (a design decision for the PR), #2196 and #3985 separately, s2idle, and other generations. The runs were on one J700 with one boot per plan, so the rates are indicative.
How it ran: dead-man-only recovery (30 min), reset route checked before each slot, no reset used. Stock restored after every boot (boot-ctxr.bin byte-identical, no trial marker, PMU boot-error count 00, stock 7.3.0-41).
What: With 27 or more logical queues open, the compute QID budget kept the free QIDs for the render pairs of 24 queues that might open later, so compute stopped short of one channel per open queue even when every open queue ran compute and QIDs were free. Clients then took each other's idle channels, and each handover released a pool and built fresh backing. The headroom now gives way to one compute channel per render pair in current demand.
Tested: Mac Studio J775c (M5 Max, G17C) A/B against main by satchlj: PASS (comment): 35 and 40 open compute queues run 30-34x faster per round, gpubench-stress-vk 5/5, three s2idle cycles clean. Locally:
tools/asahi/g17-resource-tests.pypasses with a new case that replays the cross_instance capacity snapshot from linux#1964 (main stops at 26 compute channels with 35 queues open; this change reaches 35; with all 58 contexts open compute still keeps its floor of 10). arm64 LLVM=1 W=1 build ofdrivers/gpu/drm/asahi/with KUnit enabled: no warnings in the touched files, and the new and updated KUnit cases compile. checkpatch --strict: clean.Risk: two-way · the compute QID budget shared by every G17 Mac (M5 J714s and J775c, Neo J700) and by the M4 Pro/Max (T6040, T6041), which run the same code with QID floor 32. With 27 to 57 render pairs in demand (16 to 41 at floor 32), compute may now take more QIDs than before: one channel per pair up to 42 pairs (31 at floor 32), then what the pairs leave. Pairs in demand are the open queues plus live sibling and teardown-held pairs. Fewer queues can then open later with dedicated render pairs, until the firmware stops: 45 instead of 49-50 in the J714s cross_instance workload, and 40 instead of 48 in gpubench-stress-vk
queue.exhauston the J775c. Below that range, and with every context open, the budget is unchanged.Not yet:
queue.exhaustcount.queue.exhaustcount.Details
QueueIds::compute_roomlets compute take a fresh QID only while the QIDs left over coverrender_reserve(pairs): two per pair for every open queue plusRENDER_HEADROOM(24) more queues, capped at all 58 execution contexts. That leaves compute at most78 - 2 * pairschannels, which is less than one per open queue from 27 open queues on. From 34 on, the reserve is the full 118 and compute stops at 10. Compute QIDs never return to render, so whatever compute took while fewer queues were open is all it ever gets.On the J714s, 16 deqp-vk
cross_instanceworkers keep 35 logical queues open (32 devices plus the desktop), and all 32 devices run compute. The capacity samples from the linux#1964 rows showfresh_fits=0whenever all 35 are open, on both kernels. Compute grew only when open queues dropped for a moment, and those drops came from failing clients:So linux#1964 does not leak or hold a QID. It removed the failures that had been working around this limit.
The change caps the headroom at the QIDs that leave one compute channel per pair in current demand (
QID_COUNT - floor - pairs). Current demand (2 * pairs + 2) stays protected. From 43 pairs on, where one channel per pair no longer fits beside the pairs, compute may take what the pairs leave, which comes back down to the floor of 10 with all 58 contexts open. Compute only takes a fresh QID when a client needs a channel (its first, or on M5 a sibling for sustained work) and no released channel fits, so it grows with the clients that run compute at the same time, not to the cap.Tests:
headroom_leaves_each_open_pair_a_compute_channel(floors 0, 4 and 32).cancelable_siblings_do_not_block_compute_on_full_qid_tablenow expects compute to stop at one channel per open queue (32) instead of 14.tools/asahi/g17-resource-tests.pythat fails on main (left: 26, right: 35) and passes here.Evidence
tiling=38 compute=26 fresh_fits=0from round 2 on. On the earlier base, compute went 24 → 30 → 33 only in rounds with failing clients (round 1 dropped to 15 open queues, round 3 to 5).assertion left == right failed: each open queue keeps a compute channel; left: 26, right: 35. With this change:compute headroom: open queues each keep a compute channel; full context budget keeps the compute floor.make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/asahi/withCONFIG_KUNIT=yandCONFIG_DRM_ASAHI_M5=y: rc=0, no warnings inkick.rsorruntime.rs.