Skip to content

drm/asahi: g17: keep userspace-sized submit vectors off contiguous pages - #2858

Merged
RyanTheTide merged 13 commits into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-submit-kvvec
Dec 5, 2026
Merged

RyanTheTide merged 13 commits into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-submit-kvvec

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What: Keep the G17 submit path's userspace-sized vectors (the per-command dependency and ordering lists, the publication links, the merge arrays) off contiguous pages and charge them to the caller, after an order-3 GFP_KERNEL OOM kill under deqp-vk. The per-ioctl commands and VM pins already got this in main with #2228.
Tested: J616s (M4 Pro), our m4.201 test kernel = main a851ca0edfc9 + our carried patches + this change backported (not this head itself): dEQP-VK.synchronization{,2}.timeline_semaphore.* 5,753/5,753 Pass; 0 OOM kills, 0 page allocation failures, 0 GPU recoveries; a kmem:mm_page_alloc probe shows 0 asahi order >= 2 allocations that could reach the OOM killer (none from the submit path); compaction is on in that kernel. Cyberpunk 2077 A/B, J616s, each kernel = main a851ca0edfc9 + our carried patches + this change backported (not this head itself): links charged per KBox (m4.201) 18.5-19.2 fps, memcg slab hooks 0.35-0.40% of samples; links uncharged (m4.202) 20.0-21.0 fps, hooks 0.04-0.05%; links in one charged block with the might_sleep() guard (m4.205, the backport of edade58c698e + 25ac1dfa71be; 8 profiled + 3 traced launches, 0 recoveries, 0 client failures) 24.6-25.9 fps, frame p50 38.5-40.6 ms, hooks 0.055-0.077%. So the one charge per job costs ~0.02 percentage points of samples and no frame rate against the uncharged links; m4.205 also carries other G17 changes against m4.202 (pooled fences, a per-queue pending cap, others), so its fps gain belongs to that kernel, not to this PR. At 25ac1dfa71be: KUnit (arm64 qemu, asahi + SEP + ISP config) 930 tests: 929 pass, 1 skip, including the new link-block cases (red on the per-link code; allocating per link again or dropping __GFP_ACCOUNT fails them); the same KUnit with CONFIG_DEBUG_ATOMIC_SLEEP=y runs with 0 "sleeping function called from invalid context" reports, and dropping a link block under a spinlock reports one from LinkBlock's drop; tools/asahi/run-host-tests.py: all 251 g17 entries pass, and the 29 failures are the set that fails on plain main in this environment; checkpatch clean.
Risk: two-way door · M4, M4 Pro, M4 Max and M5 (shared G17 code)
Not yet: a row at this head on current main; the dEQP-VK run with CONFIG_COMPACTION off; the M4, M4 Max and M5 rows; and a cap on pending commands per queue: none exists here, so charging bounds this memory only under a memcg limit (the cap is #3602)

Details

Trigger: an order-3 GFP_KERNEL OOM kill under deqp-vk. On a J616s (M4 Pro, 16K pages) the OOM killer fired five times in one dEQP-VK run, from the submit ioctl, while 26 GB was available. It killed unrelated processes:

deqp-vk invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=3
 krealloc_node_align_noprof+0x154/0x238
 rust_helper_krealloc_node_align+0x10/0x20
 ..._asahi_core3g175queue...18prepare_submission+0x690/0xd8c [asahi]
 ..._asahi_core3g175queue...6submit...

That kernel had CONFIG_COMPACTION off, which is our own config and is being fixed there. With nothing to compact, an order <= 3 allocation is never allowed to fail, so it ends in the OOM killer. Compaction makes order 3 recoverable, but the driver still shouldn't need physically contiguous memory per submit for data userspace sizes.

What userspace sizes, and what changes

Vector Sized by Change
prepare_submission's pending and guards up to 64 commands per ioctl (MAX_COMMANDS_PER_SUBMISSION), each (Validated, Order, Destinations) over 1 KB, which needs order 3 already KVVec in main's per-queue Scratch (#2228)
each command's dependencies, checked_inputs, firmware the command's inputs plus the other engine's unfinished prefix, which can be thousands KVVec
Packet::{inputs, firmware} the same lists, kept by the job KVVec
EnqueueOrdering's predecessors, host waits, firmware waits and inherited timestamp waits; Fences::timestamp_waits the covered prefixes of both engines, pushed one at a time from empty KVVec
the publication's links one per covered unfinished predecessor one KVVec block per command, owned by its publication (see below)
sync_input::merge()'s pointer array the dependency count KVVec
asahi_g17_merge_fences()'s cursor array the dependency count kvmalloc_array() / kvfree()

All of them use GFP_KERNEL_ACCOUNT, so a client that submits huge batches or waits on huge prefixes is charged in its own memory cgroup, which is their bound. The links are the same kind of per-job state as the job's fence vectors: a command behind a stalled predecessor adds one link, and one fence, per covered unfinished publication, so nothing but the memcg caps them. Charging one KBox per link put memcg's slab hooks on every submit and on the event work that frees links (measured above), so a command's links are one block, charged once, that its publication owns: it publishes only after every predecessor has consumed its link, and each link holds the publication until then. kvmalloc still tries kmalloc first, so small sizes keep their current memory.

vfree() context. A vmalloc'ed vector must be freed where vfree() may sleep.

  • The command, dependency and merge vectors are freed in the ioctl.
  • EnqueueOrdering is freed in the ioctl. A command's link block is freed with its publication, which drops where its Completion, frontier entry or last link does: the ioctl, the queue's teardown, drm_sched's free_job and kill work, or the event work through Deferred::finish(). None of them holds a spinlock, has interrupts disabled or is in an RCU read side; the hard interrupt and the rescan hrtimer only queue the event work. Dropping a publication already took a mutex (fence::Member -> Submission::release_state()), and LinkBlock's drop now asserts might_sleep().
  • Fences (and their timestamp waits) are held only by the Queue, which main already fills with KVVecs.
  • Packet's two vectors go with the packet. Its holders are runtime state behind mutexes, the drm_sched job (free_job runs from the scheduler's workqueue or at teardown), and the ioctl.
  • No file that holds a Packet takes a spinlock or RCU read lock, or disables IRQs. The only fence callback (sync_scope.c) holds no packet.

Left contiguous, by design. The merged dma_fence_array's own fence array is allocated by core __dma_fence_unwrap_merge() and freed with kfree() in dma_fence_array_release(), so it can't move to vmalloc from the driver. It holds only unsignalled fences, 8 bytes each.

Merged with main. #2228 landed first, with pending/guards in a KVVec Scratch; the merge 77eb06bd5c89 takes main's version there and main's EnqueueOrdering/ProducerWaits logic in enqueue(), and only moves the vectors that hold the fences. ad7c997ec0f2 covers the vectors main added since this branch was written.

Evidence

Testing

  • At cab097479b9a: KUnit (arm64 qemu, asahi + SEP + ISP config) 928 tests, 927 pass, 1 skip; tools/asahi/run-host-tests.py all g17 entries pass (251), with only the 29 failures plain main has in this environment. test-fence-signalling.py's host shim now provides kvmalloc_array()/kvfree() (cab097479b9a).
  • At b99cc53: KUnit 738 tests, 737 pass, 1 skip; --only g17 90/90; checkpatch 0 errors (the 1 warning is the quoted kernel log line). checkpatch on the new commits: 0 errors, 0 warnings.
  • The pre-merge change ran in our M4 Pro m4.179 to m4.185 kernels (with compaction back on).

Not done

The submit ioctl collects its validated commands and their VM pins in
KVecs, and builds each command's dependency, checked-input and firmware
fence lists in KVecs too. All of them are sized by userspace: up to 64
commands per submission, each over a kilobyte once validated, and as
many dependencies as the command waits for, which for the other engine's
unfinished commands can be thousands. kmalloc() needs them physically
contiguous, so a large submission asks for an order-3 block for its
commands alone, on every ioctl. On a machine without compaction that is
never allowed to fail and ends in the OOM killer instead, five times in
one dEQP-VK run on an M4 Pro, with 26 GB available:

  deqp-vk invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=3
   krealloc_node_align_noprof+0x154/0x238
   rust_helper_krealloc_node_align+0x10/0x20
   ..._asahi_core3g175queue...18prepare_submission...

Nothing needs these contiguous: only the ioctl and the job read them.
Make them KVVecs, and the cursor array the merge of a long dependency
list allocates a kvmalloc_array(). Small ones keep their kmalloc
memory. Userspace decides how large they get, so charge all of them to
the caller's memory cgroup (GFP_KERNEL_ACCOUNT).

A vmalloc()ed vector must be freed where vfree() may sleep. The
command, dependency and merge vectors are freed in the ioctl. A job's
packet keeps its checked inputs and firmware fences, and its owners
release it under the runtime's mutexes or from drm_sched's free_job()
work, never under a spinlock or in a fence callback.

The fence array of the merged dependency itself is allocated by
__dma_fence_unwrap_merge() and freed with kfree() by dma_fence_array,
so it stays contiguous. It holds only unsignalled fences, 8 bytes each.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
@jgoyvaerts
jgoyvaerts force-pushed the m4pro/g17-submit-kvvec branch from 5ba7b33 to b99cc53 Compare November 22, 2026 20:30
@RyanTheTide

Copy link
Copy Markdown
Contributor

Review at b99cc53 (non-author, draft). No blocker.

  • Every vector that grows with userspace input (commands per ioctl, dependency and prefix lists, the merge arrays) moves to KVVec / kvmalloc_array() with GFP_KERNEL_ACCOUNT; kvmalloc still tries kmalloc first, so the common small case is unchanged, and a large one no longer needs an order-3 block or reaches the OOM killer through compaction-free reclaim.
  • The vfree() context holds as far as I can see: none of the files that hold a Packet (job, queue/, runtime/, trace) use a spinlock, IRQ-off section or RCU read side, the drm_sched free_job runs from the scheduler workqueue, and the C fence callback in sync_scope.c holds no packet. kvfree_atomic-style deferral is not needed.
  • Charging to the caller's memory cgroup is right for data the caller sizes.
  • Merges cleanly on the current integration/aurora tip.

Small points, not blocking:

  • A row showing the same dEQP-VK run on a 16K-page Mac with CONFIG_COMPACTION still off and no OOM kill would prove the change on its own, independent of the config fix.
  • pending starts with capacity 1 and grows per command; with up to MAX_COMMANDS_PER_SUBMISSION entries, with_capacity from the parser's command count (if it is known up front) would save the reallocations.

Assisted-by: LLM (Claude:Opus 5.5)

@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Partial hardware evidence from the J616s (M4 Pro). The same change, in our tree as one commit on top of #2228's per-queue scratch, is in our m4.179 kernel, which also turns compaction back on. On this boot:

  • The vkd3d-proton test that queues 65,536 commands passed twice. Its per-command dependency and merge vectors grew through kvmalloc without any page allocation failure.
  • The d3d12 list (544 tests) and dEQP-VK query_pool/timestamp (1999 cases) show no regressions against the same Mesa on m4.177.
  • 0 invoked oom-killer and 0 page allocation failure, 0 GPU recoveries.

This stays a draft. I haven't rerun the large dEQP-VK run that hit the OOM killer, and with compaction now on in that kernel, 0 OOM kills on this boot doesn't show this change on its own. The next check is that dEQP-VK run, with a kmem:kmalloc probe, to show the submit path no longer asks for high-order blocks.

Assisted-by: LLM (Claude:Opus 5.5)

Alyx-ML added a commit to Alyx-ML/linux that referenced this pull request Nov 23, 2026
Several ioctls size a kernel allocation straight from userspace:

- SUBMIT copies cmdbuf_size bytes (a u32, so up to 4 GiB) into a KVec.
  Only G16 bounds it before the copy (4 MiB); every other GPU kept the
  trait default of usize::MAX.
- SUBMIT allocates in_sync_count + out_sync_count sync items before any
  per-GPU check.
- VM_BIND copies stride * num_binds bytes and then reserves num_binds
  prepared operations. Without a GPU batch limit (bind_batch_limit()
  returns None), both are up to u32::MAX.

A request past the page allocator's largest order hits
WARN_ON_ONCE_GFP() in __alloc_pages(). Any user with the render node can
trigger it, and with panic_on_warn it takes the machine down. Short of
that limit, a valid but large request still needs high-order contiguous
pages: an order-3 allocation of the sync array failed on J616s under
deqp-vk.

For SUBMIT:

- Copy the command stream and build the sync array in KVVec with
  GFP_KERNEL_ACCOUNT. kvmalloc() falls back to vmalloc() instead of
  failing on fragmented memory, and the memory is charged to the
  caller's memcg. The sync array keeps this type through every
  generation's submit() (G13/G14, G15, G16, G17, G18, M3, M5); the G17
  job vectors are converted in aurora-silicon#2858.
- kvmalloc() refuses, and warns about, more than INT_MAX bytes. The
  trait default for max_cmdbuf_size() is now INT_MAX, so a larger
  command stream fails with E2BIG. This rejects no stream any GPU could
  accept before. A sync array larger than INT_MAX bytes fails with
  E2BIG too.
- G17 returns its own bound: the largest valid G17 stream,
  MAX_COMMANDS_PER_SUBMISSION * (1 + 5) *
  (size_of::<drm_asahi_cmd_header>() + u16::MAX) = 25,168,512 bytes,
  checked at build time to be at most INT_MAX.
- G15 returns its 4 MiB MAX_CMDBUF, as G16 already does. Its parser
  refused a longer stream before, but only after the copy, with EINVAL.
  Such a stream now fails before the copy, with E2BIG.
- G18, M3 and M5 use the shared default until their own largest stream
  is known.

For VM_BIND, pass __GFP_NOWARN on the user-sized allocations, so a
request that is too large fails with ENOMEM and no warning. Its sizes
are not changed. The timestamp mapping limit is left to
aurora-silicon#2531.

Checked by reading the call paths (file.rs submit, parse_array, vm_bind,
vm_bind_g17, mmu/bind.rs, and each generation's submit()). rustfmt is
clean on the changed code. The kernel Rust code was not compiled here.
What userspace can see: on G17, a stream over 25,168,512 bytes, which
its parser cannot accept, now fails before the copy; on G15, a stream
over 4 MiB fails with E2BIG before the copy instead of EINVAL after it;
on G13, G14, G18, M3 and M5, only streams over 2 GiB fail early. The
allocation path changes on every GPU, so deqp-vk or CTS runs on G13, G14
and G17 (J616s among them) are needed before this is merged.
@RyanTheTide

Copy link
Copy Markdown
Contributor

@jgoyvaerts checking open drafts today. To come out of draft, this still needs:

  • It conflicts with main. Merge main in or rebase (no force push needed: a merge commit is fine).
  • Then a test run at the final head on a Mac with the hardware it touches, and mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

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 <jonathan.goyvaerts@gmail.com>
Since this branch was written, main builds a command's producer waits
in two steps: EnqueueOrdering collects the covered predecessors, host
waits, firmware waits and inherited timestamp waits from the frontier,
and the publication's Prepared links one record per predecessor. Each
of those vectors grows with the same covered prefixes this branch's
dependency vectors do, pushed one entry at a time from empty, so a deep
prefix of the other engine reallocates them into high-order contiguous
blocks on every command.

Make them KVVecs charged to the caller with GFP_KERNEL_ACCOUNT, and
charge the per-predecessor link records too.

vfree() context: EnqueueOrdering and Prepared are consumed or dropped
in the ioctl; Prepared::activate() frees its links after the target's
mutex is released. The inherited timestamp waits end up in Fences,
which only the Queue holds, and the Queue already keeps KVVecs.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
test-fence-signalling.py compiles the production g17/sync_input.c
against host shims. Its fence merge now takes its cursor array with
kvmalloc_array(GFP_KERNEL_ACCOUNT) and frees it with kvfree(), so the
shim provides those instead of kmalloc_array(), kfree() and GFP_KERNEL,
which nothing else in the harness uses.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Merged main (4cc1d6d) in as a merge commit, no force-push. New head: cab097479b9a.

Conflicts, all in g17/queue/mod.rs:

The resolution changes no behaviour: main still decides which fences a command waits for, checks and hands to firmware. Comparing this PR's diff against its old base with the merge's diff against main shows only that move.

Two commits on top, both for what main added since this branch was written:

  • ad7c997ec0f2 drm/asahi: g17: keep the enqueue ordering vectors off contiguous pages. EnqueueOrdering's predecessors, host waits, firmware waits and inherited timestamp waits, Fences::timestamp_waits and the publication's Prepared::links grow with the same covered prefixes and were KVecs pushed from empty. They become KVVec + GFP_KERNEL_ACCOUNT. vfree() context: EnqueueOrdering and Prepared are freed in the ioctl, and activate() frees its links after the target's mutex is released. Fences are held only by the Queue, which main already fills with KVVecs.
  • cab097479b9a selftests: asahi-m4: shim kvmalloc_array() for g17/sync_input.c. test-fence-signalling.py compiles the production sync_input.c against host shims that only had kmalloc_array()/kfree().

Checks at cab097479b9a (local, an M4 Pro host):

  • KUnit (arm64 qemu, asahi + SEP + ISP config): 928 tests, 927 pass, 1 skip.
  • tools/asahi/run-host-tests.py: 738 ok, 29 fail. All 251 g17 entries pass. The 29 failures are the same set that fails on plain main in this environment: apple-dcp, test-m3-uapi, g15-pb-growth/retention/stats-drain (link errors) and sep-suspend-errors (missing rustup 1.93.1).
  • checkpatch: 0 errors, 0 warnings on the new commits.
  • CI: the runs for this head are queued. aurora-silicon CI hasn't been starting runs since about 13:12 UTC today.

Next: the same dEQP-VK run that hit the OOM killer, with a kmem:kmalloc probe on the submit path, on a J616s (M4 Pro) kernel carrying this head. It's queued for our next test kernel.

@jgoyvaerts
jgoyvaerts marked this pull request as ready for review November 28, 2026 18:10
@jgoyvaerts
jgoyvaerts requested review from a team and DjDeveloperr as code owners November 28, 2026 18:10

@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: FINISH, then merge at cab09747

Blockers:

  1. Wait for the 21 queued CI checks (apple-build, kunit, host-tests, pr-text, readiness, 16 KUnit suites) at cab09747 to finish green.
  2. Complete the queued exact-head J616s (M4 Pro) hardware row at cab09747 (dEQP-VK + regression check; no Mac boot at this head yet).

Checked:

  • All 6 modified files (g17/completion/publication.rs, g17/job.rs, g17/queue/mod.rs, g17/sync_input.c, g17/sync_input.rs, tools/testing/selftests/drivers/gpu/asahi-m4/test-fence-signalling.py): 0 code blockers.
    • Verified all userspace-sized submit vectors (Prepared::links + KBox<Link>, Packet::{inputs, firmware}, Fences::timestamp_waits, dependencies, checked_inputs, EnqueueOrdering vectors, sync_input::merge(), and asahi_g17_merge_fences() cursors) move cleanly to KVVec / kvmalloc_array() with GFP_KERNEL_ACCOUNT.
    • Verified vfree() drop contexts are sleepable: Prepared::activate() releases self.target.state.lock() before consuming/dropping self.links, EnqueueOrdering/merge/dependency vectors drop in the ioctl path, and Packet/Fences drop under queue/scheduler workqueue/teardown contexts (no spinlock/IRQ drop).
    • Verified test-fence-signalling.py shims GFP_KERNEL_ACCOUNT, kvmalloc_array(), and kvfree() cleanly (251/251 g17 host tests, 927/928 KUnit, checkpatch clean, MERGEABLE on main).
Evidence
  • Head: cab09747 (MERGEABLE on main, +57/-48 across 6 files).
  • CI at review time: 21 checks QUEUED/PENDING, 0 failures.
  • Code is clean; ready to approve once CI and the exact-head J616s row at cab09747 pass.

@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Note on where the hardware row will come from: our J616s test kernels are based on main a851ca0edfc9 plus our carried patches, not on current main, so the kernel that runs the dEQP-VK kmalloc-probe row won't carry cab097479b9a itself. It will carry a backport of this PR's change onto that base:

  • The original change is already there as a carried patch.
  • ad7c997ec0f2 is adapted: that base has no Fences::timestamp_waits yet, so it covers Prepared::links and the one firmware-wait push.
  • The sync_input.c test shim fix is included.

KUnit and the g17 host harnesses pass on the backport. I'll post the run's result here, naming the kernel and that base, and the Tested: line will say the same.

@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

J616s (M4 Pro) result, on our m4.201 test kernel. That kernel is main a851ca0edfc9 plus our carried patches plus this PR's change backported (the original change, ad7c997ec0f2 adapted to that base, and the sync_input.c test shim), not cab097479b9a itself.

  • Cases: dEQP-VK.synchronization{,2}.timeline_semaphore.*, 5,753 cases. This is the group whose submits hit the order-3 OOM kills, including the write_blit_image cases. They ran one deqp-vk process at a time, 50 cases per process, on system Mesa.
  • Results: 5,753/5,753 Pass.
  • Kernel log during the run: 0 invoked oom-killer, 0 page allocation failure, 0 GPU recoveries.
  • Probe: a kmem:mm_page_alloc tracepoint on order >= 2, non-movable allocations, with kernel stacks. It caught 760 such allocations.
    • No allocation in the asahi driver could reach the OOM killer: none entered direct reclaim without __GFP_NORETRY. Nothing came from prepare_submission, enqueue, EnqueueOrdering or Prepared::new.
    • The 758 under ASAHI_VM_BIND are kvmalloc's first kmalloc try for core drm_gem_get_pages()'s page array. That try is GFP_NOWAIT and falls back to vmalloc.
    • The one under ASAHI_SUBMIT is an opportunistic slab refill for Packet::new's render footprint.
  • Caveat: that kernel has compaction on, so the 0 OOM kills alone don't isolate this change; the probe does. I haven't run the compaction-off row Ryan suggested.

Open: a Cyberpunk profile on the same kernel shows more time in the memcg slab charge and free hooks. That is consistent with the per-submit GFP_KERNEL_ACCOUNT on Prepared::links and its Link records, which are freed in the event work. It isn't attributed yet, since other changes are in that kernel too. If it holds, those transient, frontier-bounded allocations would go back to uncharged GFP_KERNEL and stay KVVec. Until then I'm not claiming this change is performance-neutral.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (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 Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 08493ce6: not ready yet

Check Detail
CI at head ok 9 checks passed
Review no approved by aurora-silicon-review, but GitHub does not count it yet (code owner from Core, Omarchy Mac or Aurora Maintainers needed, or approval went stale)
Requested changes ok none
Hardware row at head ok comment at 08493ce6
Conflicts ok none
PR text ok Risk: two-way · M4, M4 Pro, M4 Max and M5 (shared G17 code)

Areas: area:gpu

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

Prepared::new() takes one link record per covered predecessor, and the
vector holding them, with GFP_KERNEL_ACCOUNT. Every submit charges them
to the caller's memory cgroup, and the event work that publishes the
predecessor uncharges them, which puts memcg's slab hooks on both
paths. On an M4 Pro, Cyberpunk 2077 spent 0.35-0.40% of its samples in
them, against 0.03% before, and its median frame time rose from about
48 to 52-53 ms; without the charge both come back.

The charge buys nothing here: the links are transient, bounded by the
frontier, and never outlive the predecessor's publication. Take them
with GFP_KERNEL; the vector stays a KVVec, so a deep prefix still needs
no contiguous pages.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 2, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Dec 2, 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: MERGE at a1f478bba9ef once the J714s and J700 rows below pass at this head.
Blockers: none in the code.
Checked: the forward merge of main ccb3d8bd is a clean merge plus three conflict fixes, and each fix keeps both sides. g17/job.rs keeps main's batch_renders next to this PR's KVVec inputs. g17/queue/mod.rs keeps main's order (skip inputs the sources already cover, then inputs that already signalled), drops this side's copy of the first check because main moved it, and pushes with GFP_KERNEL_ACCOUNT. The test-fence-signalling.py stand-in keeps main's READ_ONCE/smp_rmb and adds GFP_KERNEL_ACCOUNT. Against main, the net diff is the one approved at 5a735f9c plus one line: the stand-in still defines GFP_KERNEL, which is unused and harmless. CI at this head: apple-build and KUnit asahi pass. host-tests passes 996 of 998; the two failures are centauri-scan-tests, which fails the same way on an unrelated PR at the same main, so main causes them. The asahi-m4 selftests, which build this stand-in, pass. No Apple material, no gates.

Rows still owed at this head: J714s (G17S), the dEQP-VK synchronization*.timeline_semaphore subset vs base with 0 OOM kills and 0 page-allocation failures; J700 (G17P), the same subset.

Evidence
  • git merge-tree --write-tree --merge-base=87f8dd626a9e 5a735f9cf848 ccb3d8bd1b32 conflicts only in g17/job.rs, g17/queue/mod.rs and test-fence-signalling.py. Every other path is identical to the tree of a1f478bb.
  • Net diff ccb3d8bd..a1f478bb (+302/-85) compared line by line with 87f8dd62..5a735f9c (+302/-86): the only difference is the kept #define GFP_KERNEL 0.
  • host-tests run 46960149006: 996/998. The unrelated run 46960564439 has the same 2 centauri-scan-tests failures (bt-production.c: implicit dev_warn_ratelimited/cen_rx_consume).

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 3, 2026
Conflicts: g17/completion/publication.rs, g17/job.rs and
g17/queue/mod.rs. main replaced the completed fence per firmware-ordered
producer with a check of the other engine's failure log (the `firmware`
vector is gone), and links a command only to the predecessors that no
other one reaches. Keep both, with the vectors that remain as KVVec
charged to the client.

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

Copy link
Copy Markdown
Contributor

Merged main (0c4c91bb7cc3) as 92b9cca40427, a plain merge commit; your commits are unchanged. Three files conflicted:

  • g17/completion/publication.rs: only the atomic imports.
  • g17/job.rs, g17/queue/mod.rs: main replaced the per-producer firmware fence vector with a check of the other engine's failure log, so that vector and its KVVec change are gone; main's timestamp_waits, failure log and reach fields stay next to your KVVec fields.
  • g17/queue/mod.rs EnqueueOrdering::build(): main's keep() (which skips predecessors another one already reaches) stays, with your accounted KVVec behind it.

The other added and removed lines against main are the same as at a1f478bba9ef. run-host-tests.py --only g17 337/337, --only asahi-m4 1/1, and the driver builds for arm64 with KUnit on. It also merges clean with #3200 (no shared file). The J700 and J714s rows are owed at this head.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 3, 2026
RyanTheTide
RyanTheTide previously approved these changes Dec 3, 2026

@RyanTheTide RyanTheTide 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.

Checked the merge against its main parent. The other-engine failure log and predecessor reach pruning stay in place. The remaining userspace-sized vectors use charged KVVec allocations, and the single charged link block retains its successor until each link has left the predecessor list and traversal. Exact-head CI and the current-base J616s row remain pending.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 3, 2026
main's aurora-silicon#4020 rewrote the G17 publication links that this branch keeps
in one charged block. Links now stay deferred on the successor until
its finish(), a waiter that subscribes it, or a probe that finds every
predecessor settled, and the phase is one atomic. That conflicts in
g17/completion/publication.rs and g17/queue/mod.rs.

- publication.rs: main's logic is kept as it is. Only the storage
  changes back to this branch's: all of a successor's links are one
  LinkBlock, a KVVec charged with GFP_KERNEL_ACCOUNT, instead of a KVec
  of (predecessor, KBox<Link>) pairs. A deferred link holds its
  predecessor, and the deferred links are listed through Link::next, so
  finish(), subscribe() and the probe take, consume and settle them as
  main does with its vector. An attached link holds its successor until
  release(), and State::drop releases the links of a predecessor that
  is dropped unpublished, as before.
- queue/mod.rs: main's firmware_published, kept beside the firmware
  waits, is a charged KVVec like them. main's skip of producers that
  were already published inline stays.
- The KUnit case that drops an unpublished predecessor now finishes the
  waiter first, since only then is its link installed in the
  predecessor. It also checks a successor dropped while its links are
  still deferred.
- tools/asahi/g17-publication-lazy-tests.py and
  g17-inline-cross-engine-tests.py match source text that moved:
  add_successor() takes a NonNull<Link>, activate() defers the chained
  links, link_deferred() skips a settled predecessor in a match guard,
  the probe unlinks a failed predecessor's link, and the producer and
  firmware_published pushes use GFP_KERNEL_ACCOUNT. Their models and
  assertions are unchanged.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot added needs-review No approving review from Core or Omarchy Mac yet (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 4, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Forward merge of main 35ddf947b124 into this branch. New head: c30dc52acac7. It is one merge commit on top of 92b9cca4: no rebase, no force push.

What conflicted

How I resolved it

  • publication.rs: drm/asahi: g17: attach publication links lazily with a single atomic phase #4020's logic stays as it is: the same deferral, probe, subscribe and phase changes. Only the link storage is this branch's: one LinkBlock per successor (a KVVec, allocated with GFP_KERNEL_ACCOUNT) instead of a KVec<(Arc<Publication>, KBox<Link>)>.
    • A deferred link holds its predecessor, and the deferred links are listed through Link::next, which is unused until the link is attached.
    • So finish() and subscribe() take that list, the probe unlinks a failed predecessor's link, and a clean settle drops the predecessors the list holds.
    • As before, an attached link holds its successor until release(), and State::drop releases the links of a predecessor that is dropped unpublished.
  • No hunk of this PR is moot. drm/asahi: g17: attach publication links lazily with a single atomic phase #4020 still allocated a KVec plus one uncharged KBox per link, so the one charged block is still needed.
  • queue/mod.rs: main's code with this branch's charged pushes. firmware_published is a charged KVVec, like the vectors next to it.
  • KUnit: both block cases are kept.
  • tools/asahi/g17-publication-lazy-tests.py and g17-inline-cross-engine-tests.py check source text, so seven of their strings now follow the moved code:
    • add_successor() now takes a NonNull<Link>, and activate() defers the listed links.
    • link_deferred() skips a settled predecessor in a match guard, and the probe calls state.unlink_deferred(index).
    • The producer and firmware_published pushes use GFP_KERNEL_ACCOUNT.
    • Their models and assertions are unchanged.

Checks. All ran on pc, with the same commands on main 35ddf947 and on the merge.

  • Image modules, then W=1 of drivers/gpu/drm/asahi/ (arm64, LLVM, aurora_defconfig, warm tree): it builds, and the W=1 warning set matches main's exactly (43 lines each), so there are no new warnings.
  • The same with CONFIG_KUNIT=y, so the publication KUnit suite compiles too: it builds, and the W=1 warning set matches main's (39 lines each).
  • Host tests:
    • run-host-tests.py --only g17-: 404/404 (main: 404/404).
    • --only asahi-m4: 1/1 (main: 1/1).
    • All 9 mutations of the lazy suite and all 13 of the partial-order suite are still caught.
  • The merged publication.rs itself, built in userspace over std stand-ins, ran under Miri with Stacked and Tree Borrows, 32 schedules each.
    • It ran its 9 KUnit cases plus 3 threaded cases, where finishes, probes, a late setup and an unpublished drop race each other.
    • No undefined behaviour, data races or leaks. main's file passes the same harness.
  • Not run here: the KUnit suites themselves, since they need QEMU. The hosted Apple build and KUnit job is running at this head.
  • main moved to 0242419a while the checks ran. Its new commits touch none of this PR's files, and the PR shows as mergeable.

Rows needed at c30dc52a. The approval was for 92b9cca4, and the publication code is new on a new base.

  • J714s (G17) and J700 (G17P): a module-only aurora.ko swap, with base = main and head = this merge.
    • Run the dEQP-VK synchronization*.timeline_semaphore subset against base.
    • Pass means 0 OOM kills, 0 page-allocation failures and 0 GPU recoveries.
  • The J616s row and the one-block accounting A/B noted earlier are still open.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Review of the forward merge at c30dc52acac7 (main 35ddf947 into 92b9cca4). I read the merge on its own rather than from the merge summary.

Verdict: the conflict resolution is correct. Review PASS. The merge itself doesn't need any change. Rows on hardware are still owed (see the end).

What I checked in publication.rs (git diff 35ddf947 c30dc52a and git diff 92b9cca4 c30dc52a)

  • drm/asahi: g17: attach publication links lazily with a single atomic phase #4020's logic is unchanged: the same deferral until finish(), a subscribing waiter, or a probe that sees every predecessor settled. The probe, subscribe and claim code is the same. Every phase store is still under the state lock with Release, and every read uses Acquire. The merge adds no phase write and moves none.
  • Only the storage changed. All of a successor's links sit in one LinkBlock (KVVec, GFP_KERNEL_ACCOUNT). Deferred links are chained through Link::next.
  • Successor dropped while its links are still deferred: the deferred links hold only their predecessors, with target: None, so nothing points back at the successor. Dropping the block drops those predecessor references, and nothing is leaked. No other list can point into the block at that point, because an attached link holds its successor.
  • Predecessor dropped unpublished: State::drop reads each link's next and then releases it. The release may free the successor's block, but only after next has been read.
  • Races between finish, subscribe and probe: each takes the deferred list under the successor's lock, so only one of them gets it. While attaching, link_deferred reads next and the predecessor before add_successor(). The caller holds the successor during the whole walk, so the block stays allocated even if the predecessor publishes and releases a link at once. The probe finds the link to unlink and its previous link in the same lock hold. On a clean settle it drops the predecessors off the lock, and self keeps the block alive.
  • Double release: each attached link is released exactly once. That happens in drain() (right away, or when its frame is popped), in the immediate path of add_successor(), or in State::drop. Each of these reads next/resume before the release.
  • remaining: the accounting is the same as drm/asahi: g17: attach publication links lazily with a single atomic phase #4020's: a sentinel plus the list length, with settled predecessors counted as fast_ok. A link the probe consumed leaves the list, so it isn't counted later.
  • Charging: the per-link KBox and the KVec that main allocated without charging are gone. Each successor now has one charged block. firmware_published in queue/mod.rs, new on main, became a charged KVVec like the vectors next to it. Apart from that, queue/mod.rs, job.rs and sync_input.* match the PR's own change before the merge.
  • might_sleep() on block free: drm/asahi: g17: attach publication links lazily with a single atomic phase #4020 adds new places where a publication's last reference can drop: the probe's consume and settle steps in the submit path, and link_deferred/subscribe from finish() and activate(). They run in the same contexts the assert commit lists (ioctl and event work). No publication is touched under the port, feed or fence spinlocks.

Harness edits: in g17-publication-lazy-tests.py and g17-inline-cross-engine-tests.py only the text the checks match changed. The models and assertions are byte-identical to main's. I ran both on pc, on main and on the merge:

  • lazy: PASS on both, 9/9 mutations caught.
  • inline: PASS on both, 6/6 mutations caught.

Hosted at c30dc52a: apple-build, host-tests and KUnit asahi are green. KUnit ran 646 tests: 645 passed, 1 skipped. asahi_g17_publication_order passed 9/9, including consumer_links_are_one_charged_allocation and link_block_is_freed_once_on_release_and_drop_paths.

Nit (not blocking): finish() and subscribe() now count the deferred list by walking it under the lock, where main used len(). The walk is bounded by the predecessor count and stays inside one contiguous block, so it's fine. A stored count would avoid it if it ever shows up in a profile.

Still owed before merge

  • J714s and J700 rows at this exact head: module-only aurora.ko A/B on the 7.3.0-main571a6c45 kernel both Macs boot for aurora.ko rows. Base is main's aurora.ko (current main ac0201f5 has the same driver tree as 35ddf947). Each row runs the dEQP-VK.synchronization{,2}.timeline_semaphore subset. PASS means 0 OOM kills, 0 page-allocation failures, 0 GPU recoveries or faults, no new CTS failures against base, and a clean kernel log. Both kits are built and with the machine leads.
  • The J616s row and the one-block accounting A/B.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 4, 2026
main now keeps a submission's input fences in one shared list
(sync_input::Inputs, which each command holds through CommandInputs)
instead of a copy per command. That conflicts in g17/job.rs and
g17/queue/mod.rs.

- job.rs: a Packet keeps this branch's checked inputs as a charged
  KVVec next to main's shared_inputs.
- queue/mod.rs: main's command_inputs() replaces the loop that copied
  every input into dependencies and checked_inputs, so the inputs no
  longer go into checked_inputs. The loop that remains pushes main's
  input_dependencies into this branch's KVVec with GFP_KERNEL_ACCOUNT.
  main's Inputs list is already a KVVec charged with
  GFP_KERNEL_ACCOUNT, so nothing else changes there.
- sync_input.rs and tools/asahi/g17-inline-cross-engine-tests.py merge
  cleanly. main's Inputs::new() now also calls this branch's merge(),
  whose pointer list and C cursors are charged and need no contiguous
  pages.

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

Copy link
Copy Markdown
Contributor

J714s (M5 Pro) row at c30dc52acac7: PASS.

Module-only A/B on one trial kernel (7.3.0-main571a6c45): base arm = main's aurora.ko (driver tree 3680a536), head arm = this PR's aurora.ko. Same Image and same other modules on both arms.

VERDICT #2858 J714s: PASS
CTS timeline_semaphore: head {'Pass': 5753}, base {'Pass': 5753}
KLOG: head OOM 0, page-allocation 0, GPU 0, lost 0, oops 0; base OOM 0, page-allocation 0, GPU 0, lost 0, oops 0
DEPTH64: base active_max 62, head active_max 62 OK
MEMORY: OK
CHURN 8x8x50 refused cycles retried (v2): base [0, 0, 0, 0, 0, 0, 0, 0], head [0, 0, 0, 0, 0, 0, 0, 0]

No GPUBench row is slower than its A/A noise.

One note on queue creation. The row has a "lockstep" step: 8 clients each create 8 queues at the same moment. On both arms every client gets vkQueueSubmit2 = -2 after about 2 s (base 2034 ms, head 2004 ms). That comes from main, not from this PR. The J714s has one pool of 58 logical queues for all clients, and the desktop holds 3. 8 x 8 = 64 is more than the 55 that are free. When the pool runs out before any client has all 8 queues, no client can finish and give queues back. So every waiting client hits the 2 s queue-create timeout. This PR doesn't touch that code (runtime.rs, queue/admission.rs, kick.rs are the same in both arms). An earlier run of this row lost the same race in its churn step on the head arm. That run is not a result for this PR, and the churn step now retries a refused cycle.

Still needed: a forward merge (this branch conflicts with main again), the J700 row, and an approval at the final head.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 4, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

I merged main (be72f78e) into this branch as 08493ce6. It's a merge commit pushed as a fast-forward, so the PR is mergeable again.

What conflicted. Main now keeps a submission's input fences in one shared list (sync_input::Inputs, held by each command through CommandInputs) instead of a copy per command.

  • job.rs: a Packet keeps this branch's checked inputs as a charged KVVec next to main's shared_inputs.
  • queue/mod.rs: main's command_inputs() replaced the loop this branch had changed, so the inputs no longer go into checked_inputs. The push that's left, into dependencies, uses GFP_KERNEL_ACCOUNT like the rest. Main's shared list is already a charged KVVec.
  • publication.rs, sync_input.c, sync_input.rs and the test files keep exactly this branch's changes.

Checks on the merge (pc, compared with main be72f78e):

  • The full arm64 tree builds (Image and all modules). W=1 of drivers/gpu/drm/asahi gives the same warnings as main.
  • run-host-tests.py --only g17- passes 408/408 and --only asahi-m4 passes 1/1, on both main and the merge.
  • Every mutation is caught: g17-publication-lazy 9/9, g17-inline-cross-engine 7/7, g17-render-partial-order 13/13.

Rows. The rows at c30dc52a don't count for this head. One hunk of the PR's diff changed shape (its patch ID changed), and main's driver moved under it. New kits at 08493ce6 compare it with main be72f78e's aurora.ko, module-only on the same 7.3.0-main571a6c45 trial kernel. Main's driver still links against that kernel. One kit is for the J700 (it replaces the queued c30dc52a kit) and one for the J714s (it runs after the queued c30dc52a churn kit, which still checks the queue-pool explanation for the earlier churn failure).

Still owed before merge: those two rows, the J616s row and the one-block accounting A/B.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 4, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J714s (M5 Pro) row at the current head 08493ce65f5a: PASS.

Module-only A/B on one trial kernel. Kit work/j714s-linux2858-08493ce6-20261204 (manifest 54e30745); base arm = main be72f78e, head arm = this PR. 19 minutes, SLC on (16 planes). Afterwards the Mac went back to its verified stock kernel.

  • Queue depth: base and head both reach 62 active queues.
  • CTS timeline_semaphore: 5,753/5,753 pass on both arms.
  • Kernel log: 0 OOM, 0 page-allocation failures, 0 GPU errors, 0 lost devices, 0 oopses on either arm.
  • Memory: the one-client DRM total differs by +0.03 MiB, depth by +0.00 MiB.
  • Churn 8x8x50 (v2): 0 refused cycles on either arm.
  • Lockstep 8x8x1: both arms hit main's 58-queue pool limit the same way: vkQueueSubmit2 returns -2 after ~2.04-2.06 s (base 8/8 clients, head 7/8), with 0 wrong results. This is the known test limit with 64 clients on a 58-queue pool, not a change from this PR.
  • GPUBench: all 9 rows within -0.62 %..+0.51 % of base.

Still owed before merge: the J700 (G17P) row at 08493ce6 (kit f741418a is queued on Neo) and an approval at this head from someone other than the last pusher.

@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 08493ce

Checked:

  • The forward merge keeps main's shared submission inputs and per-command filtering for fences already covered by firmware. Scheduler dependencies still see every uncovered input, and the packet still checks their status before publication. The remaining per-command vectors and temporary merge cursors are charged to the caller, with matching allocation and release APIs.
  • The publication code is byte-identical to the previous forward-merge revision. Each attached link holds its successor and its backing block until traversal finishes with the link. Deferred links hold their predecessors and release them after detaching under the state lock.
  • Replayed the publication, inline cross-engine ordering, partial render ordering and shared command-input host tests using source verified against this commit. All four passed. The hosted Apple build, host tests and Asahi KUnit passed. The linked J714s A/B report records 5,753 of 5,753 timeline-semaphore cases passing on each arm with zero GPU recoveries or allocation failures. #2858 (comment)

@RyanTheTide RyanTheTide 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.

Approving under the merge gate: the App review passed at 08493ce6 (adversarial pass by a non-author lane), the real CI is green at this head, and there's a hardware row at this head.

@RyanTheTide
RyanTheTide merged commit a917bd8 into aurora-silicon:main Dec 5, 2026
12 checks passed
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) 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.

3 participants