Repository navigation
drm/asahi: g17: handle GPU completions in the submitter's cluster on every G17 - #2217
Conversation
859abc4 to
6b9d7ce
Compare
|
Commit messages only, for the pre-PR checklist: the commits no longer carry Assisted-by: LLM (Claude:Opus 5.5) |
|
No blockers. I checked queue_event_records() (drivers/gpu/drm/asahi/g17/mod.rs:1441), note_submitter() and the new calls in the direct compute and render publishers. Work items are non-reentrant, so a per-CPU queue with enqueue_on() still never runs the event work concurrently. The load-before-store keeps the submitter line clean. Removing
HW row: an M5 (J813/J815) and one M4 Mac on a kernel with only this commit on top of integration/aurora: gpubench compute.light depth 1 before/after, plus a deqp-vk subset with no new failures and 0 GPU recoveries. On the J616s: 0 SELinux denials, 0 failed units, 0 new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
…every G17 On the M4 Pro (T6040) the GPU's mailbox IRQ is taken on CPU0 and its thread stays in P-cluster 0 (cpus 0,5-8). The event work ran on that thread's CPU, so an app on P-cluster 1 or the E-cores had every completion handled in another cluster. A depth-1 compute submit ioctl took 9 us from P-cluster 0, 12 us from P-cluster 1 and 16 us from an E-core, and an unpinned app hardly ever ran on P-cluster 0. Queue the event work at the CPU that last published work when that CPU is in another cluster than the one queueing it, and on the queueing CPU otherwise. Moving it unconditionally, to an unbound queue's worker in the submitter's L2 as the M5 does, took the IRQ-to-event-work time from 4 to 9-12 us even with everything in P-cluster 0, since a worker had to be woken elsewhere for each completion. Record the publishing CPU in the direct compute and render publishers too: most G17P work is published there, and only the device-mutex publishers did, from the scheduler's workers. Give every G17 the M5's scheduler queues restricted to their creator's cluster. The cluster is the one the device tree's cpu-map describes. t8142.dtsi (J704; only t8142-j813-j815.dtsi has one) and t6050-ultra.dtsi (J775d) have no cpu-map, so there each CPU is its own cluster. A scheduler queue then stays unrestricted instead of being tied to the one CPU that created it, as the M5 path did before, and the event work moves to the submitting CPU whenever another CPU queues it. The M5's unbound queue already ran the work in the queueing CPU's pod when that is the submitter's, so it behaves as before. Signed-off-by: Jonathan Goyvaerts <[email protected]>
6b9d7ce to
6ff7967
Compare
|
Fixed in I corrected the commit message and the PR body. They now name t8142.dtsi (J704; only t8142-j813-j815.dtsi has a cpu-map) and t6050-ultra.dtsi (J775d) as the trees without one, and say what the driver does there. That includes the event work, which on those trees moves to the submitting CPU whenever another CPU queues it. Testing: arm64 The J616s regression row will follow the next kernel build of our tree. We'd take your offer to run the M5 (J813/J815) and M4 rows in your lab. Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-review of 6ff7967: No blockers. Point from our last comment:
What changed since 6b9d7ce is that hunk only (same parent; mod.rs, runtime.rs, backend.rs and render/direct.rs are byte-identical). I checked that HW row: the J616s on a kernel with only this commit on top of integration/aurora: gpubench compute.light depth 1 before/after, a deqp-vk subset with no new failures, 0 GPU recoveries, 0 SELinux denials, 0 failed units, 0 new kernel errors. Then the same gpubench + deqp-vk subset on one M5 (J813/J815) and one M4 Mac, and on a J704 boot to cover the no-cpu-map path. Assisted-by: LLM (Claude:Opus 5.5) |
There was a problem hiding this comment.
Review of head 6ff796772cc1797c2e6cc26f8aa88110c4e94a07 against the pre-PR checklist.
Code, policy & CI
- 0 code, CI, or attribution blockers. CI (
host-tests) is green. - Topology-driven placement (§1): Removing
follows_submittereliminates an M5-only branch and bases both event-work placement (queue_event_records()indrivers/gpu/drm/asahi/g17/mod.rs:1441-1454) and scheduler queue restriction (Scheduler::new()indrivers/gpu/drm/asahi/g17/job.rs:562-569) onCpumask::cluster_of(). Skippingqueue.restrict()whencluster.weight() <= 1properly handles trees without acpu-map(t8142.dtsi/ J704,t6050-ultra.dtsi/ J775d), and the commit message and PR body accurately document both. - Concurrency & hot-path sanity:
EVENT_WORKremains non-reentrant across CPUs on the per-CPUeventsqueue;note_submitter()uses load-before-store (Relaxed) to avoid dirtying the cacheline when the submitting CPU is unchanged, and is wired into both direct publishers (runtime.rs:2065andruntime/render/direct.rs:306) alongside the device-mutex publishers. - §2–§4 & §6: No hacks or extra cmdline knobs; single commit
6ff796772cc1carries human author/committer and humanSigned-off-by:only, with PR-body disclosure present.
Holding approval for §5 hardware/runtime & performance evidence
- The J616s
gpubenchnumbers currently in the PR body were collected on an earlier test kernel carrying four additional unmerged submit-path changes and runtime investigation switches, rather than standaloneintegration/aurora+6ff796772cc1, and do not yet include conformance (deqp-vk) or the boot-health regression row. - Per checklist §5 (and matching @RyanTheTide's requested matrix), before approval we need on standalone
integration/aurora+6ff796772cc1:- J616s (M4 Pro): same-machine
gpubench compute.lightdepth-1 A/B,deqp-vksubset with no new failures and 0 GPU recoveries, plus regression row (0 SELinux denials, 0 failed units, 0 new kernel errors). - Additional affected G17 generations / topologies: same-machine
gpubenchA/B +deqp-vksubset on M4 and M5 (J813/J815), plus a J704 boot covering the no-cpu-map(cluster.weight() == 1) path.
- J616s (M4 Pro): same-machine
Once those standalone hardware/conformance rows are in, this is ready to approve.
There was a problem hiding this comment.
Formal §1–§6 pre-PR review at 6ff796772cc1797c2e6cc26f8aa88110c4e94a07 (re-verified against live integration/aurora 70a00e583b03; formalizing the §5 hold from the earlier COMMENTED review): REQUEST_CHANGES.
Audit Summary (§1–§4, §6)
- Code correctness & concurrency: 0 blockers.
- Topology-driven placement (§1): drops the M5-only
follows_submitterflag and usesCpumask::cluster_of()for bothqueue_event_records()(drivers/gpu/drm/asahi/g17/mod.rs:1441-1454) andScheduler::new()(drivers/gpu/drm/asahi/g17/job.rs:562-569), skippingqueue.restrict()whencluster.weight() <= 1for DTs without acpu-map(t8142.dtsi/ J704,t6050-ultra.dtsi/ J775d). EVENT_WORKremains non-reentrant across CPUs on the per-CPU queue, andnote_submitter()uses load-before-store (Relaxed) and is wired into both direct publishers (runtime.rs:2065,runtime/render/direct.rs:306).
- Topology-driven placement (§1): drops the M5-only
- §2–§4, §6 & CI: PASS — not superseded on
integration/aurora,mergeable: clean,host-testsgreen, human author/committer + humanSigned-off-by:only, PR body carriesAssisted-by:, naming clean.
Blockers (§5 Evidence)
- Missing standalone exact-head (
6ff796772cc1) hardware A/B, conformance, and regression evidence:- The J616s
gpubenchnumbers in the PR body were measured on an earlier test kernel carrying four additional unmerged submit-path patches and runtime switches, withoutdeqp-vkconformance or a boot-health regression row. - Required on standalone
integration/aurora+6ff796772cc1(default command line):- J616s (M4 Pro): same-machine
gpubench compute.lightdepth-1 A/B,deqp-vksubset with unchanged pass/fail counts and0 GPU recoveries, plus regression row (0 SELinux denials, 0 failed units, 0 new kernel errors). - Additional affected G17 generations / topologies: same-machine
gpubenchA/B +deqp-vksubset on M4 and M5 (J813/J815), plus a J704 boot covering the no-cpu-map(cluster.weight() == 1) path.
- J616s (M4 Pro): same-machine
- The J616s
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 6ff796772cc1: the code is ready; it needs one more row.
Blockers: none in the code. Missing row: the completion path is shared by every G17, so before it merges it also needs one M5 or Neo boot at this head with a desktop session and a dEQP-VK smoke run, 0 GPU recoveries. We'll run it on our J714s or J700.
Checked: no Apple material, no gates. The J616s boot carries this commit with the same patch-id: two hours of desktop use plus dEQP-VK and GLES runs, 0 GPU recoveries, 0 error lines, 0 failed units. That's the M4 row. CI green.
Superseded by the review at 6ff7967
|
J714s (M5 Pro, T6050) row at Kernel: one combined candidate
Health on the candidate boot: 0 oops or WARN, 0 GPU recoveries over the whole boot, 0 DART faults. Its err-level lines at boot are the default's set minus one line (the lane-count message that 2068 removes), so 0 new. Failed units: only |
What: On the M4 Pro the GPU's event work ran on the mailbox IRQ thread's CPU in P-cluster 0, so an app on P-cluster 1 or the E-cores had every completion handled in another cluster and paid to pull those cache lines back on its next submit. Every G17 now queues the event work in the submitter's cluster and keeps its scheduler workers in their creator's cluster (from the DT
cpu-map), as the M5 already did.Tested: J616s M4 Pro (T6040, 25G83) at
6ff796772cc1, in our combined kernel 7.3.0-m4.179 (integration/aurora plus our other open G17 PRs, this commit patch-id equal; not a standalone kernel), default command line, boot 2026-11-22 23:51 to 2026-11-23 01:43 UTC with desktop use and dEQP-VK/GLES runs: 0 GPU recoveries, 0 kernel lines at err level, 0 failed units; no SELinux/AppArmor loaded (0avc:lines). The gpubench A/B (submit ioctl CPU −19 to −38%) is from an earlier test kernel with investigation-only placement switches and four other submit-path changes, not from this head. KUnit at this head 696/697 (1 skipped), host tests--only g1790/90.Risk: two-way door · the G17 Macs: M4 (incl. Pro/Max), M5 and Neo (A18 Pro). On trees without a
cpu-map(t8142.dtsi / J704, t6050-ultra.dtsi / J775d) scheduler queues stay unrestricted and the event work follows the submitting CPU. Checked unaffected: only the J616s. Known cost on the J616s:submit.empty4-7% slower and occlusion query 26.0 to 28.4 us (single samples).Not yet: a standalone
integration/aurora+ this commit J616s gpubenchcompute.lightdepth-1 A/B with a deqp-vk subset; the M4, M4 Max and M5 (J813/J815); a tree without acpu-map(J704 boot).Details
On the M4 Pro (T6040), the GPU's mailbox IRQ is taken on CPU0, and its thread stays in P-cluster 0 (CPUs 0 and 5-8). The event work ran on that thread's CPU. So for an app on P-cluster 1 or the E-cores, every completion was handled in another cluster, and the app's next submit paid to pull those cache lines back.
The M5 already avoids this: its event work runs on an unbound queue in the submitter's L2, and
creator_cluster_scheduling()keeps its drm_sched workers in their creator's cluster. This change gives every G17 the same, with one difference in how the event work moves:try_compute_early) and the direct render publisher (render/direct.rs) now record the publishing CPU too. Most G17P work is published there. Before, only the device-mutex publishers recorded it, from the scheduler's workers. The store is skipped when the CPU hasn't changed, so the line the completion side reads isn't dirtied on every submit.creator_cluster_scheduling()is true on every G17. The cluster comes from the device tree'scpu-map. t8132, t604x, t6050-max, t8140 and t8142-j813-j815 have one. t8142.dtsi (J704) and t6050-ultra.dtsi (J775d) don't, so thereCpumask::cluster_of()holds only the CPU itself. A scheduler queue whose cluster mask holds one CPU is left unrestricted, so it isn't tied to the CPU that created it, as the M5 path did before. On those trees the event work moves to the submitting CPU whenever another CPU queues it.On the M5 the unbound queue already ran the work in the queueing CPU's pod when that pod is the submitter's, so it behaves as before.
Known limit: the scheduler workers stay in their creator's cluster. An app that moves to another cluster keeps its run and free work in the old one.
Evidence
gpubench on the J616s (M4 Pro, 48 GiB, 25G83), earlier test kernel
gpubench
compute.light, depth 1. Before and after are the same boot and the same Mesa: the test kernel had investigation-only run-time switches for the old and the new placement (not in this PR). Medians:The full gpubench record, same boot, depth-1 submit ioctl CPU:
Throughput stayed within 7%. Slower, single samples:
submit.empty4-7%, occlusion query 26.0 to 28.4 us.The test kernel also carries four of our submit-path changes not yet in
integration/aurora(publication batch reuse, command vectors kept in the queue, packets built in place, a shorter receive-thread lock hold). They cut the submit path's own work and don't change where completions run.Regression row, combined kernel 7.3.0-m4.179
integration/aurora bf423bf plus our other open G17 PRs; carries
6ff796772cc1patch-id equal. Boot 2026-11-22 23:51 UTC to 2026-11-23 01:43 UTC (desktop, other GPU tests, dEQP-VK and GLES runs), default cmdline: 0 kernel lines at err level, 0 failed units, 0 GPU recoveries. LSMscapability,landlock,yama, no SELinux/AppArmor loaded, 0avc:lines. The window ends where a deliberate GPU hang test for another PR started. Our later combined kernels m4.183 to m4.185 also carry this commit patch-id equal.On this branch
With the one-CPU cluster check (11-21): KUnit 696 of 697 passed, one skipped (needs
CONFIG_UCLAMP_TASK).tools/asahi/run-host-tests.py --only g1790/90. arm64defconfig+asahi.configbuild ofdrivers/gpu/drm/asahiis clean in the touched file. CIhost-testsgreen.