Skip to content

drm/asahi: g17: hold tiling for indirect waits only while a sibling is busy - #4258

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/g17-two-pair-idle-sibling-tiling
Dec 4, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/g17-two-pair-idle-sibling-tiling

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What: On queues with two render pairs (G17C, G17D), a render's fragment-only compute waits and same-VM attachment overlaps go onto its tiling kick only while another pair of the same queue holds a render that hasn't retired (or one parked for replay). When the other pair is idle, tiling overlaps compute again, as it did before linux#3991. A fragment wait that names a render on another pair is still always ordered.

Tested: g17 host tests 384/384 in the pinned workflow image, including all 13 mutations of g17-render-partial-order (2 new). Warm module-only build on pc (aurora_defconfig, LLVM): base and head build, and only aurora.ko changes source. W=1 of drivers/gpu/drm/asahi/ gives the same 39 warnings on both. Hosted: KUnit asahi 637 passed and 1 skipped of 638, including the new a_two_pair_queue_with_idle_siblings_tiles_beside_its_compute_waits_and_hazards; apple-build and host-tests pass.

Risk: two-way door · M5 Max / M5 Ultra (two-pair G17C/G17D) render ordering. One-pair queues are unchanged.

Not yet: a G17D (M5 Ultra) run. The two-pair A/B on J775c is done: satchlj's ABBA run of peer-j775c-4258-c924253c-20261204 gave VERDICT FIX (rt.scene light d2 fps +18.4 %, fps_timed medium..extreme +7..+13.5 %, 0 CTS status diffs in renderpasses + synchronization, stress 5/5). The receipt and the merge evidence are in the comments.

Details

Why. satchlj's same-Mesa A/B on J775c (main ebfb5226 vs f21d1ed0, Borealis 23f7c8697dbc, gpubench-rt-vk rt.scene trace=query): untimed light d2 went from 7,503 to 6,216 fps (-17.2 %). Timed medium..extreme d2 lost 7-12 % fps_timed, and gpu_raster_us grew by +156..+2,186 µs, matching gpu_as_us. #3991 promotes the fragment-only compute waits and attachment overlaps of every render on a two-pair queue (ordered_partial && render_pairs > 1). In this scene, the render's fragment half waits for the AS build, so its tiling waited for it too.

When the promotion is needed. DRM_ASAHI_FEATURE_ORDERED_PARTIAL_RENDERS promises that a partial render starts after the fragment work its fragment half is ordered after: the pair's own earlier fragment work (fragment_busy drains it) and the renders its fragment barriers name. Those named renders are promoted on every queue, as before. A compute wait or an attachment overlap matters only when it stands for a render of the queue that runs on another pair. Such a render exists only while another pair of the owner holds one that hasn't retired:

  • A render's compute wait resolves to a published compute kick. Any render that compute waits for was published before it.
  • An overlap with a render of the owner's other pair names a live render there.
  • When the other pairs are idle, what remains are overlaps with other queues' renders. A one-pair queue has left those on the fragment kick since a3e795e.

The two-pair admission keeps a queue at depth 1-2 on one pair (SIBLING_BACKLOG = 1). So at d2 the other pair is normally idle, and this change applies.

Change.

  • Registry::sibling_render_in_flight(slot, owner) (runtime/render.rs) checks every other pair the owner holds. A resident pair counts when Pair::in_flight() is true (active, parked replay or configuration). A lent pair counts when its borrowed_active or borrowed_replay snapshot is set, the same way render_in_flight() treats lent pairs.
  • The device-mutex path samples this in publish_render (submit.rs). The direct path samples it in lend_render, under the same device-mutex hold that resolves the compute waits it copies into the loan, and carries it in Loan (direct.rs).
  • render_barriers now uses ordered_partial && render_pairs > 1 && dependencies.sibling_in_flight.
  • RenderDependencies::EMPTY starts with the flag set. Any path that doesn't sample the pairs keeps drm/asahi: g17: order cross-pair partial renders and advertise feature on two-pair M5 #3991's ordering.

One-pair path (J714s and smaller M5, A18 Pro) is unchanged. render_pairs > 1 still gates the promotion, and pairs::per_owner() is 1 there. The new flag can't turn the promotion on, so the kick barriers stay the same.

Evidence
Host tests (pc, localhost/aurora-linux-host-tests:ubuntu2404, rustc 1.96.0, --network=none):
  python3 -I tools/asahi/run-host-tests.py --jobs 8 --only g17-   -> 384/384 passed
  g17-render-partial-order-tests.py: plain + 13/13 mutations killed
    (new: sibling-only, idle-siblings-promoted)
rustfmt (kernel .rustfmt.toml) over the 4 touched .rs files: no new deviations vs base

Warm module-only build (pc, reflinked aurora_defconfig O=, LLVM, one slot):
  base main bd3112c58d65: Image+modules 175 s; aurora.ko build-id b6652fc18803f831917f8d19a8b9600a0def7b61
  head (tree e6daa41fe0e1): sync rewrote 4 files under drivers/gpu/drm/asahi/ + 2 under tools/asahi/;
       aurora.ko build-id 7f943b68905c7217d3aa74dbd452072983314f25
  make W=1 drivers/gpu/drm/asahi/: 39 warnings base, 39 head, identical sets (none in the touched code)

Hosted KUnit asahi: Ran 638 tests: passed: 637, skipped: 1
  [PASSED] a_two_pair_queue_with_idle_siblings_tiles_beside_its_compute_waits_and_hazards

…s busy

linux#3991 made a render on a queue of two render pairs (G17C, G17D)
hold its tiling kick behind every fragment-only compute wait and every
same-VM attachment overlap. Either may stand for an earlier render on
the queue's other pair, which `fragment_busy` does not drain, and a
tiler-heap overflow partial render must not run ahead of that render.

Such a render exists only while another pair of the owner holds one
that has not retired. A queue that keeps its renders on one pair, as a
shallow queue does, still had its tiling held behind compute. On J775c,
rt.scene with ray queries lost 7-17 % of its frame rate with linux#3991,
its raster time growing by its acceleration-structure build time.

Promote those two waits only while another pair of the owner holds a
render that has not retired, or one parked for replay, resident or lent
out. The device-mutex path samples this when it publishes and the
direct path when it lends the pair. A compute wait of the render was
published before it, and so was any render that compute waits for.
RenderDependencies starts with the promotion on, so a path that does
not sample the pairs keeps the ordering it had.

A fragment wait that names a render of another pair is still promoted
always. A queue of one pair (M5 Pro and smaller, A18 Pro) never
promotes the two waits, as before.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@satchlj

satchlj commented Dec 4, 2026

Copy link
Copy Markdown
Member

J775c (M5 Max, two-pair G17C B1, 64 GiB) ABBA peer-kit receipt for peer-j775c-4258-c924253c-20261204 (kit.sh --check 5/5):

  • Verdict: VERDICT FIX: B ordered correctly and faster (light d2 fps +18.4%, median fps_timed medium..extreme +12.0%) (kit.sh judge exit 0)
  • Arm A: aurora-silicon/linux@bd3112c58d655452ccfc8ad99b611589021e6aa0, packaged trial kernel 7.3.0-1-4258.0-ARCH (kernel build-ID 8ad09f60e6d3b8f8d6e5f9f84faf68d4b0a2bf0a, aurora.ko build-ID 86dca164d2af6f1742fe7892f7b4909839bb036e).
  • Arm B: module-only rebuild of aurora.ko from the same kernel build tree after applying 0001-drm-asahi-g17-hold-tiling-for-indirect-waits-only-wh.patch (verified tree e6daa41fe0e1a5b84ab642a73ee7e85423b1d8c5, aurora.ko build-ID f7a3cf6baccd2e890ca074d10d4d8bcf9662f7ef), staged into /usr/lib/modules/7.3.0-1-4258.0-ARCH/updates/aurora.ko via kit.sh stage-b for B1/B2 and unstaged via kit.sh unstage before A2. Identical kernel image and Borealis Mesa (1:26.3.0_devel.20261204.23f7c8697dbc-1) across all four rounds.
  • Stress & CTS: gpubench-stress-vk (xq.order, xq.chain, cr.concurrent, render.tiler, rq.stress) 5/5 PASS in all four rounds (A1, B1, B2, A2). CTS renderpasses + synchronization: A1 and B1 both 90,195 Pass / 56,364 Skip, 0 status diffs. Zero new GPU kernel-log errors; all census CRCs match between A and B.

verdict.txt

arms: A module 86dca164d2af6f17, B module f7a3cf6baccd2e89; kernel identical in all rounds (module-only)
CTS renderpasses+synchronization: A1 {'Pass': 90195, 'Skip': 56364}; B1 {'Pass': 90195, 'Skip': 56364}; 0 status diffs

rt.scene trace=query d2: mean of A1,A2 vs mean of B1,B2 (noise = spread between an arm's rounds)
preset    metric                 A1         A2         B1         B2      B/A  noise
light     fps                6260.2     6272.9     7413.2     7431.9   +18.4%   0.3%
light     fps_timed          6435.3     6403.6     6826.5     6716.8    +5.5%   1.6%
light     gpu_raster_us        64.3       64.3       52.8       57.4   -14.3%   8.5%
light     gpu_as_us             0.4        0.4        0.4        0.4    -5.3%  10.6%
light     gpu_rt_us            67.4       67.7       67.8       67.8    +0.4%   0.5%
light     gpu_us              154.5      155.0      144.5      148.5    -5.3%   2.7%
medium    fps                 817.4      817.8      817.5      817.5    -0.0%   0.0%
medium    fps_timed           743.5      743.9      843.7      844.0   +13.5%   0.1%
medium    gpu_raster_us       619.5      619.8      462.6      462.9   -25.3%   0.1%
medium    gpu_as_us           161.2      160.7      158.7      158.1    -1.6%   0.4%
medium    gpu_rt_us           509.4      509.1      509.4      509.5    +0.0%   0.1%
medium    gpu_us             1342.9     1341.5     1183.2     1182.8   -11.9%   0.1%
solarbay  fps                 585.4      585.5      585.1      585.3    -0.0%   0.0%
solarbay  fps_timed           542.4      542.5      607.7      607.3   +12.0%   0.1%
solarbay  gpu_raster_us      1023.8     1024.0      820.0      821.2   -19.9%   0.1%
solarbay  gpu_as_us           203.0      203.1      211.5      209.7    +3.7%   0.9%
solarbay  gpu_rt_us           529.2      529.5      529.7      531.8    +0.3%   0.4%
solarbay  gpu_us             1839.5     1838.7     1643.2     1643.8   -10.6%   0.0%
heavy     fps                 306.8      306.8      306.4      306.6    -0.1%   0.1%
heavy     fps_timed           289.6      289.6      309.9      309.9    +7.0%   0.0%
heavy     gpu_raster_us      1441.3     1442.4     1201.4     1201.7   -16.7%   0.1%
heavy     gpu_as_us           299.6      300.1      316.3      316.0    +5.4%   0.2%
heavy     gpu_rt_us          1651.5     1652.0     1646.9     1647.8    -0.3%   0.1%
heavy     gpu_us             3447.9     3449.0     3220.4     3218.0    -6.6%   0.1%
extreme   fps                  59.3       59.6       59.4       59.6    +0.2%   0.5%
extreme   fps_timed            53.6       53.7       59.6       59.6   +11.1%   0.3%
extreme   gpu_raster_us      2673.7     2673.2      501.5      503.0   -81.2%   0.3%
extreme   gpu_as_us          2296.0     2303.5     2512.6     2552.0   +10.1%   1.6%
extreme   gpu_rt_us         13665.1    13615.8    13602.1    13578.9    -0.4%   0.4%
extreme   gpu_us            18725.2    18677.2    16704.9    16698.2   -10.7%   0.3%
light     render_slots active (max per round A1 B1 B2 A2): [2, 2, 2, 2]
medium    render_slots active (max per round A1 B1 B2 A2): [2, 2, 2, 2]
solarbay  render_slots active (max per round A1 B1 B2 A2): [2, 2, 2, 2]
heavy     render_slots active (max per round A1 B1 B2 A2): [2, 2, 2, 2]
extreme   render_slots active (max per round A1 B1 B2 A2): [2, 2, 2, 2]

other depths (both pairs in use; ordering checked above):
  light d4 fps B/A +0.0%
  medium d4 fps B/A +0.3%
  solarbay d4 fps B/A +0.0%
  heavy d4 fps B/A -1.9%
  extreme d4 fps B/A +0.2%

VERDICT FIX: B ordered correctly and faster (light d2 fps +18.4%, median fps_timed medium..extreme +12.0%)

(Full raw r4258.tgz archive kept locally if any per-frame JSON or raw log detail is needed.)

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review December 4, 2026 04:08
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 4, 2026 04:08
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merge evidence for c924253.

Two-pair hardware (J775c, M5 Max, G17C). satchlj's ABBA run of the peer kit (receipt above) gave VERDICT FIX. Only aurora.ko differed between the arms (A = main bd3112c, B = this patch, tree e6daa41fe0e1). rt.scene trace=query at d2: light fps +18.4 %, fps_timed medium..extreme +7.0..+13.5 %, and gpu_raster_us down 14..81 %. At d4, where both pairs are busy, fps stayed within 2 %. Ordering held: gpubench-stress-vk passed 5/5 in all four rounds. CTS renderpasses + synchronization gave 90,195 Pass / 56,364 Skip on both arms with 0 status diffs. There were no new GPU kernel errors.

One-pair queues (J714s M5 Pro, smaller M5, A18 Pro) behave as on main, so no J714s row is needed.

  • render_barriers is the only code that reads sibling_in_flight. Its caller passes pairs::per_owner(), and select_board sets that to 1 on boards with fewer than 4 clusters. On those boards ordered_partial && render_pairs > 1 && dependencies.sibling_in_flight is false whatever the flag holds, just as ordered_partial && render_pairs > 1 was on main. No other barrier looks at the flag, so the tiling and fragment barrier lists come out the same word for word.
  • The two new sibling_render_in_flight calls only read the registry under the device mutex. They don't write, allocate or fail. Loan carries one more bool.

Review. The direct path samples the siblings when it lends the pair, before it takes the render lock and gathers the attachment overlaps. That's safe because one queue's renders publish one at a time: the ioctl doesn't publish while the scheduler backlog is non-zero, and the scheduler thread releases the backlog only after render_packet returns. So no render of a sibling can appear between the sample and the overlaps. A lent sibling counts its borrowed_active and borrowed_replay snapshots, and a parked pair holds no work. I found no defects.

Against current main. Main 787efea is 37 commits past the PR base and includes #3390 (inline cross-engine publication) and #3411 (single-pair depth 64) in the same g17 files. Neither changes when a queue's renders publish or which pair count render_barriers sees. git merge-tree --write-tree 787efea4 c924253c merges cleanly to tree 7648650a43ec. On that tree (pc):

  • g17 host tests in the pinned image (rustc 1.96.0): 394/394 passed, and g17-render-partial-order killed all 13 mutations.
  • Warm module-only build (aurora_defconfig, LLVM, reflinked warm O=): main and the merge both build Image + modules. aurora.ko build-ids: main dae875ca7ff21f7013f2a5a4d1235a0d3fd41ec5, merge cc65172ee8ce611416a3cb65eea5965b63a17669. Going from main to the merge rewrote only the 6 files of this PR.
  • make W=1 drivers/gpu/drm/asahi/: 43 warnings on main and 43 on the merge, the same set, none in the touched code.

Main has since moved to ade5247, but those 12 commits don't touch drivers/gpu/drm/asahi/ or this PR's tools.

host tests: python3 -I tools/asahi/run-host-tests.py --jobs 8 --only g17-  -> 394/394 passed
            g17-render-partial-order-tests.py --mutation <each of 13>      -> 13/13 killed
build:      main 787efea4 Image+modules 776 s; merge tree 7648650a Image+modules 294 s (asahi objects 24)
W=1:        43 / 43 warnings, diff empty

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Merge readiness at c924253c: not ready yet

Check Detail
CI at head ok 12 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at c924253c
Conflicts ok none
PR text ok Risk: two-way · M5 Max / M5 Ultra (two-pair G17C/G17D) render ordering. One-pair queues are unchanged.

Areas: area:gpu

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

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 4, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merge check on current main: main 99ca7de1edd4 (with #4020) + head c924253c0a56 merges cleanly (tree 6c6d3a7bc13f). The g17 host tests pass 404/404 on that tree, including #4020's lazy-publication suite, and g17-render-partial-order catches all 13 mutations. The only file both PRs touch is tools/asahi/run-host-tests.py. Hardware: satchlj's J775c two-pair ABBA VERDICT FIX at this head. The one-pair path is unchanged (render_pairs > 1 is false there), so no J714s row is needed. Merging at this head; the only block left is the last-push approval, because the author is also the last pusher.

@DjDeveloperr
DjDeveloperr merged commit 35ddf94 into main Dec 4, 2026
14 of 16 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/g17-two-pair-idle-sibling-tiling branch December 4, 2026 04:11
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:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants