Skip to content

drm/asahi: g17: cut allocations and copies in the submit path - #2228

Merged
RyanTheTide merged 5 commits into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-submit-path-allocs
Nov 28, 2026
Merged

RyanTheTide merged 5 commits into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-submit-path-allocs

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What: Three changes that remove per-submit allocations and copies on the G17 submit path: reuse each queue's publication batch, keep the submit ioctl's command vectors in the queue (as KVVecs charged to the caller), and build each packet in its allocation. They don't change what is submitted or where it runs; per submit, allocations drop from 12 to 9.3 on the J616s.

Tested:

  • J616s M4 Pro (T6040), head 6e21fca49d00, in our m4.190 test kernel: aurora main 8c6bd8d1e806, plus drm/asahi: g17: kill a hung client's work instead of letting it take the GPU down #2504 at b731bf1a34b0, drm/asahi: g17: prune a queue's frontier from the front #2732 at 9cc1c8acf8bc and this PR. Booted 2026-11-25 15:43 UTC. Mesa is m4/next c356a1498.
    • dEQP-VK.synchronization{,2}.timeline_semaphore.*: 5,753/5,753 Pass at -j 1, with 0 GPU recoveries.
    • At -j 10, 455 cases fail in queueSubmit with VK_ERROR_OUT_OF_DEVICE_MEMORY. The cause is Mesa's lazy QUEUE_CREATE getting ENOSPC/EBUSY once ten processes use up the shared queue budget. It is not an allocation failure in this PR.
    • 0 invoked oom-killer and 0 page allocation failure.
    • Desktop session from boot to 16:27 UTC: 0 recoveries, 0 kernel lines at err level, 0 failed units (row).
  • J716c M5 Max (T6050, G17C B1, firmware 27.2), one-shot paired A/B of 6e21fca49d00 against base 15b1e2e0aaca, from erikwb (row):
    • gpubench-vk: 18/18 ok, with 0 GPU errors.
    • 15,028 timeline_semaphore cases match base.
    • 0 OOM or allocation failures.
  • Head 5c529c9e97e5 merges main b14959b819cf into 6e21fca49d00, and this PR's diff against main is unchanged. At that head: KUnit 853/854 (1 skipped), and every g17 host test passes.

Risk: two-way door · the G17 Macs: M4 (incl. Pro/Max), M5 and Neo (A18 Pro). A kept command vector stays at its largest size until the queue closes (at most 64 commands, about 96 KB per queue, vmalloc-backed and charged to the client's memory cgroup). Checked unaffected: the J616s (M4 Pro) and J716c (M5 Max).

Not yet: a Neo (A18 Pro) row. The submit ioctl's CPU time change can't be measured across boots (see Evidence).

Details
  • Reuse each queue's publication batch. Every publication allocated a DeferredBatch with room for two rings of completions: 64 entries, about 3.5 KB through kvmalloc. It freed the batch when the publication ended, so the direct compute and render paths did a kvmalloc and a kvfree in every submit ioctl.
    • The backend now keeps the batch of its last finished publication and lends it to the next one.
    • A batch that still holds work is dropped as before.
    • Concurrent publishers of one queue each get their own batch, and the first one back is kept. A new batch is allocated without the spare's lock held.
  • Keep the submit ioctl's command vectors in the queue. prepare_submission collected the validated commands and their VM pins in two vectors allocated and freed by every ioctl. The queue now keeps both, empty between ioctls. Whatever an error leaves unsubmitted is released at the same point as before.
    • Both are KVVecs charged to the caller (GFP_KERNEL_ACCOUNT, amended 11-22). The trigger was an order-3 GFP_KERNEL OOM kill under deqp-vk, from this vector's krealloc() in prepare_submission. 64 commands of about 1.5 KB need an order-3 block at 16K pages, and with compaction off in our kernel that allocation went to the OOM killer five times in one run, with 26 GB available. A large vector now falls back to vmalloc. It is freed with the queue, which may sleep. drm/asahi: g17: keep userspace-sized submit vectors off contiguous pages #2858 makes the same change for the code as it is on integration/aurora (the per-ioctl vectors there), plus the dependency and merge vectors this PR doesn't touch.
  • Build each packet in its allocation. Packet::new built the packet, with its 1.3 KB validated command, on the stack and then moved it into the Arc. The compiler kept three stack copies of the command for that. The packet is now allocated first and initialised in place, so the command is copied once. (Arc::init(init!(..)) and Arc::try_init(try_init!(..)) were tried: both compile but grow Packet::new's frame from sub sp, #0x4f0 to #0xd20 and its memcpy calls from 4 to 7.)

Known limit: a kept vector stays at its largest size until the queue closes: at most 64 commands, about 96 KB per queue. It needs no contiguous pages and is charged to the client's memory cgroup.

Evidence

J616s (M4 Pro, 48 GiB, 25G83), daily kernels since 11-18

Before and after are separate boots, compared with gpubench and kmem tracing, with 0 GPU recoveries. The one result that holds across boots is the allocation count.

Allocations (kmem trace, compute.light pinned at depth 1, 139 submits). Per submit, 12 before (11 kmalloc + 1 kmem_cache_alloc) and 9.3 after. The per-ioctl temporaries are gone: the DeferredBatch publication (4096 B), and prepare_submission's pending vector (2048 B) plus its VM-guard vector (192 B). What is left is objects that outlive the ioctl, plus a drm_exec in 2% of submits.

Submit ioctl CPU time, compute.light, in us at depth 1 / 8 / 64. Only rows with the same P-cluster frequency floor compare:

Run Before After
Hardware-minimum floors (1.26 GHz), unpinned 11.0 / - / 4.92 16.29 / - / 6.00
P floors 4.5 GHz, unpinned 9.50 / - / - 10.17 / 8.58 / 4.67
P floors 4.5 GHz, pinned to cpu5 - 9.75 / 7.54 / 4.25
P floors 2.35 GHz, pinned to cpu5 8.75 / 7.58 / 7.71 13.31 / 8.04 / 4.58
P floors 2.35 GHz, pinned to cpu11 10.38 / 8.21 / 6.62 13.93 / 9.12 / 6.81

So the change in submit CPU time is not measurable across boots: depth 64 is lower on cpu5, level on cpu11 and higher unpinned. The differences follow each boot's cluster load, not this code. The same floor gave 8.75 and 13.31 us at depth 1 on the two boots. Depth 1 is set by core type, cluster and frequency, which #2217 and #2222 address. What these commits measurably do is remove three per-submit allocations.

Not an A/B for these commits:

Regression row, combined kernel 7.3.0-m4.179 (previous head 1c3306581218)

integration/aurora bf423bf plus our other open G17 PRs, not a standalone kernel. Boot 2026-11-22 23:51 UTC to 2026-11-23 01:43 UTC (desktop, other GPU tests, our dEQP-VK and GLES runs), default cmdline: 0 kernel lines at err level (same as m4.178), 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.

The 7 synchronization.timeline_semaphore.{one_to_n,wait_before_signal}.write_blit_image_read_{blit,copy}_image.* cases that hit order-3 OOM kills from prepare_submission on m4.177: 3 rounds at -j 2, 21/21 Pass, 0 invoked oom-killer. This kernel has compaction enabled (our m4.177 config had it off), so the row says nothing about the KVVec change in 9c73f8ef6beb.

On this branch

KUnit: 698 tests, 697 pass, 1 skip (needs CONFIG_UCLAMP_TASK), including the new a_publication_batch_comes_back_only_when_idle. tools/asahi/run-host-tests.py --only g17 90/90. checkpatch 0 errors on all three commits. git diff 1c3306581218 9c73f8ef6beb touches only Scratch's declaration, its doc comment and the three reserve/push calls.

Every publication allocated a DeferredBatch with room for two rings of
completions (64 entries, about 3.5 KB through kvmalloc) and freed it when
the publication ended: on the direct compute and render paths this was a
kvmalloc and a kvfree in every submit ioctl.

The backend now keeps the batch of its last publication once it is
finished and lends it to the next one. A batch that still holds work is
dropped as before, and concurrent publishers of one queue (the two
engines' scheduler workers and the ioctl) each get their own: the first
one back is kept. The batches are created and used exactly as before.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
@jgoyvaerts
jgoyvaerts force-pushed the m4pro/g17-submit-path-allocs branch from 954fc9b to 1c33065 Compare November 21, 2026 06:14
@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 954fc9be6f (git diff 954fc9be6f 1c33065812 is empty). New head 1c33065812.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Looks good; approve once the HW row below is in.

I checked the three changes. PublicationBatch (drivers/gpu/drm/asahi/g17/runtime.rs:917-925, 1586-1597) takes the spare before allocating, so nothing is allocated under the mutex. It returns a batch only when is_idle() holds, after finish() has drained every vector and cleared has_source_completions, and it is dropped at the end of each publisher with no other lock held. No path replaces a lent batch's vectors, so the room checks (render/tvb/vacated) behave as before. In queue/mod.rs the scratch vectors are taken out of the queue for the ioctl and cleared before finished.clear(), the same point the old vectors were dropped, and the VM pins now outlive the leftover commands on the error path. Packet::new keeps its error behaviour.

  1. Nit: drivers/gpu/drm/asahi/g17/job.rs:154-169 can be a single Arc::init(init!(Self { ... }), GFP_KERNEL), like the Arc::pin_init users elsewhere in g17. That drops the UniqueArc round trip and the irrefutable let Ok(..).

HW row: one more G17 Mac other than the J616s (M4 or M5) on a kernel with only these commits on top of integration/aurora: gpubench compute/render rows plus a deqp-vk subset with no new failures and 0 GPU recoveries, and a regression row on the J616s (0 SELinux denials, 0 failed units, 0 new kernel errors).

Assisted-by: LLM (Claude:Opus 5.5)

@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

I tried the nit and left the code as it is; the head stays 1c33065812.

With the arm64 defconfig + asahi.config build (LLVM=1), both Arc::init(init!(Self { ... }), GFP_KERNEL) and Arc::try_init(try_init!(...), GFP_KERNEL) compile cleanly, but they make Packet::new worse. The stack frame grows from sub sp, #0x4f0 to #0xd20, and memcpy calls go from 4 to 7. The InPlaceInit path moves the initializer, together with the ~1.3 KB command it captured, through extra closures by value. That brings back the copies this commit removes, so job.rs:154-169 keeps UniqueArc::new_uninit + init_with.

The J616s regression row will follow the next kernel build of our tree. We'd take your offer to run the other G17 Mac row (M4 or M5) in your lab.

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.

Adversarial review at 1c3306581218 against the pre-PR checklist.

No code, CI, attribution, or policy blockers found:

  • CI & Attribution/Policy (§1–§4, §6): host-tests is green on 1c3306581218; all three commits carry human author/committer and human Signed-off-by: only; PR body disclosure is clean; no model gating or naming issues.
  • PublicationBatch reuse (drivers/gpu/drm/asahi/g17/runtime.rs:917-925, 1429-1436, 1571-1597): spare_batch is a leaf mutex never held across allocation (DeferredBatch::publication()?), kvfree (when a competing batch drops because *spare is already populated, the guard drops before batch), or shared.state. DeferredBatch::is_idle() checks every field (has_source_completions, values, bindings, vacated, render, tvb), and reserve_replays is never called on a publication batch so lent capacities stay bounded.
  • Queue scratch vectors (drivers/gpu/drm/asahi/g17/queue/mod.rs:108-115, 447-530, 587-645): Moving self.scratch out with core::mem::take and clearing pending then guards before restoring self.scratch preserves error-path cleanup semantics. (If outputs.publish() fails after guards.drain_all(), guards drains before scratch.pending.clear(), which matches the pre-existing guards.into_iter() drop order.)
  • In-place Packet::new (drivers/gpu/drm/asahi/g17/job.rs:152-169): UniqueArc::new_uninit + init_with(init!(...)) is sound, avoids the Arc::init closure-move stack/memcpy regression you measured under LLVM=1, and preserves allocation-failure cleanup.

Remaining before approval (§5)

  • Clean same-head HW & regression run on J616s (default command line, without the unrelated tiler-heap PRs / unincluded 4th patch noted in the PR body): 0 SELinux denials, 0 failed units, 0 new kernel errors, 0 GPU recoveries.
  • One additional G17 Mac (M4 or M5) on top of integration/aurora with gpubench + a deqp-vk subset showing no new failures and 0 GPU recoveries.

prepare_submission collected the validated commands and their VM pins in
two vectors allocated by every submit ioctl and freed at its end.

The queue now keeps both, empty between ioctls, so their room is allocated
once. Commands are drained from them in the same order, and whatever an
error leaves unsubmitted is released at the same point as before.

Neither needs contiguous pages, and `pending` is large: up to 63
commands of over a kilobyte each come to an order-3 block. As KVecs
that block was a GFP_KERNEL krealloc() that, on a machine without
compaction, ended in the OOM killer during dEQP-VK runs. Keep them in
KVVecs, so a large one falls back to vmalloc(), and charge them to the
caller's memory cgroup (GFP_KERNEL_ACCOUNT), since each userspace
queue keeps its own. They are freed with the queue, which may sleep.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
Packet::new built the packet, with its 1.3 KB validated command, on the
stack and moved it into the Arc. The compiler kept three stack copies of
the command for that, so every submitted command was copied four times
here.

Allocate the packet first and initialise it in place: the command is
copied once. A failed allocation still drops the command unpublished.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

@RyanTheTide, an amendment you should know about: new head 9c73f8ef6beb (was 1c3306581218), force-pushed.

The trigger was an order-3 GFP_KERNEL OOM kill under deqp-vk on the J616s. The OOM killer fired five times in one dEQP-VK run, from prepare_submission+0x690 → krealloc() → __kmalloc_large_node, while 26 GB was available. That's the pending vector: 64 commands of about 1.5 KB need an order-3 block at 16K pages. Our kernel had compaction off (our config, fixed separately), so that allocation was never allowed to fail and went to the OOM killer instead.

What changed:

  • Commit 2, "keep the submit ioctl's command vectors in the queue": Scratch::{pending, guards} are now KVVec, with GFP_KERNEL_ACCOUNT on their reserve/push. The change is folded into the commit that introduces Scratch, so the new code is right when it lands rather than fixed in a follow-up. The commit message says why.
  • Freeing: both are freed with the queue, which may sleep, so the vmalloc fallback is safe there.
  • Commits 1 and 3: unchanged. Commit 1 keeps its hash 98e9ab5b4753; commit 3 is only rebased. git diff 1c3306581218 9c73f8ef6beb touches only Scratch's declaration, its doc comment and the three reserve/push calls.

The same problem exists on integration/aurora as it is, where those vectors are still allocated per ioctl. The per-command dependency/checked-input/firmware lists and the merge arrays have it too. #2858 fixes those on its own, so it can land with or without this PR. Whichever lands second resolves a few lines in prepare_submission.

KUnit: 698 tests, 697 pass, 1 skip. Host tests --only g17 90/90. checkpatch 0 errors on all three commits. The hardware rows you and Dj asked for are still to come.

Assisted-by: LLM (Claude:Opus 5.5)

@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

J616s (M4 Pro, 48 GiB, 25G83) regression row from our combined m4.179 kernel (integration/aurora bf423bf plus our other open G17 PRs), not a standalone kernel. It carries this PR at the previous head 1c33065 (all three commits patch-id equal), not 9c73f8e: its commit 2 is still the KVec version.

  • Boot 2026-11-22 23:51 UTC to 01:43 UTC (desktop, other GPU tests, our dEQP-VK and GLES runs), default cmdline: 0 AVC denials, 0 failed units, 0 kernel lines at err level (same as m4.178), 0 GPU recoveries. The window ends where a deliberate GPU hang test for another PR started.
  • The 7 synchronization.timeline_semaphore.{one_to_n,wait_before_signal}.write_blit_image_read_{blit,copy}_image.* cases that hit order-3 OOM kills from prepare_submission on m4.177: 3 rounds at -j 2, 21/21 Pass, 0 invoked oom-killer. This kernel has compaction enabled (our m4.177 config had it off), so the row says nothing about the KVVec change in 9c73f8e.

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.

Formal §1–§6 pre-PR checklist re-review at 9c73f8ef6beb34a58a8c9a31cf02d76d675dcb0d (host-tests: green; mergeStateStatus: CLEAN; not superseded on integration/aurora).

Code, Safety & Attribution Assessment (0 code blockers)

  • PublicationBatch reuse (98e9ab5b4753, drivers/gpu/drm/asahi/g17/runtime.rs, runtime/backend.rs, runtime/render/submit.rs): spare_batch is a leaf mutex never held across allocation (DeferredBatch::publication()?) or kvfree (competing drops release the mutex guard before dropping batch), is_idle() verifies has_source_completions and all 5 vectors are empty, and reserve_replays() is never called on lent publication batches so reused capacity remains bounded.
  • Queue Scratch vectors (6408757ed87c, drivers/gpu/drm/asahi/g17/queue/mod.rs): Amending Scratch::{pending, guards} to KVVec with GFP_KERNEL_ACCOUNT avoids high-order contiguous allocation failures on 64-command submissions and charges retained per-queue capacity to the caller's memcg. Both are cleared unconditionally before restoring self.scratch and freed in sleepable context when Queue drops; Validated and Destinations hold host-side references only, so error-path cleanup order is sound.
  • In-place Packet::new (9c73f8ef6beb, drivers/gpu/drm/asahi/g17/job.rs): UniqueArc::new_uninit + init_with(init!(...)) is sound, preserves allocation-failure cleanup, and avoids the LLVM=1 Arc::init closure-move stack/memcpy regression.
  • §1–§4, §6: Pass — no model gating, default command line, all 3 commits carry human author/committer (Jonathan Goyvaerts <[email protected]>) and human Signed-off-by: only (zero AI commit trailers), Assisted-by: at end of PR body, host-tests green, KUnit 697/698 pass (1 skip).

§5 Blocker Holding APPROVE / MERGETRAIN-LINUX4

  • No exact-head hardware run for 9c73f8ef6beb: The 2026-11-23 J616s regression row ran the earlier 1c3306581218 KVec revision inside the combined m4.179 kernel rather than 9c73f8ef6beb's KVVec + GFP_KERNEL_ACCOUNT commit 2, and no second G17 Mac row has been run yet.
  • Required before approval:
    1. Clean exact-head (9c73f8ef6beb on integration/aurora, default cmdline, without unrelated PRs) J616s hardware + regression row (gpubench + dEQP-VK cases including the synchronization.timeline_semaphore.* cases exercising Scratch KVVec, 0 OOM / allocation failures, 0 GPU recoveries, 0 SELinux denials, 0 failed units, 0 new kernel errors).
    2. One additional G17 Mac row (M4 or M5) on top of integration/aurora with gpubench + a dEQP-VK subset showing 0 new failures and 0 GPU recoveries.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (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-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 5c529c9e: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 5c529c9e, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · the G17 Macs: M4 (incl. Pro/Max), M5 and Neo (A18 Pro). A kept command vector stays at its largest size until the queue closes (at most 64 commands, about 96 KB per queue, vmalloc-backed and charged to the client's memory cgroup). Checked unaffected: the J616s (M4 Pro) and J716c (M5 Max).

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 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) merge-conflict Conflicts with the base branch (bot) and removed blast:none Macs affected, from Merge risk (bot) labels Nov 24, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Nov 25, 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 9c73f8ef6beb: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: commit 2 changed after the booted 1c330658 (it was the KVec/GFP_KERNEL version), so one J616s boot at this head with the timeline-semaphore cases and a short desktop run is needed.

Because this G17 path is shared by M4, M5 and the Neo, it also needs one M5 or Neo run at this head before it merges.

Checked: no Apple material, no gates. spare_batch is a leaf mutex never held across an allocation. Host tests green.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 25, 2026 02:40

Superseded by the review at 9c73f8e

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@jgoyvaerts
jgoyvaerts requested a review from a team as a code owner November 25, 2026 03:41
@jgoyvaerts
jgoyvaerts requested a review from LiamRay11 November 25, 2026 03:41
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Merged main 15b1e2e0aaca into the branch; the new head is 6e21fca49d00, a plain push on top of 9c73f8ef6beb.

The one conflict was in g17/queue/mod.rs submit(). Main now records whether the submission has a render command (has_render, also used for its new compute_only). This branch fills the queue's kept Scratch instead of taking pending and guards by value. I kept both: has_render and compute_only are computed from the borrowed scratch.pending, and the drains and the error-path clear are unchanged.

No behaviour change from the resolution: the merge's diff against main is line-for-line the PR's diff against its old base.

Checks at the new head: asahi/SEP/ISP KUnit 797/798 (1 skip), and all 93 g17 host tests pass. The g15, DCP, M3-uAPI and SEP host tests fail on this machine on plain main too: they want a rustup 1.93.1 toolchain it doesn't have.

Still open: the J616s boot at this head (timeline-semaphore cases plus a short desktop run) and one M5 or Neo row.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Hardware row for @DjDeveloperr's request at 9c73f8ef, at the current head 6e21fca49d00.

Kernel: our m4.190 test kernel on a J616s (M4 Pro, T6040). It is aurora main 8c6bd8d1e806 with #2504 (b731bf1a34b0), #2732 (9cc1c8acf8bc) and this PR (6e21fca49d00) merged in, plus our carried patches. This PR merged unchanged; its only conflict is the one line against #2732 described on the PR-status note (guards.drain_all() after #2732's reserve block). The Mesa is unchanged from earlier rows (m4/next c356a1498).

Timeline semaphores: all 5,753 dEQP-VK.synchronization{,2}.timeline_semaphore.* cases in mustpass, through dq-fast: 5,753/5,753 Pass, with 0 GPU recoveries.

  • At -j 10, 5,298 passed and 455 failed in queueSubmit with VK_ERROR_OUT_OF_DEVICE_MEMORY. In this Mesa, that comes from creating the kernel queue lazily at first submit, which gets ENOSPC/EBUSY from QUEUE_CREATE. Ten parallel dEQP processes, each with several queues, exhaust the shared queue budget. I read that from Mesa's code and didn't trace it.
  • All 455 pass at -j 1. None of them is a submit refusal (that would be device-lost) and none involves this PR's allocations.
  • The 28 one_to_n/wait_before_signal blit/copy cases that hit order-3 OOM kills on m4.177 also ran 2 extra rounds at -j 2: 56/56 Pass.
  • invoked oom-killer: 0. page allocation failure: 0.

Desktop session: the owner's normal Hyprland desktop on m4.190, from boot (2026-11-25 15:43 UTC) to 16:27 UTC, with these suites and our other G17 runs on top: 0 GPU recoveries, 0 kernel lines at err level, 0 WARN/Oops/SError, 0 failed units (system and user). No SELinux/AppArmor loaded (0 avc: lines).

Not covered: M4, M4 Max and M5, and a longer soak.

@erikwb

erikwb commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Verdict: FINISH, then merge at 6e21fca49d00

Blockers:

  1. PR body **Tested:** and **Not yet:** still cite stale head 9c73f8ef6beb and list J616s as pending: please update **Tested:** at 6e21fca49d00 with the J616s row from the earlier comment (naming the combined kernel composition 8c6bd8d1e806 + #2504 + #2732 + #2228, the 5,753/5,753 serial timeline_semaphore pass vs the 455 -j 10 VK_ERROR_OUT_OF_DEVICE_MEMORY failures from lazy QUEUE_CREATE exhausting the shared queue budget, and 0 OOM/alloc failures) and this J716c row, and update **Not yet:** accordingly.

Checked: code diff against 15b1e2e0aaca (preserves has_render and compute_only across the g17/queue/mod.rs merge resolution with scratch.pending borrowed, guards.drain_all(), and error-path clear intact; UniqueArc::new_uninit + init_with in g17/job.rs; idle-only PublicationBatch reuse in g17/runtime.rs, runtime/backend.rs, and runtime/render/submit.rs; no Apple material, no model/chip/board/firmware gates, no new cmdline/module params, no AI attribution in commits; CI 3/3 pass), and J716c (M5 Max / T6050 / G17C B1, GPU fw 27.2) paired one-shot trial A/B at exact head 6e21fca49d00 vs exact base 15b1e2e0aaca (default cmdline): gpubench-vk 18/18 ok with 0 GPU errors; dEQP-VK.synchronization.*.timeline_semaphore.* + synchronization2.*.timeline_semaphore.* (15,028 cases, 6 shards) matches base (14,997 Pass / 8 NotSupported / 8 DeviceLost / 15 Fail, 34 GPU-error lines vs base 14,995 Pass / 8 NotSupported / 6 DeviceLost / 19 Fail, 32 GPU-error lines; a fleet candidate carrying #2228 + #3174 gives 15,001 Pass / 8 NotSupported / 1 DeviceLost / 18 Fail, 10 GPU-error lines — pre-existing flaky/base failures, not introduced by #2228); 0 OOM/alloc failures, 0 AVC (SELinux N/A), only pre-existing failed units and boot err lines.

Evidence

Environment (J716c)

  • Hardware / firmware: Apple M5 Max (T6050 / J716c, G17C B1), GPU firmware 27.2 (26B123), Stage 2 1.0.0b17-gae94218e.
  • Kernel command line (default): ... arm64.nomte aurora.mem_limit_pct=90 aurora.client_mem_limit_pct=85 mem_sleep_default=s2idle user4k=on.
  • Userspace: Borealis (libvulkan_asahi.so, apiVersion 1.4.363) built from aurora-wip 262403b7bce1 (-Doptimization=2 -Ddebug=false -Db_ndebug=false).
  • SELinux: not built in kernel (N/A; 0 AVC lines in dmesg across all windows).

Commands run

gpubench-vk quick set on exact head 6e21fca49d00 (GB_WARMUP_MS=100 GB_RUNS=3 GB_RUN_MS=200 GB_TIMED_RUNS=2):

for spec in \
  "submit.empty --depths 1,8" \
  "compute.light --depths 1,4,16" \
  "compute.heavy --depths 1,4 --param kind=alu" \
  "compute.heavy --depths 1,4 --param kind=bw" \
  "render.light --depths 1,4,8 --param kind=tri" \
  "render.light --depths 1,8 --param kind=clear" \
  "render.heavy --depths 1,4 --param kind=fill --param res=1080p" \
  "sync.signal --param kind=queue --param sema=timeline" \
  "mem.buffer"; do
  set -- $spec; t=$1; shift
  gpubench-vk --test "$t" "$@"
done

Result at 6e21fca49d00: 18/18 rows ok (0 non-ok, 0 GPU-error lines in window).

deqp-vk timeline semaphore suite (15,028 cases from vk-default mustpass matching dEQP-VK.synchronization.*.timeline_semaphore.* and dEQP-VK.synchronization2.*.timeline_semaphore.*, 6 shards, cold shader cache per run, MESA_SHADER_CACHE_MAX_SIZE=4G):

deqp-vk --deqp-caselist-file=<shard-list> --deqp-log-filename=<shard.qpa> \
  --deqp-log-images=disable --deqp-log-shader-sources=disable \
  --deqp-surface-type=pbuffer --deqp-terminate-on-fail=disable --deqp-log-flush=enable

A/B results (15,028 cases, identical Borealis 262403b7bce1)

Kernel Contains Pass NotSupported DeviceLost Fail Wall Non-audit dmesg lines GPU-error lines AVC
Exact base 15b1e2e0aaca no #2228, no #3174 14,995 8 6 19 400 s 74 32 0
Exact head 6e21fca49d00 #2228, no #3174 14,997 8 8 15 426 s 81 34 0
Combined candidate 16e42e07bef5 main + #3174 + #2228 + #2715 + #3085 + #3084 (partial) 15,001 8 1 18 491 s 21 10 0
  • The Fail cases are signal_order.timeline_semaphore.write_image_* and vary run to run (3 names shared between base and head, 0 shared across all three runs).
  • The DeviceLost cases are multi_queue.timeline_semaphore.* (plus 1 implicit.timeline_semaphore.write_copy_buffer_read_ssbo_vertex.buffer_16384.1113 on the head run) and emit the same kernel log signature on base and head (G17 capacity refusal ComputeReserve, watchdog gave up on a render/compute command ... Defer behind earlier work of another VM, and recovery: GPU MMU fault: write reason 0). Adding #3174 drops DeviceLost from 6–8 to 1.
  • Whole-boot health at 6e21fca49d00: Hyprland desktop up; 0 OOM/alloc failures; 0 AVC; boot err+ lines limited to the 2 pre-existing systemd-gpt-auto-generator lines (plus the pre-existing MMU fault recovery lines during the timeline CTS window); failed units limited to pre-existing aurora-peripherals.service at boot (systemd-networkd-wait-online.service after CTS).

Diff & CI at 6e21fca49d00

  • git diff 15b1e2e0aaca..6e21fca49d00 modifies 5 files: drivers/gpu/drm/asahi/g17/job.rs, drivers/gpu/drm/asahi/g17/queue/mod.rs, drivers/gpu/drm/asahi/g17/runtime.rs, drivers/gpu/drm/asahi/g17/runtime/backend.rs, drivers/gpu/drm/asahi/g17/runtime/render/submit.rs.
  • GitHub CI: host-tests (SUCCESS), readiness / readiness (SUCCESS), pr-text / pr-text (SUCCESS); readiness (SKIPPED).

@RyanTheTide

Copy link
Copy Markdown
Contributor

This branch conflicts with main again. Please merge main in with a normal push (no force push), together with any open review fixes. If we hear nothing within 24 hours, a maintainer will do the forward merge so the review can continue.

Conflicts, and how they were resolved:

- g17/queue/mod.rs submit(): main (aurora-silicon#2732) reserves room for every
  command's frontier and publisher entry before queuing, then takes the
  guards with into_iter(). The reservation is kept, and this branch's
  guards.drain_all() follows it, so the per-queue scratch vector keeps
  its allocation.
- g17/runtime.rs Backend: main's compute_channels and this branch's
  spare_batch fields are both kept, in the struct and in new().

No behaviour changes: the branch's diff against main is unchanged.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
@jgoyvaerts
jgoyvaerts requested review from a team as code owners November 26, 2026 13:21
@jgoyvaerts
jgoyvaerts requested a review from maralcbr November 26, 2026 13:21
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Merged main b14959b819cf into the branch, pushed normally: new head 5c529c9e97e5, on top of 6e21fca49d00.

Conflicts:

  • g17/queue/mod.rs submit(): main (drm/asahi: g17: prune a queue's frontier from the front #2732) now reserves room for every command's frontier and publisher entry before queuing. That reservation is kept, and this branch's guards.drain_all() follows it (the one-line overlap noted earlier).
  • g17/runtime.rs Backend: main's compute_channels and this branch's spare_batch are both kept.

No behaviour change: the branch's diff against main is line-for-line the same as at 6e21fca49d00. At the new head, KUnit (arm64) runs 854 tests: 853 pass and 1 is skipped. Every g17 host test passes. The 29 local host-test failures are toolchain-only and also fail on plain main here.

@erikwb, thanks for the J716c row. Tested and Not yet now carry it together with the J616s row at 6e21fca49d00, and Risk lists both Macs.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 26, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 5c529c9e

Blockers: none (re-run the cancelled pr-text check and wait for the 3 queued unrelated KUnit jobs to finish green before landing).

Checked:

  • drivers/gpu/drm/asahi/g17/job.rs: UniqueArc::new_uninit(GFP_KERNEL) + init! constructs Packet in place, eliminating stack copies of the ~1.3 KB command payload.
  • drivers/gpu/drm/asahi/g17/queue/mod.rs: Scratch (pending + guards KVVecs charged via GFP_KERNEL_ACCOUNT) is taken from self.scratch, drained on enqueue, and explicitly cleared before returning to self.scratch on both success and error paths; conflict resolution at 5c529c9e preserves #2732 frontier/publisher room reservation.
  • drivers/gpu/drm/asahi/g17/runtime.rs, runtime/backend.rs, runtime/render/submit.rs: PublicationBatch<'a> Drop returns the batch to spare only when batch.is_idle(), dropping non-idle batches safely; unit test a_publication_batch_comes_back_only_when_idle verifies all three cases.
  • Hardware rows & tests: net diff is line-for-line identical to 6e21fca4 (tested on both J616s M4 Pro and J716c M5 Max); arm64 KUnit 853/854 pass (1 skip) at 5c529c9e; 17/21 CI green (MERGEABLE on main).
  • Checked for Apple material, tool attribution, private serials, and gating: clean; human Signed-off-by present.
Evidence
  • Head: 5c529c9e97e5 (base: main, mergeable: MERGEABLE, +130/-23 across 5 files).

@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at 5c529c9e. App approved at this head. The net diff is identical to the tested 6e21fca4 (J616s + J716c rows), with 853/854 KUnit passing. It merges in 1 h under the 6-point rule once the remaining hosted checks finish, unless you object.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at 5c529c9e. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J616s+J716c;net-diff-identical-to-6e21fca4. (5) There's no blocking review. (6) Dj was pinged here 61 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 8973cea into aurora-silicon:main Nov 28, 2026
26 of 56 checks passed
jgoyvaerts added a commit to jgoyvaerts/linux that referenced this pull request Nov 28, 2026
Conflicts, and how they were resolved:

- g17/queue/mod.rs, prepare_submission(): main (aurora-silicon#2228) keeps pending
  and guards in the per-queue Scratch, already KVVec and charged with
  GFP_KERNEL_ACCOUNT. Main's version is taken; this branch's local
  KVVecs and the ValidatedBatch alias go.
- g17/queue/mod.rs, enqueue(): main (aurora-silicon#3119 and the timestamp overlap
  work) builds the producer waits in EnqueueOrdering and feeds the
  firmware-ordered ones through ProducerWaits. Main's logic is taken;
  dependencies, checked_inputs and firmware become KVVecs charged with
  GFP_KERNEL_ACCOUNT, as this branch did for the old loops.

job.rs, sync_input.rs and sync_input.c merged without conflicts.

No behaviour change beyond this branch's: which fences each command
waits for, checks and hands to firmware is main's; only where the
vectors that hold them are allocated, and who is charged, changes.

Signed-off-by: Jonathan Goyvaerts <[email protected]>
RyanTheTide added a commit that referenced this pull request Nov 29, 2026
main's #2228 builds the g17 packet in its allocation; the two fields
this branch adds (forfeited, first_excuse) move into the new in-place
initialiser. The forfeit logic is unchanged.

Signed-off-by: Ryan Murray <[email protected]>
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) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (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.

4 participants