Skip to content

drm/asahi: g17: run the render submission on the P cores on every G17 - #1974

Closed
AxxzyWasTaken wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:t6041-g17-render-pcores
Closed

AxxzyWasTaken wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:t6041-g17-render-pcores

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

drm_sched runs a render queue's run work on its own ordered, unbound workqueue, so the kernel can put that worker on any CPU. On the J616c (16-inch M4 Max) it usually ends up on an E core. Games with many small passes per frame keep that worker busy. In Counter-Strike 2 the render workers used 56% of an E core (2.6 GHz), every render was already in run_job when the GPU went idle, and the GPU sat at about 80% busy while at its top performance state.

On every G17 backend, this has the driver create the render scheduler's submit queue itself, the same way M5 already does, and restrict it to the CPUs with the highest capacity: the P cores of both P clusters, which are CPUs 0 and 5-13 on the J616c. Cpumask::cluster_of() would only cover one of the two clusters. The CPUs are picked with arch_scale_cpu_capacity() through the driver's existing cpu_capacity.c helper, so on a part with only one kind of core every CPU stays in the mask. The compute scheduler, the event queue and the M5 path are unchanged: M5 keeps its workers in the creator's cluster (creator_cluster_scheduling()), which is checked first.

The first commit turned this on for T6041 by chip id. After review, the second one makes it the default for every G17. The reason, run work that falls behind the GPU on an E core, applies to any part with both kinds of core, and the same E-core placement shows on the M4 Pro. T6041 behaves as before.

Measured

On the J616c, with the same P-core restriction applied to every unbound workqueue through /sys/devices/virtual/workqueue/cpumask (3fe1), CS2 alternating between the two masks:

  • The render workers dropped from 56% of an E core to 31% of a P core.
  • GPU busy went from 75-84% to 91-96%.
  • Mean fps over four rounds went from 103.6 to 116.6 (+13%), with the GPU at its top clock both ways. P cores won 6 of 7 rounds.
  • Desktop idle power on AC (SMC total system power, 3 × 20 s) was about 16 W both ways, with no difference outside the noise.

Tested

On this branch (the commit alone on integration/aurora fc05050): the kernel and modules build with LLVM=1. checkpatch --strict gives one warning, "externs should be avoided in .c files", for the new prototype in cpu_capacity.c. That file has no header and already declares asahi_min_cpu_capacity() the same way.

The second commit (every G17): aurora.ko builds with LLVM=1 W=1, with no warnings in the files it touches. tools/asahi/run-host-tests.py passes: --only g17 32/32, full run 321/321.

Not tested

  • This exact head booted. The numbers above come from the global workqueue mask, which also moved every other unbound workqueue.
  • Idle power on battery.
  • The J614c.
  • Any G17 other than T6041: the M4 Pro, A18 Pro and M4 have no rows yet.
  • A slowdown on the J575c (M4 Max Mac Studio, comment above): with one 64x64 pass per submission, P-core placement was 1.4-2x slower per submission (32 passes at depth 2: 1479 to 2841 us), with every P-only workqueue mask. That is T6041 too, and the cause isn't known yet. It needs a game row there, and rows on the other parts, before this ships.
  • Overlap with drm/asahi: g17: handle GPU completions in the submitter's cluster on every G17 #2217, which makes creator_cluster_scheduling() true on every G17. That check comes first, so with drm/asahi: g17: handle GPU completions in the submitter's cluster on every G17 #2217 as it is, the render worker follows its creator's cluster and this PR has no effect.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@7robertodantas

Copy link
Copy Markdown
Contributor

Tested on a J575c (Mac Studio, M4 Max, 12P+4E, 40-core GPU). The placement change works here, but the synthetic test I could run got slower, not faster.

Setup: kernel fc05050 + #1987 + this commit (cda465e), compared with the same kernel without it. Mesa/hk 202611101320. CPUs 1-4 are the E cores (capacity 421), and 0 and 5-15 the P cores (1024), so the new mask is 0, 5-15. Both kernels booted and the GPU works. No failed units.

Workload: gpubench render.light (64x64 pass, one triangle), plus a local passes=N option that records N such passes into separate targets in one command buffer. That's the closest thing to "many small passes per frame" I have. I don't have CS2 or another game on this machine. Values are the median µs per submission over 4 alternating rounds (lower is better). The CPU split comes from ftrace workqueue_execute_start for drm_sched_run_job_work.

without with this PR
run_job_work on E cores 100% 0%
32 passes, depth 2 1479 2841
32 passes, depth 4 1737 2847
8 passes, depth 8 410 561
1 pass, depth 16 / 64 26.7 / 27.8 26.7 / 29.9
compute.light, depth 16 (control) 13.2 13.7

A third boot back on the kernel without the PR gave 1412 µs for 32 passes at depth 4, so the gap is not boot-to-boot noise.

On the unpatched kernel I also tried the global mask method from the PR description (/sys/devices/virtual/workqueue/cpumask), 32 passes at depth 4:

mask run_job_work ran on µs/submit
ffff (default) E 1412
001e (E only) E 2062
03e1 (P cluster with CPUs 0, 5-9) P 2696
fc00 (P cluster with CPUs 10-15) P 2188
ffe1 (both P clusters) P 2647

So on this board every P-only mask is slower for this workload, including a single P cluster. That rules out work hopping between the two clusters. The P clusters were at 2.1-4.1 GHz during the slow runs, so it isn't a low P-core clock either. The global mask also changes things beyond the render worker: 001e keeps run_job_work on the E cores, the same as ffff, and is still slower. The GPU mailbox IRQ (CPU 7) and the aurora_g17_events work (CPUs 5-9) sit in the first P cluster during these runs. I haven't worked out why P-core placement is slower here.

This doesn't contradict your CS2 numbers. A 64x64 pass is almost free on the GPU, so this test mostly measures the round trip of the run_job and completion path, and a game frame isn't like that. But at least one render-heavy pattern gets about 1.4-2x slower per submission on the J575c. A real game test on a 40-core part would help before this is turned on for every T6041. I can run the patched gpubench test on another workload if you have one in mind, or share the passes=N change.

Not tested: games, idle or load power, the J614c.

AI disclosure: done with an AI assistant (Claude); I ran and checked the hardware steps.

@AxxzyWasTaken
AxxzyWasTaken force-pushed the t6041-g17-render-pcores branch from cda465e to 40900b9 Compare November 17, 2026 21:16
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for this. The render worker drifting onto E cores is a real issue, and asahi_fastest_cpus() is a clean way to find the P cores.

One request. The placement is turned on only for T6041 by chip id (drivers/gpu/drm/asahi/g17/mod.rs:1798, fastest_cpu_render: cfg.chip_id == crate::hw::t6041::CHIP_ID). The reason in the comment, that the run work falls behind the GPU on an E core, applies to every SoC with both P and E cores. asahi_fastest_cpus() already returns every CPU on a part with one core type. In this tree we select behaviour by hardware property, not by the chip it was tested on.

Could you make it the default for every G17 backend, or name in a comment the hardware reason the others should not get it? We have seen the same E-core submit placement on the M4 Pro. Also, the J575c comment reports a slowdown in one synthetic test, so we would like rows before it ships. We can run them on our M4 Pro and A18 Pro.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks. It's now the default for every G17 backend, in a new commit, "drm/asahi: g17: render submission on the P cores on every G17". The chip id check is gone, and the G17 backend always restricts the render scheduler's submit queue to the highest-capacity CPUs. As you say, asahi_fastest_cpus() returns every CPU on a part with one kind of core. M5 is unchanged: creator_cluster_scheduling() is checked first and keeps its workers in the creator's cluster. The comment at fastest_cpu_render() says so. T6041 behaves as before.

Two things to weigh before it ships:

Tested: aurora.ko builds with LLVM=1 W=1, with no warnings in the files the commit touches. tools/asahi/run-host-tests.py passes: g17 32/32, full run 321/321. I haven't booted this head.

Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described.

@AxxzyWasTaken AxxzyWasTaken changed the title drm/asahi: g17: run the T6041 render submission on the P cores drm/asahi: g17: run the render submission on the P cores on every G17 Nov 19, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for a16ef48. Running the render submission on the fastest CPUs on every G17, with the comment explaining why and leaving M5 to its creator-cluster placement, covers what we asked. Because of the earlier J575c synthetic slowdown we will run rows on our M4 Pro and A18 Pro at this head and post them here.

drm_sched runs a render queue's run work on an ordered, unbound
workqueue of its own, so the work can land on any CPU. On the M4 Max
(J616C) it usually lands on an E core. A game with many small passes per
frame keeps that worker busy: in Counter-Strike 2 the render workers
used 56% of an E core, each render was already in run_job when the GPU
went idle, and the GPU sat at about 80% busy at its top performance
state.

On T6041, create the render scheduler's submit queue in the driver, as
M5 already does, and restrict it to the CPUs of the highest capacity:
the P cores of both P clusters (CPUs 0 and 5-13 on the J616C). The CPUs
are picked with arch_scale_cpu_capacity(), so a part with only one kind
of core keeps every CPU. The compute scheduler and the other driver
queues stay where they were.

With the same P-core restriction set for every unbound workqueue through
/sys/devices/virtual/workqueue/cpumask, the render worker used 31% of a
P core, GPU busy rose from 75-84% to 91-96% and CS2 went from 103.6 to
116.6 fps (mean of four rounds), with the GPU at its top clock in both.
Desktop idle power on AC showed no difference outside noise (about 16 W
both ways); idle power on battery was not measured.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
The render run work falls behind the GPU on an E core because of how it
works, one job published at a time, not because of anything particular
to T6041: the same E-core placement shows on the M4 Pro. So restrict the
render scheduler's submit queue to the highest-capacity CPUs on every
G17 backend instead of on T6041's chip id alone.

asahi_fastest_cpus() already returns every possible CPU on a part with
one kind of core, so such a part keeps every CPU. M5 is unchanged: its
scheduler workers stay in their creator's cluster
(creator_cluster_scheduling()), which is checked first. T6041 is
unchanged.

The CS2 result in the commit before is from T6041 only. A J575c (M4 Max
Mac Studio) synthetic test with a 64x64 pass per submission got slower
with P-core placement (32 passes per command buffer: 1479 to 2841 us per
submission), so other parts need their own rows before this ships.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@AxxzyWasTaken
AxxzyWasTaken force-pushed the t6041-g17-render-pcores branch from a16ef48 to f97641b Compare November 21, 2026 09:57
@RyanTheTide

Copy link
Copy Markdown
Contributor

Looks good; approve once a booted row at this head is posted.

I checked the new path in drivers/gpu/drm/asahi/g17/job.rs:565-577: workqueue_restrict() copies the mask (rust/kernel/workqueue.rs:541-549), so dropping the CpumaskVar at the end of the branch is fine, the queue is the same ordered reclaim-safe kind drm_sched would allocate, and creator_cluster_scheduling() still wins on M5. asahi_fastest_cpus() (drivers/gpu/drm/asahi/cpu_capacity.c:29-40) picks the possible CPUs with the top arch_scale_cpu_capacity(), so the result follows the DT capacities and there is no per-chip choice left.

  1. Nit: g17/job.rs:569 declares the extern "C" prototype inline in the Rust function, and cpu_capacity.c:12 declares it again in the .c file. A small cpu_capacity.h included by cpu_capacity.c and bound through the driver's bindings would clear the checkpatch warning and keep the two in sync.

HW row: this head (not the global workqueue mask) on the J616c, CS2 A/B against the base with the same scene, fps and GPU busy, plus the J575c synthetic and one game row, and an M4 Pro row; 0 failed units, 0 new kernel errors. #2217 needs to be settled first, since with it applied this branch is never taken.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

This still applies cleanly to the current integration/aurora tip 110861f, and the render submit-queue placement is not on the tip yet. The code review is done apart from the nit about the duplicated asahi_fastest_cpus() prototype. Two things still decide whether it goes in: #2217 (still open) makes creator_cluster_scheduling() true on every G17, and with it applied this branch is never taken, so the two need settling against each other on the same workload. Rows at this head are also still needed: J616c CS2 A/B, the J575c synthetic and a game row, and an M4 Pro row.

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).

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

J616C (MacBook Pro 16" M4 Max, T6041, 32-core 25G83) exact-head boot & headless Vulkan/GL verification at f97641be2f96 (7.3.0-j616c-pr1974+, aura v1.0.0b15):

  • CPU capacity map confirmed: cpu1..4 (cap=421, E-cores), cpu0, cpu5..13 (cap=1024, P-cores).
  • GPU probe & workloads (Mesa Borealis Vulkan 1.4 git-1fa0b69be2):
    • aurora 28a600000.gpu probed cleanly (0 GPU faults / errors / warnings).
    • vulkaninfo --summary PASS (Apple M4 Max (G16C B1)).
    • glmark2-es2-drm --off-screen PASS (terrain 139 FPS, build 1673 FPS, Score 905).
    • vtxalu (1M tris × 40 frames): mean_ms=16.794 (59.55 fps).
    • dEQP-VK raster/geometry/tiling subset (624 cases): 258 Pass / 366 NotSupported / 0 Fail / 0 Warn.
  • Health: 0 failed systemd units, 0 SELinux AVC denials, 0 GPU faults/errors.
  • Note on #2217: Interactive CS2 A/B comparing #1974 vs #2217 on the same workload still waits for an interactive desktop session.

Assisted-by: LLM (Google:Gemini 4 Neon)

@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 review at live head f97641be2f96baa3aa4a58e840abae508bbe7b92: holding APPROVE with COMMENT — not ready for MERGETRAIN-LINUX4 yet.

Checked & clean (code at head, §1–§4, §6, live CI)

  • §1–§3 Implementation at head f97641be2f96 (cpu_capacity.c, g17/job.rs, g17/runtime/backend.rs):
    • Final tree has no chip-id gating: asahi_fastest_cpus() derives the highest-capacity mask dynamically via arch_scale_cpu_capacity() across for_each_possible_cpu(cpu) (preserving all CPUs on homogeneous parts), Backend::fastest_cpu_render() returns true for every G17, and creator_cluster_scheduling() still runs first for M5.
    • CpumaskVar::new_zero(GFP_KERNEL)? -> asahi_fastest_cpus() -> queue.restrict(&cpus)? is memory-safe (workqueue_restrict copies the mask before cpus drops) and uses the same ordered reclaim-safe workqueue class as drm_sched.
  • §4 Attribution: Both commits (479222c5e7a7, f97641be2f96) carry human author/committer (AxxzyWasTaken <axxzytte@gmail.com>) and human Signed-off-by: only (zero AI trailers); PR body includes Assisted-by:.
  • §6 Naming & live CI: Diff and commit messages are clean; host-tests is green (SUCCESS).

Remaining blockers holding APPROVE (§5 performance evidence & design overlap)

The newly posted exact-head J616C row (f97641be2f96) cleanly proves headless boot stability and dEQP-VK conformance (258 Pass / 0 Fail, 0 GPU faults, 0 failed units, 0 SELinux AVC denials), but does not yet clear the §5 bar for a cross-G17 performance change:

  1. No exact-head same-machine A/B performance proof on J616C: §5 requires a same-machine A/B with conformance unchanged for performance claims. The CS2 numbers in the PR body (103.6 -> 116.6 fps) were captured via the global /sys/devices/virtual/workqueue/cpumask sysfs mask (moving all unbound workqueues), not this patch, and the new headless row is a single-arm smoke run without a baseline A/B comparison.
  2. Unexplained 1.4–2.0× regression on J575c (40-core M4 Max, T6041): The earlier hardware test on this patch (gpubench render.light 32 passes: 1479 -> 2841 us at depth 2, 1737 -> 2847 us at depth 4) remains unexplained, with no J575c game A/B row yet.
  3. Missing hardware rows for other affected G17 parts: Because f97641be2f96 turns P-core render submission on for every G17, §5 still needs same-machine A/B + conformance rows on other affected G17 parts (M4 Pro / A18 Pro / M4) before shipping globally.
  4. Unresolved architectural overlap with open PR #2217: #2217 makes creator_cluster_scheduling() true on every G17; because g17/job.rs checks creator_cluster_scheduling() before fastest_cpu_render(), landing #2217 as-is turns #1974's branch into dead code. Both PRs need same-workload A/B settling before either merges.

Minor non-blocking cleanup nits (for when this is next updated)

  • Consider squashing 479222c5e7a7 (which introduces the superseded cfg.chip_id == crate::hw::t6041::CHIP_ID gate in g17/mod.rs) and f97641be2f96 (which immediately deletes those 8 lines) into one clean commit so git history does not carry an intermediate chip-id gate.
  • Moving the asahi_fastest_cpus() declaration into a small header (as noted by @RyanTheTide) would clear the checkpatch.pl --strict "externs should be avoided in .c files" warning in cpu_capacity.c:18.

Assisted-by: LLM (Gemini 4 Neon)

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Closing in favor of #2217, which handles GPU completions in the submitter's cluster across every G17 and supersedes this PR.

Assisted-by: LLM (Google:Gemini 4 Neon)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants