Repository navigation
drm/asahi: g17: run the render submission on the P cores on every G17 - #1974
AxxzyWasTaken wants to merge 2 commits into
Conversation
|
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
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 (
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: 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 Not tested: games, idle or load power, the J614c. AI disclosure: done with an AI assistant (Claude); I ran and checked the hardware steps. |
cda465e to
40900b9
Compare
|
Thanks for this. The render worker drifting onto E cores is a real issue, and One request. The placement is turned on only for T6041 by chip id ( 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. |
|
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, Two things to weigh before it ships:
Tested: Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described. |
|
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>
a16ef48 to
f97641b
Compare
|
Looks good; approve once a booted row at this head is posted. I checked the new path in
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) |
|
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). |
|
J616C (MacBook Pro 16" M4 Max, T6041, 32-core 25G83) exact-head boot & headless Vulkan/GL verification at
Assisted-by: LLM (Google:Gemini 4 Neon) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
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 viaarch_scale_cpu_capacity()acrossfor_each_possible_cpu(cpu)(preserving all CPUs on homogeneous parts),Backend::fastest_cpu_render()returnstruefor every G17, andcreator_cluster_scheduling()still runs first for M5. CpumaskVar::new_zero(GFP_KERNEL)?->asahi_fastest_cpus()->queue.restrict(&cpus)?is memory-safe (workqueue_restrictcopies the mask beforecpusdrops) and uses the same ordered reclaim-safe workqueue class asdrm_sched.
- Final tree has no chip-id gating:
- §4 Attribution: Both commits (
479222c5e7a7,f97641be2f96) carry human author/committer (AxxzyWasTaken <axxzytte@gmail.com>) and humanSigned-off-by:only (zero AI trailers); PR body includesAssisted-by:. - §6 Naming & live CI: Diff and commit messages are clean;
host-testsis 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:
- 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/cpumasksysfs 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. - Unexplained 1.4–2.0× regression on J575c (40-core M4 Max, T6041): The earlier hardware test on this patch (
gpubench render.light32 passes:1479 -> 2841 usat depth 2,1737 -> 2847 usat depth 4) remains unexplained, with no J575c game A/B row yet. - Missing hardware rows for other affected G17 parts: Because
f97641be2f96turns 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. - Unresolved architectural overlap with open PR
#2217:#2217makescreator_cluster_scheduling()trueon every G17; becauseg17/job.rscheckscreator_cluster_scheduling()beforefastest_cpu_render(), landing#2217as-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 supersededcfg.chip_id == crate::hw::t6041::CHIP_IDgate ing17/mod.rs) andf97641be2f96(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 thecheckpatch.pl --strict"externs should be avoided in .c files" warning incpu_capacity.c:18.
Assisted-by: LLM (Gemini 4 Neon)
|
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) |
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_jobwhen 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 witharch_scale_cpu_capacity()through the driver's existingcpu_capacity.chelper, 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:Tested
On this branch (the commit alone on
integration/aurorafc05050): the kernel and modules build with LLVM=1. checkpatch--strictgives one warning, "externs should be avoided in .c files", for the new prototype incpu_capacity.c. That file has no header and already declaresasahi_min_cpu_capacity()the same way.The second commit (every G17):
aurora.kobuilds with LLVM=1 W=1, with no warnings in the files it touches.tools/asahi/run-host-tests.pypasses: --only g17 32/32, full run 321/321.Not tested
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)