Repository navigation
drm/asahi: g17: rebind a compute owner whose queue was shared away - #1964
Conversation
A compute publication whose command does not fit its queue's pool grows the pool (Rebind::Grow). grow_compute allocates the new backing without the device mutex, then retries under it until the growth completes. Until begin_growth marks the queue growing, the queue is an idle channel with no prepare claim (compute_readiness claims only a queue whose pool already fits), so another owner's admission can share it away (share_idle) when no channel is free. grow_compute then finds no queue for its owner and returns EAGAIN, and its loop treats that as "wait for progress" and retries. Only build_compute binds a channel again, and grow_compute never returns to it. The publication waits out its whole 30 s budget and fails with EBUSY, even after the machine has gone idle with released channels and free QIDs. linux#1866's report for such a loss reads "channel=30000 ... queue None": grow_compute's waits are counted as channel time because they run inside ensure_compute. On M5 a pool fits only a command plan with the same block size and no more blocks, so growth is common there. Under 16 parallel dEQP-VK cross_instance processes, channels change hands every few hundred milliseconds. A device that lost its channel this way kept its work-state node and never bound again, and the client saw a lost device. When the owner holds no queue, grow_compute now returns EAGAIN to ensure_compute at once, both before allocating the new backing and inside its retry loop. ensure_compute already retries EAGAIN through build_compute, which binds a channel. A growth that has begun is aborted on that error path as before. Other EAGAIN results are handled as before. The change is not M5-specific: on G17P the same loop could wait for a queue shared away before its growth began. G17P grows a pool only for a larger block count, so it reaches this path rarely. Signed-off-by: Diljit Singh <hey@djdev.me>
|
Looks good; approve once the Neo rows run on this head.
HW row: (a) J714s, integration/aurora with only this commit on top: 10 rounds of the 16-process dEQP-VK.synchronization*.cross_instance.* burst, with 0 lost devices and 0 "gave up after 30000 ms" lines, against the same tree without the commit. (b) Neo (J700, G17P): the 3-client GPU stress row and the sync P1 row on this head, with no new Crash/Fail, 0 GPU recoveries, 0 AVC denials, 0 failed units and no new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
|
Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches. Host tests (tools/asahi/run-host-tests.py --only) on 110861f plus this change: g17 passes (90/90). |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: REQUEST CHANGES at 5481bba7
Blockers:
- Branch is
CONFLICTINGwithmain. Rebase or merge currentmainso the PR isMERGEABLEand build/KUnit CI executes cleanly against currentdrivers/gpu/drm/asahi/g17/runtime.rs. - Missing exact-head hardware verification. No hardware test row has been posted exercising compute pool growth / channel sharing on G17 hardware at the rebased head.
Checked:
- Diff (
drivers/gpu/drm/asahi/g17/runtime.rs,+17/-4): returningErr(EAGAIN)immediately before allocation and settingunbound = truewhenfirmware.queues.compute_mut(self.owner)returnsNoneinsidegrow_compute()avoids waiting out the 30 s budget when a compute channel was shared away and letsensure_compute()rebind viabuild_compute().
Evidence
- Code logic in
grow_compute()is clean and directly addresses thechannel=30000 ... queue Nonestall (linux#1866). - Rebase onto
mainto clearCONFLICTING, verify CI green, and post an exact-head G17 hardware test row.
Resolve ensure_compute_pool(): keep this branch's early EAGAIN for an owner whose queue was shared away, with main's check that every channel of the owner fits; in the growth path keep main's sibling drain and primary lookup and mark the owner unbound when it has none. Signed-off-by: DjDeveloperr <hey@djdev.me>
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed the conflict-pass merge commit 21fa9ac only: runtime.rs adapted to main's per-owner compute queues (pool_fits over the owner's queues, compute_primary(owner)). The resolution keeps what each side had and adds nothing outside the conflict. Approved for the merge-up; merging still waits on CI and the rows at this head.
There was a problem hiding this comment.
Verdict: MERGE at 21fa9ac8d573
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: Code reviewed in the earlier App review at this head (6122660677).
Follow-ups (not blocking): current CI, focused G17 shared-queue rebind run
|
Blocker at
|
The match scrutinee in grow_compute keeps the owner's queue locked while the arm guard checks every bound queue. That scan locks the same cell again while holding the device mutex. Check separately whether a queue is still bound so the lookup guard drops before the scan. Keep the lookup that can find a bound sibling when the primary was shared away. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
The fix at A Rust 2021 mutex-scope model using the before and after code reproduced the recursive lock on the previous head and passed the unbound, sufficient-capacity and undersized-sibling cases with the fix. Strict checkpatch and the merge diff check passed. The next hardware row is a J714s lockdep-enabled cross-instance synchronization run at this head. Run 10 rounds with 16 processes and compare to main, checking for admission timeouts, lost devices and lockdep reports. J700 is the second-generation control for the shared growth path. |
|
J700 (G17P) row at head Ten one-shot boots on J700, alternating head and base, with the same config, toolchain, stock Fedora 44 userspace (Mesa d4ad4a4dce) and deqp-vk binary. Each ran the same 13-client, 210 s load: ray-query compute CTS, cross_instance sync, GPUBench
Evidence on Mini: |
|
Triage of the J700 allocation-failure delta: this PR doesn't delay any memory release. One base boot can't tell whether the higher rate is real. Three more boots would settle it. No code change. What fails. Every failed client in all three boots got -2 ( Each boot's kernel log has only one refusal site: What the PR changes. It changes only Denominators. The lower run counts come from the failures. Each worker restarts its client back to back for the whole window, so worker time is fixed: 1,256 to 1,263 s for ray-query CTS and 832 to 837 s for cross_instance in every boot. A failed ray-query CTS run takes about 2.3 s, against 0.9 s for a passing one. The passing runs aren't slower. Ray-query CTS median is 0.62 / 0.63 / 0.62 s and cross_instance median is 1.10 / 1.21 / 1.14 s (head / base / head). So "fewer runs" and "more failures" are the same effect: more clients waiting on queue creation. Is the higher rate real? Not shown yet.
What would settle it. Use the same kit and the same 13-client, 210 s protocol for three more one-shot boots: base, head, base. That makes the full order head, base, head, base, head, base, with three boots of each. In each window, sample Compare failure rates per boot:
I moved the PR body to the org template and listed this under Not yet. The J714s lockdep row can run at this head. |
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE
Blockers:
None.
Checked:
- Audited exact head
de11d6beda08912a7c5fb8af8774353a4fe0347aindrivers/gpu/drm/asahi/g17/runtime.rs(grow_compute()):- Splitting
if firmware.queues.compute(self.owner).is_none()into its own condition drops theQueueGuardtemporary before iteratingfirmware.queues.compute, fixing the recursiveComputeCellmutex deadlock from21fa9ac8d573. - When
compute_primary(self.owner)returnsNoneinside the retry loop, settingunbound = trueexits the loop immediately instead of waiting out the 30 s budget, unwinds any startedgrowthviaabort_growth(), drops the tentativealiasandpagesallocations, and returnsEAGAINsoensure_compute()rebinds viabuild_compute().
- Splitting
- All hosted CI checks at
de11d6beda08are green (apple-build,host-tests,pr-text,KUnit plan,KUnit asahi). - Exact-head J700 (G17P) 6-boot matched A/B in comment #7340378429 shows 0 admission timeouts, 0 lost devices, 0 GPU faults/recoveries, identical logical-queue usage (peak 52 vs 53 of 58, mean 40.2 vs 41.0), and failure rates within boot-to-boot spread; prior J714s 10-round 16-process
cross_instanceA/B passed 10/10 vs 2/10 lost devices on base (exact-head J714s lockdep row transparently noted inNot yet).
Evidence
- Head audited:
de11d6beda08912a7c5fb8af8774353a4fe0347a(MERGEABLE, basemain). - CI:
apple-build,host-tests,pr-text,KUnit plan,KUnit asahiallSUCCESS. - Hardware rows: J700 (
G17P) 6-boot A/B atde11d6beda08(#issuecomment-7340378429) PASS; J714s (M5 Pro) 10/10 rounds PASS on earlier base.
|
Holding the merge even though the readiness check says it's ready. Both rows under Not yet are still open: the J714s lockdep row at the final head (M5 lead) and the J700 queue-creation refusal boots, which the Neo lead is running now with five boots per kernel. The frontier merges this with |
|
Local check passed for merge tree |
|
J714s (M5 Pro, T6050, G17S B1) lockdep qualification at exact head Environment
Head vs Base Summary
Diagnostic Details
HandbackJ714s cleanly restored and verified back on stock |
|
Holding this out of the merge train after the 16:00 J714s A/B, where head failed R1. Here's what the logs show:
No code change for now. The J714s rerun uses the same kit and samples meminfo, the ledger and per-process shmem every second through round 1. Head must show no OOM kill, no more ENOMEM or faults than base, the desktop session intact, and clean rounds within 1.10× of base. If it OOMs again, the extra memory gets its own fix first, and this PR reruns on top of it. |
|
Merging at |
|
Post-merge instrumented J714s (M5 Pro, T6050, G17S B1) lockdep rerun at exact head Environment
Head vs Base Summary
Round-1 Per-Second Memory & Ledger TelemetryBoth arms exhibited the exact same
HandbackJ714s restored and verified cleanly on stock |
|
Attribution of the post-merge J714s rerun (the comment above): the code in this PR doesn't cause the extra ENOMEMs, GPU faults or the watchdog timeout. One run per arm can't settle the slower clean rounds, so a row to settle them is below. No code change. What the change can do. It only changes ENOMEM, 8 vs 1. Each deqp-vk worker uses the same GPU memory on both kernels: about 1,320 MiB, then about 2,420 MiB.
GPU faults, 58 vs 32 lines. That count includes every "client failed" line plus about 5 lines per recovery. Head had 9 recoveries and 15 lost devices; base had 3 recoveries and 17 lost devices. Recoveries follow clients the driver had just failed:
Both arms show the same unmapped reads at 0x0–0x80. The PR changed how clients fail (13 EBUSY timeouts on base, 7 more ENOMEMs on head), not the fault path. The watchdog (counted as "2 admission timeouts"). It is one event, logged on two lines, and the classifier counts both. A render command on slot 7 (qids 26/27) sat at the head of its queue from about 263.9 s, inside recoveries 4–6 (263.66–263.68 s). Its firmware cursors read done = read = write = 339, so the firmware finished the work and the driver missed the completion across a recovery. That is the render path, which this PR doesn't touch. The first A/B's base arm also had a watchdog timeout (on a compute command, 30,672 ms at the head of its queue). Head had 0 compute admission timeouts and 0 Clean rounds, 24.41 vs 19.64 s (1.24×): not settled.
Row to settle it (J714s, one lease, about 30 min)
The per-test times come from the |
|
Post-merge 4-boot J714s (M5 Pro, T6050, G17S B1) attribution row at exact head Environment
Timing Attribution (
|
| Pair | Order (1st → 2nd) | base median clean |
head median clean |
head / base |
1st / 2nd |
head > 1.10× base |
|---|---|---|---|---|---|---|
| Pair 1 | boot-01-base → boot-02-head |
19.53 s (n=5) |
21.79 s (n=9; 24.67 s R02–R05 w/ lockdep on) |
1.116× (1.263× w/ lockdep on) |
0.896× |
YES |
| Pair 2 | boot-03-head → boot-04-base |
19.54 s (n=6) |
25.16 s (n=6) |
1.288× | 1.288× |
YES |
- Run order ruled out:
baseran identically whether 1st (19.53 s) or 4th (19.54 s).headran24.05–25.04 sin R02–R05 ofboot-02-head(matchingboot-03-head's25.16 smedian), then dropped to20.52–21.79 sin R06–R10 afterMAX_LOCKDEP_CHAIN_HLOCKSdisabled lockdep at314.10 s— and its overall median (21.79 s) still exceeded1.10×base.
Per-Boot Summary & asahi_g17_bind Mechanism
| Metric | boot-01-base |
boot-02-head |
boot-03-head |
boot-04-base |
|---|---|---|---|---|
Release / boot_id |
cf03d96b / d3b7659d |
de11d6be / b78d9892 |
de11d6be / b13aa4b6 |
cf03d96b / aafe4351 |
Build IDs (kernel / aurora.ko) |
462c2f102523 / 97c644e05cce |
cb32436d1b9b / 75f852b2c41b |
cb32436d1b9b / 75f852b2c41b |
462c2f102523 / 97c644e05cce |
| Rounds passed / failed | 5 / 5 |
9 / 1 |
6 / 4 |
6 / 4 |
| Median clean round | 19.53 s |
21.79 s |
25.16 s |
19.54 s |
Compute queue None timeouts |
8 |
0 (4 non-queue None adm/WDT) |
0 (1 compute WDT) |
7 |
ENOMEM @ backend.rs:75 (R2–10) |
2 (0) |
10 (0) |
11 (2) |
2 (0) |
lockdep / WARN / BUG |
0 / 0 / 0 |
1 / 0 / 1 (MAX_LOCKDEP_CHAIN_HLOCKS in R06) |
0 / 0 / 0 |
0 / 0 / 0 |
oom_kill delta / desktop PIDs |
0 / unchanged |
0 / unchanged |
0 / unchanged |
0 / unchanged |
GPUBench sanity (rt.scene fps) |
PASS (68.31) |
PASS (68.33) |
PASS (68.28) |
PASS (68.29) |
Total compute asahi_g17_bind (fresh / rebound / same_vm) |
30 / 2,783 / 14 |
24 / 53,207 / 699 |
23 / 51,089 / 843 |
29 / 3,489 / 22 |
| Unique compute QIDs allocated | 33 |
27 |
26 |
32 |
Compute rebound per clean round |
64–65 |
4,114–5,360 |
4,913–6,211 |
64–76 |
Why head Is 1.24–1.29× Slower in Clean Rounds (asahi_g17_bind Evidence)
- All
renderbind counts were0across all 4 boots; the entire difference is in compute channel rebinds (engine=1 kind=1):baseallocated32–33unique compute QIDs (enough for all16 × 2 = 32cross_instanceVulkan contexts to hold a dedicated compute channel), so clean rounds did only64–76rebinds/round (19.53–19.54 s).headcapped out at26–27unique compute QIDs (6short of the32-context working set), causing clean rounds to thrash at4,114–6,211compute rebinds/round (~80× higher thanbase;51,089–53,207total vs2,783–3,489), adding ~5.5 s/round (24.05–25.81 swith lockdep on) and pushingboot-02-headoverMAX_LOCKDEP_CHAIN_HLOCKSin R06 (184,170chain hlocks used).- Under
head, returningEAGAINfromgrow_computeintobuild_computelets owners aggressively share idle channels (share_idle) instead of allocating fresh QIDs up to the 32-context working set, locking subsequent clean rounds into permanent compute-channel thrash.
Handback
J714s restored and verified cleanly on stock 7.3.0-m5-pr67 (boot_id=8589de5d-e1d9-4e7f-aa76-08714a29536c, 13/13 slot hashes, 91/91 ICD hashes, pacman -Qkk mesa 0 altered files, online=1, xprop 0x200005).
What: A compute owner whose queue another owner's admission shared away before its pool growth began now goes back to
build_computeat once and binds a channel again. Before,grow_computewaited out its whole 30 s budget for a queue it no longer held, and the client got a lost device (EBUSY). linux#1866's report for that loss readschannel=30000 ... queue None.Tested:
de11d6beda08, ten one-shot boots (five head, five base, alternating), each with 210 s of 13 concurrent clients (ray-query compute CTS, cross_instance sync, GPUBench queue.rebind, queue.churn, rt.rays): 0 admission timeouts, 0 lost devices, 0 GPU faults or recoveries, 0 WARN/BUG in every boot. The bind tracepoint shows the rebind path ran in every boot. Client queue-creation refusals are within boot-to-boot spread (Welch p ≥ 0.2 at n=5).cross_instancecases with 16 processes: 0 of 10 rounds failed and 0 lost devices, against 2 of 10 rounds and 2 lost devices without the change.Risk: two-way · the shared G17 compute runtime on M5 (J714s) and Neo (J700). G17P reaches the changed path rarely.
Not yet:
Details
Under parallel load, a compute publication that has to grow its queue's pool could lose that queue before the growth began. Until
begin_growthmarks the queue growing, the queue is an idle channel with no prepare claim, so another owner's admission can share it away (share_idle) when no channel is free.grow_computethen found no queue for its owner, and its loop treated that EAGAIN as "wait for progress". Onlybuild_computebinds a channel again, so the publication waited out its budget and failed with EBUSY, even after the machine had gone idle with released channels and free QIDs.With this change,
grow_computereturns EAGAIN toensure_computeas soon as its owner holds no queue, both before it allocates the new backing and inside its retry loop.ensure_computealready retries EAGAIN throughbuild_compute, which binds a channel. A growth that has already begun is aborted on that error path as before, and every other EAGAIN is handled as before. The new backing is dropped on that return, so an owner that lost its queue holds no growth memory while it binds again. Before, it held that backing while it waited.The follow-up commit drops the queue lookup guard before scanning the owner's cells. The earlier
matchform kept the guard alive across the scan, which locks the same cell again.The path is shared. G17P can reach it too, but rarely, because it grows a pool only for a larger block count (a ray-query scratch layout). On M5 a pool fits only a plan with the same block size, so growth is common there.
It merges outside the Neo ship window.
Evidence
M5 Pro (J714s), two matched fresh boots of the same test kernel. The kernel is integration/aurora d89d8c0 with linux#1866's attribution. Each boot started at 63 s uptime, and the burst was the first GPU work on it: 10 rounds of the 20,006 supported
dEQP-VK.synchronization*.cross_instance.*cases, 16 processes, headless, the same Mesa.channel=30000 ... queue NoneNeither boot had a GPU or MMU fault. Round 1 took 35 s on the kit module and 14 s with the change.
Caveat: the arm with this change also carried an unrelated M5-only change to render kicks, which sends the queue configuration with every render kick. It is not part of this PR, and nothing in it touches compute admission. Still, the A/B above attributes the fix to this change with that one confound.
J700 (G17P), head → base → head, base = merge-base
cf03d96bf209. Stock Fedora 44 userspace (Mesa d4ad4a4dce), the same deqp-vk binary, the same config and toolchain for both kernels. Full receipt: #1964 (comment)Every failed client failed at
vkQueueSubmitwithVK_ERROR_OUT_OF_DEVICE_MEMORY. On G17P the stock Mesa creates the kernel queue at the first submit and maps an ENOSPC or EBUSY fromDRM_IOCTL_ASAHI_QUEUE_CREATEto that error. The only kernel refusal in all three boots isG17 capacity refusal LogicalQueues ... at g17/runtime.rs:1408, which queue creation retries for 2 s before it returns EBUSY. Every failed client ran for at least 2.07 s.Builds:
.configfiles are byte-identical.Image modules dtbs: make rc=0, and no new warnings ing17/runtime.rs.