Skip to content

drm/asahi: g17: handle GPU completions in the submitter's cluster on every G17 - #2217

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-completion-cluster
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-completion-cluster

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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 (0 avc: 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 g17 90/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.empty 4-7% slower and occlusion query 26.0 to 28.4 us (single samples).

Not yet: a standalone integration/aurora + this commit J616s gpubench compute.light depth-1 A/B with a deqp-vk subset; the M4, M4 Max and M5 (J813/J815); a tree without a cpu-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:

  • Event work: queued on the CPU that last published work when that CPU is in another cluster, and on the local CPU otherwise. Moving it every time, as the M5's unbound queue does, adds a worker wakeup to every completion. On the M4 Pro that took the IRQ-to-event-work time from 4 to 9-12 us, even with everything in P-cluster 0. Off the M5 the queue stays per-CPU, so the event work still never runs concurrently with itself.
  • Submitter tracking: the direct compute publisher (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.
  • Scheduler workers: creator_cluster_scheduling() is true on every G17. The cluster comes from the device tree's cpu-map. t8132, t604x, t6050-max, t8140 and t8142-j813-j815 have one. t8142.dtsi (J704) and t6050-ultra.dtsi (J775d) don't, so there Cpumask::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:

Submitter Submit ioctl CPU, before after Latency, before after
Pinned to P-cluster 0 11.67 us 9.47 us 81.6 us 81.5 us
Pinned to P-cluster 1 15.05 us 10.40 us 93.4 us 86.7 us
Unpinned 15.01 us 11.21 us 93.8 us 89.6 us

The full gpubench record, same boot, depth-1 submit ioctl CPU:

Test Before After
compute.light 14.71 us 10.58 us
compute.heavy alu 15.31 us 11.44 us
copy.bw buf2img 27.56 us 17.58 us
render.heavy 27.10 us 16.81 us

Throughput stayed within 7%. Slower, single samples: submit.empty 4-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 6ff796772cc1 patch-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. LSMs capability,landlock,yama, no SELinux/AppArmor loaded, 0 avc: 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 g17 90/90. arm64 defconfig + asahi.config build of drivers/gpu/drm/asahi is clean in the touched file. CI host-tests green.

@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Commit messages only, for the pre-PR checklist: the commits no longer carry Assisted-by (item 4), and the disclosure is now the PR body's last line. The tree is identical to 859abc4c97 (git diff 859abc4c97 6b9d7ce8e2 is empty). New head 6b9d7ce8e2.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

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 follows_submitter drops an M5-only branch in favour of the cluster topology, which is the right input.

  1. The commit message says every G17 device tree has a cpu-map. arch/arm64/boot/dts/apple/t8142-j704.dts (t8142.dtsi has none; only t8142-j813-j815.dtsi does) and t6050-ultra.dtsi (J775d) do not. There, Cpumask::cluster_of() is the CPU alone, so drivers/gpu/drm/asahi/g17/job.rs:563 restricts each scheduler queue to the single CPU that created it. The M5 path already did this, so it is not new here, but either add the cpu-map to those trees or skip the restrict() when the cluster mask has one CPU, and correct the message.

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]>
@jgoyvaerts
jgoyvaerts force-pushed the m4pro/g17-completion-cluster branch from 6b9d7ce to 6ff7967 Compare November 21, 2026 17:01
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Fixed in 6ff796772c, in the code: drivers/gpu/drm/asahi/g17/job.rs:566 calls restrict() only when Cpumask::cluster_of() holds more than one CPU. Where the tree has no cpu-map, the scheduler queue stays unrestricted instead of being tied to the CPU that created it. That decision comes from the topology the machine reports, with no chip check. The device trees are unchanged.

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 defconfig + asahi.config build of drivers/gpu/drm/asahi, with no warnings in job.rs. KUnit on arm64 qemu: 696/697, 1 skipped. run-host-tests.py --only g17: 90/90.

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)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of 6ff7967: No blockers.

Point from our last comment:

  1. Single-CPU cluster on trees without a cpu-map (t8142.dtsi / J704, t6050-ultra.dtsi / J775d): resolved. drivers/gpu/drm/asahi/g17/job.rs:566 restricts the scheduler queue only when Cpumask::cluster_of() has more than one CPU, so on those trees the queue stays unrestricted instead of being tied to its creating CPU. The commit message and description now name both trees correctly.

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 Cpumask::weight() exists at this head (rust/kernel/cpumask.rs:157) and that, without a cpu-map, the arm64 topology leaves each CPU's cluster mask as the CPU alone, so the check selects from what the device tree describes rather than by chip. On those trees queue_event_records() (drivers/gpu/drm/asahi/g17/mod.rs) then moves the event work to the submitter whenever another CPU queues it, as the message says; that path has no measurement yet.

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)

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_submitter eliminates an M5-only branch and bases both event-work placement (queue_event_records() in drivers/gpu/drm/asahi/g17/mod.rs:1441-1454) and scheduler queue restriction (Scheduler::new() in drivers/gpu/drm/asahi/g17/job.rs:562-569) on Cpumask::cluster_of(). Skipping queue.restrict() when cluster.weight() <= 1 properly handles trees without a cpu-map (t8142.dtsi / J704, t6050-ultra.dtsi / J775d), and the commit message and PR body accurately document both.
  • Concurrency & hot-path sanity: EVENT_WORK remains non-reentrant across CPUs on the per-CPU events queue; 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:2065 and runtime/render/direct.rs:306) alongside the device-mutex publishers.
  • §2–§4 & §6: No hacks or extra cmdline knobs; single commit 6ff796772cc1 carries human author/committer and human Signed-off-by: only, with PR-body disclosure present.

Holding approval for §5 hardware/runtime & performance evidence

  • The J616s gpubench numbers 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 standalone integration/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:
    1. J616s (M4 Pro): same-machine gpubench compute.light depth-1 A/B, deqp-vk subset with no new failures and 0 GPU recoveries, plus regression row (0 SELinux denials, 0 failed units, 0 new kernel errors).
    2. Additional affected G17 generations / topologies: same-machine gpubench A/B + deqp-vk subset on M4 and M5 (J813/J815), plus a J704 boot covering the no-cpu-map (cluster.weight() == 1) path.

Once those standalone hardware/conformance rows are in, this is ready to approve.

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_submitter flag and uses Cpumask::cluster_of() for both queue_event_records() (drivers/gpu/drm/asahi/g17/mod.rs:1441-1454) and Scheduler::new() (drivers/gpu/drm/asahi/g17/job.rs:562-569), skipping queue.restrict() when cluster.weight() <= 1 for DTs without a cpu-map (t8142.dtsi / J704, t6050-ultra.dtsi / J775d).
    • EVENT_WORK remains non-reentrant across CPUs on the per-CPU queue, and note_submitter() uses load-before-store (Relaxed) and is wired into both direct publishers (runtime.rs:2065, runtime/render/direct.rs:306).
  • §2–§4, §6 & CI: PASS — not superseded on integration/aurora, mergeable: clean, host-tests green, human author/committer + human Signed-off-by: only, PR body carries Assisted-by:, naming clean.

Blockers (§5 Evidence)

  1. Missing standalone exact-head (6ff796772cc1) hardware A/B, conformance, and regression evidence:
    • The J616s gpubench numbers in the PR body were measured on an earlier test kernel carrying four additional unmerged submit-path patches and runtime switches, without deqp-vk conformance or a boot-health regression row.
    • Required on standalone integration/aurora + 6ff796772cc1 (default command line):
      • J616s (M4 Pro): same-machine gpubench compute.light depth-1 A/B, deqp-vk subset with unchanged pass/fail counts and 0 GPU recoveries, plus regression row (0 SELinux denials, 0 failed units, 0 new kernel errors).
      • Additional affected G17 generations / topologies: same-machine gpubench A/B + deqp-vk subset on M4 and M5 (J813/J815), plus a J704 boot covering the no-cpu-map (cluster.weight() == 1) path.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) blast:none Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 6ff79677: ready to merge

Check Detail
CI at head ok 1 check passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at 6ff79677
Conflicts ok none
PR text ok Risk: two-way · 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.empty 4-7% slower and occlusion query 26.0 to 28.4 us (single samples).

Areas: area:gpu
Merge: gh pr merge 2217 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) and removed blast:none Macs affected, from Merge risk (bot) labels Nov 24, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 21:01

Superseded by the review at 6ff7967

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed changes-requested A reviewer requested changes (bot) labels Nov 24, 2026
@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Nov 24, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J714s (M5 Pro, T6050) row at 6ff796772cc1: PASS

Kernel: one combined candidate 94ea5d0cb4ec (tree 3c2a50b08e3c) = main 065904c137fa + PRs 2909, 2227, 2217, 2068, 2870 and 2954 at their exact heads, merged in that order with no conflicts and the PR commits unchanged. Built natively on the M5 as 7.3.0-m5-fb4 and booted with the default's DTB, Stage 2 and command line (MTE on, SEP writes on). Baseline: the M5 default 7.3.0-m5-cdirect14, same Mesa.

  • Desktop: Hyprland driving the panel, a Dell 4K at 120 Hz and a Samsung G81SF 4K at 240 Hz kept the same pid from boot through every test and one sleep. The 11 DRM clients (Hyprland, Xwayland, quickshell and the rest) were all still there at the end.
  • dEQP-VK smoke (CTS 1.4.7.1, headless, beside the running desktop): api.smoke 8/8, synchronization.basic 29/29, draw.renderpass.simple_draw 4/4, compute.pipeline.basic 80/81 (1 NotSupported), query_pool.occlusion_query 434/441 (7 NotSupported). 555 Pass, 0 Fail.
  • 0 GPU recoveries over the whole boot.
  • gpubench compute.light depth 1, same boot: time inside vkQueueSubmit 9.54 us vs 11.12 us on the default, round trip 102.3 us on both. That kernel also carries 2909, so this is not a split for this PR alone.

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 tailscaled.service, which fails on the default too. LSMs capability,landlock: no SELinux or AppArmor, 0 avc: lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants