Skip to content

drm/asahi: g17: fan M5 Pro compute out to sibling channels for sustained heavy kicks - #3035

Merged
DjDeveloperr merged 15 commits into
mainfrom
perf/asahi-g17-m5-sibling-compute
Nov 25, 2026
Merged

DjDeveloperr merged 15 commits into
mainfrom
perf/asahi-g17-m5-sibling-compute

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What: Stacked on the #2947 → #2955 → #2969 → #3025 series. On M5 Pro, one physical firmware compute QID per logical compute queue serializes kicks even when heavy dispatches leave part of the GPU idle. A logical compute queue can now hold up to three sibling channels sharing one context and ordinal sequence, and independent kicks fan out to them only during a sustained heavy run (two retired kicks ≥ 100 us, at least two in flight). The channel count is a board property (Board::compute_channels(): 3 on J714, 1 elsewhere), and DRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNEL (bit 42) tells userspace (consumer: aurora-silicon/mesa#793).

Tested: J714s M5 Pro (G17S B1) at df36284f753b (this head, built natively, default command line with MTE and SEP writes on): boots; gpubench-vk compute and render rows all ok (compute.heavy d4 8,171 GFLOP/s); Vulkan synchronization2.op.multi_queue (every 8th case) 2,147 pass, 0 fail, the same as the default kernel; one RTC deep-sleep wake, GPU live after it; 0 GPU faults, 0 new kernel errors. Host tests --only g17 181/181. The fan-out speedups below were measured on the R1 commit (integration test kernel build 9, Mesa with aurora-silicon/mesa#793): sustained bandwidth-bound heavy compute (d=4..64) +9.9 % to +20.1 %, ALU-bound heavy compute (d=2) +5.9 %, 4/4 fresh sequential processes at 320–330 us with no QID lockout.

Risk: two-way · M5 Pro (J714) gets the new fan-out; J716C, J775D and J813 report one channel, so the fan-out stays off there. Adds a UAPI feature bit (42).

Not yet: Neo (G17P) at this head (its last row predates the main merge), M5 Max (J716C), M5 Ultra (J775D) and M5 (J813) not run.

After review (11-25): new commit df36284f753b. The unpublished-compute rollback and the sibling drain take an owner's channels out of the registry under the device mutex. They now collect them into fixed per-channel arrays (an owner holds at most three) instead of growing a KVec there. So nothing is allocated or dropped under the mutex, and every taken channel's reservation is cancelled, also when a later channel fails or is still busy. Before, a failed push left the owner locked out of reserve_compute_channel() with EINVAL. The commit also removes the unused Registry::compute_mut().

Details

Stacking: carries the same six commits as #3025 (#2947 -> #2955 -> #2969 -> #3025), patch-identical by git range-diff, and is rebased onto main (2ba145b5e335). The new feature bit is still bit 42, the next free bit: bit 40 is DRM_ASAHI_FEATURE_VDM_USC_INVALIDATE and bit 41 is now DRM_ASAHI_FEATURE_COMPUTE_ONLY (merged). The only new commit on top of the stack is drm/asahi: g17: fan M5 Pro compute out to sibling channels for sustained heavy kicks. Independent of the event-placement / render-return PR; targets integration/aurora so Host tests CI runs on the full stack.

After the main merge (11-25, main a73023bc5f1f): no conflicts; the 100-column wraps are in their own commits.

Review fix (df36284f753b): Registry::drain_compute_siblings() and the new Registry::rollback_unpublished_compute() (the rollback loop, moved beside the drain) write into caller-owned PerChannel<T> arrays ([Option<T>; COMPUTE_CHANNELS_MAX]). Each refuses with EIO before it changes a channel that would have no place, which cannot happen within the per-owner bound. After a failure the caller still holds everything taken before it. The caller drops displaced bindings and calls Backend::finish_retired_compute() only after releasing the device mutex. That runs finish_uninstalled_compute() for every taken queue and goes on past a failed cancellation. grow_compute() uses the same path for drained siblings.

New commit: 7bb65ce97e1d.

This commit:

  • Describes the channel count as a property of the board, not a test of its encoding forms. Board::compute_channels() (in g17/fw/m5/initdata.rs) is the number of firmware compute queues of one context that a single command queue's independent kicks may run on. It is 3 for the J714 (M5 Pro): macOS runs one M5 Pro command queue on up to three firmware compute queues of the same context, created on demand and sharing one completion ordinal, as seen from its own kicks traced under our hypervisor. It is 1 for the J716C, J775D and J813. multi_channel() and pairs::select_board() read only that count, and a const assertion keeps every board between 1 and COMPUTE_CHANNELS_MAX.
  • Lets a logical compute queue owner hold up to three physical compute channels (COMPUTE_CHANNELS_MAX) sharing one execution context, QoS slot, scheduler page, and work-state table, with dedicated per-channel ComputePool mappings and a unified per-context atomic ordinal sequence (Context::next_compute_identity()).
  • Fans kicks out to sibling channels only when the command is independent (no in-queue barrier and no cross-queue input sources), the owner's primary channel is in a sustained heavy run (two consecutive retired kicks >= 100 us from exact firmware execution timestamps), and at least SIBLING_MIN_IN_FLIGHT = 2 kicks are already in flight so short kicks and two-deep serial loops keep single-ring zero-arbitration latency.
  • Mirrors primary ComputeCell state lock-free so short kicks and sourced commands never lock a cell or detour to the device mutex to add a sibling.
  • Reuses vacant and foreign-VM idle compute queues via Registry::sibling_source(), rearm_vacant() / rearm_compute() / bind_rearmed(), and give_back_foreign() (prioritizing owners waiting for their primary channel) so fresh sequential processes never lock out sibling admission once the fresh-QID ceiling has been reached.
  • Reports DRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNEL (bit 42) through GET_PARAMS whenever pairs::compute_channels_per_owner() > 1 (today only the M5 Pro). Userspace consumer: borealis: gate sibling compute queues and kernel cumulative signals by kernel features mesa#793. When the bit is set, Borealis stops opening its own sibling compute queues, so the same commands are not fanned out twice.

Constants

  • COMPUTE_CHANNELS_MAX = 3: the most firmware compute queues any board spreads one command queue over (Board::compute_channels(), three on the M5 Pro, from macOS's own M5 Pro kicks traced under our hypervisor). It sizes the per-owner channel arrays and the compute waits of a render kick.
  • SIBLING_EXECUTION_NS = 100_000: measured on M5 Pro, one QID streams queued kicks back to back at about 11 us each, while three QIDs take about 16.4 us per kick (about 5 us of firmware arbitration per sibling kick). 100 us is where that 5 us drops to 5% of the kick.
  • SIBLING_MIN_IN_FLIGHT = 2: measured on M5 Pro. With a threshold of one, an owner keeping two GPU-filling kicks in flight took 286 to 302 us per kick against 270 us on one ring, because both rings then wait for the host's 60 to 100 us completion-to-resubmit turnaround. A processor-sharing model predicts 300 to 319 us. With two kicks already in flight, the primary always has one queued behind the overlap. This is the d=1 vs d>=2 crossover.
Evidence
  • Exact head df36284f753b (11-25), Apple M5 Pro T6050 / J714s / G17S B1: kernel 7.3.0-m5-p3035o, built natively on the M5 (clang 22.1.8, LLD 23.1.1, rustc 1.98.1) with the default kernel's own config. The warm tree was resynced file by file to this commit and checked byte-identical first. make -j18 Image modules dtbs exit 0, 0 errors, no Rust warnings in the touched files. Default command line (MTE on, SEP writes on), Mesa: the default Borealis 26.3.0-devel (aac82bea8e), headless only.
    • Boot in 30 s. Failed units: only tailscaled.service, which also fails on the default boot. LSMs capability,landlock, 0 AVC denials. dmesg: 0 new errors and 0 GPU or DART faults, timeouts or recoveries across all runs below. Kernel lines at priority err or worse: 10, none from the GPU (HID "no listeners", DCP clock index, as on the default boot).
    • gpubench-vk (µs per submit, all ok): compute.light d1 108.6, d2 60.2, d4 24.8; compute.heavy d1 372.4 (5,766 GFLOP/s), d4 262.8 (8,171 GFLOP/s); render.light d1 129.0, d2 68.1, d4 27.6; render.heavy d1 260.4, d4 125.3; sync.signal d1 96.4 µs; concurrent.cr d4 overlap 0.99.
    • Vulkan CTS (deqp-runner, --deqp-surface-type=fbo), 0 fail, crash or timeout: synchronization.smoke.* 12/12, synchronization2.smoke.* 10/10, compute.pipeline.basic.* 80 pass + 1 not supported, draw.renderpass.linear_interpolation.* 12 pass + 9 not supported, synchronization2.op.multi_queue.* every 8th case (2,970): 2,147 pass + 823 not supported, the same as the default kernel (7.3.0-m5-cdirect15) in the same slot.
    • GPU capacity after the runs: crashed=0, 0 quarantined compute queues, 0 awaiting witness, 0 leaked render graphs, 0 refusals.
    • Deep sleep: one RTC wake (mem_sleep deep, +28 s, Wi-Fi parked across it): entered and returned in 34.3 s, suspend_stats success 0 → 1, fail 0. After the wake the GPU is live (vulkaninfo and a dispatch). compute.light d1 108.3, d4 22.5; render.light d1 129.0, d4 28.0; sync.signal d1 91.1 µs, all ok, 0 new GPU errors.
  • Host tests at df36284f753b (python3 -I tools/asahi/run-host-tests.py --only g17): 181/181. The new g17-compute-retired-tests runs the production drain_compute_siblings(), rollback_unpublished_compute() (registry and backend), finish_uninstalled_compute(), finish_retired_compute(), reserve_compute_channel() and cancel_compute() for an owner with all three channels. It covers rollback of all three, displaced bindings, a failing rollback after a cancelled sibling, the drain, a busy sibling (EAGAIN) after an idle one, a failing cancellation, and more channels than places. Every queue and binding is dropped off the mutex, and the owner can reserve again after each case. Its 7 mutations each restore one way the old code leaked or dropped under the lock, and all fail. g17-m5-sibling-compute-tests and g17-compute-growth-deadline-tests follow the moved code.
  • scripts/checkpatch.pl --strict on df36284f753b: 0 errors, 0 checks, 1 warning: the generic "added file, does MAINTAINERS need updating?" for the new test (no MAINTAINERS entry covers tools/asahi/g17-*).
  • Rebase (ba6fe60583a6, onto integration/aurora a3d477d03f8e): the only conflict was the asahi_drm.h context next to the merged bit 41 (COMPUTE_ONLY); bit 42 is kept. Same code as R2 otherwise (the commit message's bit-41 note now names COMPUTE_ONLY). Host tests --only g17: 170/170. checkpatch.pl --strict: 0 errors, 0 checks, 10 warnings (unchanged from R2: 9 line-length in existing code, 1 MAINTAINERS).
  • R2 (4c461ae19fe1): replaces the completion_inputs && !g17d_forms && !j813_forms board-form test with Board::compute_channels(), documents the constants above, and rewords the bit-42 note. The result is the same on every board (J714 true; J716C, J775D, J813 false, as before), so the hardware rows below still apply. They were measured on the R1 commit as carried by integration test kernel build 9: the same changes, with rebased context. Host tests after R2: 170/170 (g17-compute-multi-channel-feature-tests now reads every production board's compute_channels and has 9/9 mutations: forms-gate, max-channels and multi-channel-max are new). checkpatch.pl --strict on the commit: 0 errors, 0 checks, 10 warnings, none on lines R2 touches (9 line-length warnings in existing Rust code, 1 MAINTAINERS).
  • R1 scripts/checkpatch.pl --strict: 0 errors (0 errors, 0 warnings, 0 checks on include/uapi/drm/asahi_drm.h).
  • R1 host tests (python3 -I tools/asahi/run-host-tests.py --only g17): 167/167 passed (including g17-m5-sibling-compute-tests 8/8 mutations, g17-m5-sibling-gate-tests 17/17 mutations, g17-m5-sibling-rearm-tests 14/14 mutations, g17-compute-multi-channel-feature-tests 6/6 mutations, and g17-compute-owed-stamp-tests +2 mutations).
  • Hardware (Apple M5 Pro / J714s / G17S B1, Linux 7.3.0 with the M5 direct-submission stack and Mesa with compute sibling deferral on DRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNEL):
    • 0 GPU faults, 0 kernel warnings; 4,058/4,068 multi-queue and timeline Vulkan CTS passed (0 failures).
    • Sustained bandwidth-bound heavy compute queues (d=4..64): +9.9% to +20.1% faster.
    • Sequential multi-process non-lockout: 4/4 fresh sequential processes sustained 320-330 us with zero QID exhaustion lockout.
    • Sustained ALU-bound heavy compute (d=2): +5.9% faster.

Regression tuple (R1 row)

Field Value
Board run Apple M5 Pro (J714s, G17S B1), the only board run
Distro Arch Linux ARM
Kernel Aurora 7.3.0 M5 integration test kernel build 9, carrying all five PRs (#3023, #3024, #3025, #3035, #3036)
Mesa test build git-8956dffd84 (with aurora-silicon/mesa#793)
GPU faults 0 (microbenchmark health check gpu_faults_delta=0, stress gate, CTS runs)
Kernel WARNs 0 (as recorded in the run summaries; the raw dmesg of these runs was not kept)
Vulkan CTS 4,058/4,068 multi-queue + timeline semaphore passed, 0 failed
SELinux N/A: the test kernel config has CONFIG_SECURITY_SELINUX unset
Failed systemd units Not captured: no systemctl --failed output was kept for these runs
Not run G17P (Neo), M5 Max (J716C), M5 Ultra (J775D), M5 (J813)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

R2 (8d7ae2e71f7e → 4c461ae19fe1), readiness findings addressed:

  • §1 board gate: multi_channel() no longer negates g17d_forms() / j813_forms(). It now reads a board property, Board::compute_channels(), in g17/fw/m5/initdata.rs: the number of firmware compute queues of one context that a command queue spreads over. It is 3 on the J714 (macOS's own M5 Pro kicks under aura use up to three, sharing one completion ordinal) and 1 on the J716C, J775D and J813. pairs::select_board() stores that count directly, and a const assertion keeps every board within 1..=COMPUTE_CHANNELS_MAX. The result is unchanged on every board: J714 true; J716C, J775D and J813 false, as with R1.
  • §2 constants: the doc comments for COMPUTE_CHANNELS_MAX, SIBLING_EXECUTION_NS and SIBLING_MIN_IN_FLIGHT now give their firmware and measured basis. The PR body has a short Constants section.
  • UAPI: the bit-42 note is reworded ("next free bit: 40 is VDM_USC_INVALIDATE, 41 is taken by a pending series"). The consumer, borealis: gate sibling compute queues and kernel cumulative signals by kernel features mesa#793, is linked in the body and as a Link: trailer.
  • Hygiene: Signed-off-by: Diljit Singh only. No Co-Authored-By, and no benchmark or build names in the commit or code.
  • Tests: run-host-tests.py --only g17 gives 170/170. g17-compute-multi-channel-feature-tests now reads every production board's compute_channels, with 9 mutations (new: forms-gate, max-channels, multi-channel-max). checkpatch --strict gives 0 errors and 0 checks; the 10 warnings are in existing lines (9 line-length, 1 MAINTAINERS).
  • Added the §5 regression tuple to the body. SELinux is N/A because the kit kernel config has it unset. Failed systemd units were not captured for these runs, so the tuple says so rather than claiming 0.

@DjDeveloperr
DjDeveloperr force-pushed the perf/asahi-g17-m5-sibling-compute branch from 4c461ae to ba6fe60 Compare November 24, 2026 09:51
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 24, 2026
…D sources directly

Cross-queue compute handoffs previously hit three layers of host lock
contention and fallback overhead:

1. asahi_g17_collect_fences() expanded every unsignaled node in a
   timeline dma_fence_chain without same-context coalescing (forcing
   reallocations and per-leaf global device-mutex scans inside
   Backend::input_sources()).
2. Backend::input_sources(), compute_readiness(), and sources_published()
   always took the global device mutex and linearly scanned compute
   queues to check whether a same-VM producer was published.
3. Backend::compute_direct() unconditionally rejected packets with
   converted input sources, forcing every cross-QID compute submission
   through compute_inline() under the global device mutex (and holding
   m5_outer across mailbox doorbell I/O in ComputeHost::notify()).

Coalesce healthy unsignaled leaves sharing a non-zero fence context in
collect_leaf() (keeping only the latest seqno via dma_fence_is_later()
while preserving every failed leaf with status < 0), keeping the initial
Rust collection capacity at 4, and hoist the fallback device mutex out
of the leaf loop in Backend::input_sources().

Publish immutable cross-QID kick metadata (PublishedSource: epoch,
publication order, KickDependency, and producer source_readers counter)
onto fence::Submission once compute::Queue::publish() commits and rings
its doorbell, invalidating it on retirement, error, replay, and cancel.
Track the live epoch in published_epoch (AtomicU64, 0 = unpublished) so
has_published_epoch() and empty clear_published() skip Submission::state,
and store immutable vm_status outside Mutex<State> so same_vm() is
lock-free. Remove ReaderHint's blind spot so lock-free Hold::new() loans
are always observed by shareable(), can_rearm(), and reset_for_owner().

Use the PublishedSource snapshot for lock-free checks in input_sources(),
compute_readiness(), and sources_published(), allow M5 compute_direct()
to resolve same-VM compute sources directly (skipping duplicate explicit
barriers, self-reader Holds, and firmware_consumer marks when a source
was already published on the consumer's own physical QID in the same
epoch while still validating source_status() and recovery/epoch), mark
firmware_consumer atomically on cross-QID producers, and drop m5_outer
before port.notify() in ComputeHost::notify().

Add host C+Rust tests and mutation controls in
g17-m5-cross-qid-direct-tests.

Signed-off-by: Diljit Singh <[email protected]>
…ned heavy kicks

On M5 Pro one physical firmware compute QID per logical compute queue
serializes its kicks: each QID owns a single preemption, operand, usage,
status and stamp state, so a kick holds for its parent on that QID. Kicks
that each leave the GPU partly idle then run one at a time. macOS runs one
M5 Pro command queue on up to three firmware compute queues of the same
context, created on demand and sharing one completion ordinal, as its own
kicks show when run under aura.

Describe that as a property of the board: Board::compute_channels() is the
number of firmware compute queues of one context over which a single
command queue's independent kicks may run, 3 for the J714 and 1 for the
J716C, J775D and J813, whose macOS drivers have not been seen to spread a
command queue. multi_channel() and pairs::select_board() read that count
alone rather than the board's encoding forms, and a const assertion keeps
every board between 1 and COMPUTE_CHANNELS_MAX, the size of the per-owner
channel arrays and of the compute waits a render kick carries.

Let an owner on such a board hold up to that many physical compute channels
sharing one execution context, QoS slot, scheduler page and work-state
table, and fan out onto them only the work that gains from overlap:

- A command runs on, or brings up, a sibling channel only when it is
  independent (no in-queue barrier), has no cross-queue input sources, the
  owner's primary channel runs sustained heavy work and at least two kicks
  of the owner are already in flight. The work is sustained heavy when the
  primary's last two retired kicks each ran at least 100 us between the
  start and end timestamps of their exact firmware execution records
  (pairs::heavy_run(), pairs::sustained()). One QID streams short kicks
  back to back faster (about 11 us per kick) than three QIDs do (about
  16.4 us: each sibling kick pays about 5 us of firmware arbitration), so
  short kicks stay on the primary ring; from 100 us that cost is within 5%
  of the kick. Recordless retirements and releases of held descriptors
  never count, and the run restarts for every owner.
- A kick queued behind one in flight on the same ring starts the moment
  its predecessor ends, while the host needs 60 to 100 us to turn that
  completion into the next submission. Two overlapped kicks that each fill
  the shader cores share them and end together; both rings then wait for
  the host, and every pair of kicks pays that turnaround (a
  processor-sharing model predicts 300 to 319 us per kick against 270 us
  serial; 286 to 302 us were measured for an owner keeping two such kicks
  in flight). A kick that leaves the GPU partly idle gains about 10% from
  the same overlap, but the kernel cannot tell the two apart from a kick's
  metadata (same workgroup size, no threadgroup memory, similar register
  footprint; the grid lives in the CDM stream). So a kick leaves the
  primary ring only with SIBLING_MIN_IN_FLIGHT (two) kicks already in
  flight (pairs::overlaps(), on the direct path, in channel selection and
  in sibling admission): the primary then keeps one queued behind the
  overlap, a sibling only adds overlap and never exposes the turnaround,
  and an owner keeping at most two kicks in flight runs exactly as on one
  ring. Mesa applies the same rule to the sibling queues it opens itself.
- A command with input sources always takes the primary channel, on the
  direct path (whose lock-free cross-QID source resolution, binding loans
  and hold hand-off are unchanged) and on the device-mutex path, and never
  binds a sibling, so a semaphore hop between queues stays on one ring per
  queue.
- Backend::fans_out() checks the command before it asks for the primary's
  state, and compute_direct() reads that state from the primary
  ComputeCell's lock-free mirror (sustained), so short kicks and sourced
  commands neither lock a cell nor detour to the device-mutex path to add
  a sibling.
- Each sibling channel owns a dedicated ComputePool mapped into the
  context VM; concurrent kicks take distinct 1-based ordinals and
  (predecessor_id << 32) | current_id object ids from one per-context
  atomic sequence (Context::next_compute_identity()), used as both
  submit_sequence and completion_ordinal.
- ComputeCell mirrors (configuring, active_len, last_published, sustained)
  whenever a QueueGuard drops; compute_direct() routes to an idle primary
  without locking a sibling cell and scans the hints lock-free otherwise.
- Siblings bind lazily when every bound channel is busy, from the source
  Registry::sibling_source() names, in the order a primary binding takes
  its channel: an idle reusable queue whose populated pool serves the
  owner's VM and fits, bound at once; a vacant reusable queue no other
  owner is re-arming, re-armed with fresh backing off the device mutex and
  bound as the sibling through the primary's own rearm_vacant(),
  rearm_compute() and bind_rearmed(); a fresh QID; and last an idle
  reusable queue whose pool still serves another VM, given back
  (give_back_foreign(), which rebind_compute() now shares) while no other
  pool release is in flight, so the next pool pass vacates it for a later
  attempt. Only reusable queues qualify: a queue with an owner or work, an
  open owner's idle channel, a queue another owner is re-arming and one
  whose scheduler or pool release is in flight are never taken, and an
  owner waiting for its first channel goes first. Once earlier clients had
  taken compute QIDs up to the fresh-QID ceiling, every idle queue was
  vacant or held a gone VM's pool, so admitting only same-VM pools and
  fresh QIDs never brought a sibling up again until the GPU slept. A miss
  backs off for SIBLING_HEADROOM_BACKOFF_NS.
- Each QID keeps the completion-class implicit parent while its own earlier
  kick is active; dependent compute and render consumers wait on every
  channel of the owner. Siblings release and roll back before the primary,
  idle siblings drain before primary pool growth, and a ContextKill cookie
  and its acknowledgment cover every channel.

GET_PARAMS reports the new DRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNEL wherever
a logical compute queue holds more than one channel
(pairs::compute_channels_per_owner() > 1), so userspace that would open
sibling queues of its own for the same overlap leaves it to the kernel
instead of fanning out twice. Only the M5 Pro reports it: the other M5
boards describe one channel, and G17P never selects an M5 board. The
feature takes bit 42, the next free bit: bit 40 is
DRM_ASAHI_FEATURE_VDM_USC_INVALIDATE and bit 41 is
DRM_ASAHI_FEATURE_COMPUTE_ONLY. Mesa's Vulkan driver reads the bit and
then leaves the sibling queues to the kernel (aurora-silicon/mesa#793).

Host tests: tools/asahi/g17-m5-sibling-gate-tests.py compiles the gate,
the in-flight threshold, the direct-path channel selection, the
ComputeCell mirror and the registry's channel selection and sibling
admission, with 17 mutation controls; g17-m5-sibling-rearm-tests.py runs
the production reuse predicates, sibling sources, give-back, pool pass and
re-arm for clients that come and go with no fresh QID left (14 controls,
the old admission rule among them);
g17-compute-multi-channel-feature-tests.py reads every production board's
channel count and checks where the feature is reported, that the decision
ignores the encoding forms and that its bit is unique (9 controls);
g17-compute-owed-stamp-tests.py runs the real retirement pass
against the heavy-kick run (2 more controls);
g17-m5-sibling-compute-tests.py covers identities, dedicated pools,
routing, release, rollback, growth and exit ordering (8 controls).

Link: aurora-silicon/mesa#793
Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr
DjDeveloperr force-pushed the perf/asahi-g17-m5-sibling-compute branch from ba6fe60 to 7bb65ce Compare November 24, 2026 16:52
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 24, 2026 16:52
@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 75774d0d: not ready yet

Check Detail
CI at head ok 18 checks passed
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 75774d0d, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · M5 Pro (J714) gets the new fan-out; J716C, J775D and J813 report one channel, so the fan-out stays off there. Adds a UAPI feature bit (42).

Areas: area:gpu

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

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Rebased onto main (2ba145b5e335, previously a3d477d03f8e): ba6fe60583a6 → 7bb65ce97e1d.

Conflicts were all in drm/asahi: g17: enable direct compute submission on M5, from the dead-code removal merged in #2433:

  • g17/initdata/m5.rs: main removed the unused m5_policy_telemetry_word(). That removal is kept, and only this commit's new m5_history_view() is added.
  • g17/runtime.rs publish_compute_raw(): main reworded the comment on the M5 outer-ring reservation (InitData::publish_work_at). This commit moves that block below the queue checks, so the old copy is dropped as before.

The stack is unchanged: on #3025 (550b955538f4), whose six commits it carries again. Feature bit 42 is still the next free bit on main. Every other commit is unchanged (git range-diff: patch-identical).

Host tests: tools/asahi/run-host-tests.py --only g17 170/170 pass. scripts/checkpatch.pl --strict: 0 errors, and the same warnings as before the rebase. The full suite runs in the Host tests check.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 24, 2026
@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026
…i-g17-m5-direct-cross-qid-sources

Bring in the base PR's merge of main up to 6ec49ac, including its
m5_history_view() update for the relocated M5 submission-history
fields.

Conflict in tools/asahi/run-host-tests.py: both sides register a new
g17 test; both are kept.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr
DjDeveloperr requested a review from a team as a code owner November 25, 2026 10:28
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
…i-g17-m5-direct-cross-qid-sources

Bring in the removal of the unused unlocked M5 history update from the base branch. No conflicts.

Signed-off-by: Diljit Singh <[email protected]>
…sahi-g17-m5-sibling-compute

Bring in the removal of the unused unlocked M5 history update from the base branch. No conflicts.

Signed-off-by: Diljit Singh <[email protected]>
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 25, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

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 9b419de5e66e

Blockers:

  1. rollback_unpublished_compute() and drain_compute_siblings() can drop aliases/queues under self.shared.state.lock() and permanently leak ComputeReservation slots on OOM:
    • In drivers/gpu/drm/asahi/g17/runtime/backend.rs:38-67, retired and bindings are zero-capacity KVec::new() and grow via let _ = bindings.push(replaced, GFP_KERNEL); and let _ = retired.push((entry.reservation, queue), GFP_KERNEL); while self.shared.state.lock() is held (on a failure path that runs after ENOMEM publication failures). On allocation failure, let _ = drops replaced (Binding) or queue inside the device mutex (violating off-lock alias teardown) and skips finish_uninstalled_compute(), leaving entry.queue == None with an uncancelled ComputeReservation so the QID/slot leaks and future reserve_compute_channel() calls for that owner permanently fail with EINVAL.
    • In drivers/gpu/drm/asahi/g17/runtime.rs:1150-1190 (Registry::drain_compute_siblings()), retired.push((entry.reservation, queue), GFP_KERNEL)?; runs under self.shared.state.lock() after entry.queue.take() has already emptied the slot. An allocation failure returns Err(ENOMEM) while dropping queue (and any earlier pushed sibling queues) under the device mutex and leaking the uncancelled reservation(s).
    • Fix: since an owner holds at most COMPUTE_CHANNELS_MAX (3) channels, store collected items in fixed stack arrays ([Option<...>; COMPUTE_CHANNELS_MAX]) or pre-allocate/reserve capacity before taking self.shared.state.lock() and before calling entry.queue.take().

Checked: Full incremental kernel diff audit of aurora-silicon/linux#3035 (e35ddb55bc59..9b419de5e66e, 15 kernel files across drivers/gpu/drm/asahi/ and include/uapi/drm/asahi_drm.h), plus finish_uninstalled_compute(), reserve_compute_channel(), and paginated CI (19/19 passed).

Evidence
  • drivers/gpu/drm/asahi/g17/runtime.rs:1648-1664: finish_uninstalled_compute() documents the two-phase rollback contract — the empty registry entry reserves the QID/free-list identity until off-lock drop(queue) completes, and then cancel_compute(reservation) frees the slot. Skipping finish_uninstalled_compute() after entry.queue.take() leaves the empty entry stuck in self.queues.compute[slot].
  • drivers/gpu/drm/asahi/g17/runtime.rs:1060-1065 (reserve_compute_channel()): returns Err(EINVAL) whenever an entry has queue.is_none() && entry.reservation.owner == owner, turning a dropped retired.push() into permanent lockout for that owner.
  • Remaining audited areas look solid: UAPI DRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNEL uses pre-reserved bit 42, Context::next_compute_identity() atomically allocates monotonic non-zero ordinals/object IDs across sibling QIDs, QueueGuard::drop() syncs cell stats before releasing _guard, compute_direct() avoids nested cell locks and falls back on cross-channel barriers, and compute_exit.rs propagates and acknowledges the shared context-kill cookie across all sibling channels.

…under the lock

rollback_unpublished_compute() and drain_compute_siblings() take
compute queues out of the registry under the device mutex. The empty
entry keeps the QID until finish_uninstalled_compute() drops the queue
off-lock and cancels its reservation. Both collected the queues, and
the rollback its displaced bindings, into empty KVecs while holding the
mutex. A failed push dropped the queue or binding under the mutex and
skipped the cancellation. The empty entry then stayed for good, and
reserve_compute_channel() refused its owner with EINVAL from then on.
The drain also lost the queues it had already taken when a later
sibling was still busy (EAGAIN), and the rollback lost them when a
later channel's rollback failed.

An owner holds at most COMPUTE_CHANNELS_MAX channels, so collect into
fixed per-channel arrays that the caller owns: nothing is allocated
under the mutex, a channel is refused before it changes if it would
have no place, and after a failure the caller still has everything
taken before it. The caller drops the displaced bindings and finishes
every taken queue after releasing the mutex, and goes on past a failed
cancellation. The rollback loop moves into the registry beside the
drain, so no early return can skip that.

Also remove Registry::compute_mut(), which has no caller left in this
series and was the driver's only g17 dead-code warning.

The new g17-compute-retired-tests host test runs the production
rollback, drain, finish and reservation code for an owner with all
three channels, including a failing rollback, a busy sibling and a
failing cancellation.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Review fix at df36284f753b (new commit on top of 9b419de5e66e, no force push): the rollback and the sibling drain no longer allocate, or drop anything, under the device mutex.

  • rollback_unpublished_compute(): the loop moved into Registry::rollback_unpublished_compute(). It fills two caller-owned fixed arrays, [Option<_>; COMPUTE_CHANNELS_MAX]: one for displaced bindings, one for cancelled queues with their reservations. A channel that would have no place is refused with EIO before it changes. That cannot happen within the per-owner bound. The backend releases the mutex, drops the bindings, then finishes every taken queue, also when the rollback failed part way.
  • drain_compute_siblings(): writes into the same kind of caller-owned array. So EAGAIN from a busy sibling, or a failed release, no longer loses the siblings already taken. grow_compute() finishes them after releasing the mutex.
  • Finishing: the new finish_retired_compute() runs finish_uninstalled_compute() for each taken queue and goes on past a failed cancellation. So no other entry stays empty, and reserve_compute_channel() can no longer lock the owner out with EINVAL.
  • Also removed the unused Registry::compute_mut(), the dead-code warning noted earlier.

Tests: new host test g17-compute-retired-tests compiles the production code and covers an owner with all three channels: rollback of all three, displaced bindings, a failing rollback, the drain, a busy sibling after an idle one, a failing cancellation, and more channels than places. Nothing is dropped under the mutex, and the owner can reserve again after every case. Its 7 mutations, each one of the old failure modes, all fail. run-host-tests.py --only g17: 181/181.

Hardware row at df36284f753b: Apple M5 Pro (T6050 / J714s / G17S B1), pass. Built natively on the M5 from this exact head (make -j18 exit 0, no Rust warnings in the touched files). Default command line (MTE on, SEP writes on), default Borealis Mesa, headless:

  • Boots. Failed units: only tailscaled.service, same as the default boot. 0 new kernel errors, 0 GPU or DART faults, timeouts or recoveries.
  • gpubench-vk all ok: compute.heavy d1 372.4 µs / d4 262.8 µs (8,171 GFLOP/s); render.heavy d1 260.4 / d4 125.3 µs; light and sync rows match the previous row.
  • Vulkan synchronization2.op.multi_queue (every 8th case): 2,147 pass, 823 not supported, 0 fail, the same as the default kernel. Smoke, compute-basic and draw subsets also pass.
  • GPU capacity after the runs: crashed=0, 0 quarantined.
  • One RTC deep-sleep wake (deep, +28 s): suspend_stats success 0 → 1, GPU live after it, light rows ok, 0 new GPU errors.

Details are in the PR body's Evidence block.

@github-actions github-actions Bot added the changes-requested A reviewer requested changes (bot) label Nov 25, 2026
satchlj
satchlj previously approved these changes Nov 25, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: MERGE at df36284f753b

Blockers: none

Checked: review fix commit df36284f753b resolving the prior CHANGES_REQUESTED on 9b419de5e66e; Registry::rollback_unpublished_compute() and drain_compute_siblings() now collect displaced bindings and retired queues into caller-owned [Option<_>; COMPUTE_CHANNELS_MAX] arrays with zero allocations or drops under the device mutex, and finish_retired_compute() cancels every taken reservation off-lock even after a partial rollback, busy sibling (EAGAIN), or failed cancellation; dead Registry::compute_mut() removed; new tools/asahi/g17-compute-retired-tests.py host suite plus existing g17 suites wired into run-host-tests.py; exact-head Apple M5 Pro (T6050 / J714s / G17S B1) hardware row (gpubench-vk, Vulkan synchronization2.op.multi_queue, RTC deep-sleep wake, zero GPU/DART faults); commit hygiene (DCO Signed-off-by, zero AI attribution, zero Apple material); all 18 build/host/KUnit/pr-text CI checks green (0 active, 0 failed).

Evidence
  • Fix audit (df36284f753bcf69c83ca964d0ba84ae45438c79 on top of 9b419de5e66e):
    • drivers/gpu/drm/asahi/g17/runtime.rs & drivers/gpu/drm/asahi/g17/runtime/backend.rs: replaces under-lock KVec collection in both rollback_unpublished_compute() and drain_compute_siblings() with caller-owned fixed [Option<_>; COMPUTE_CHANNELS_MAX] arrays. If a channel has no free slot it fails with EIO before mutating state; otherwise all displaced bindings and taken queues are dropped and cancelled off-lock in finish_retired_compute(), continuing past individual cancellation failures so no empty entry can strand an owner with EINVAL.
    • Unused Registry::compute_mut() removed (clears the remaining g17 dead-code warning).
    • tools/asahi/g17-compute-retired-tests.py + tools/asahi/run-host-tests.py: exercises production rollback, drain, finish, and re-reservation paths across all 3 channels (including partial rollback failure, busy sibling EAGAIN, cancellation failure, and capacity overflow) with 7 negative mutation checks.
  • Exact-head hardware & CI verification (df36284f753b):
    • Apple M5 Pro (T6050 / J714s / G17S B1) native build (make -j18, 0 Rust warnings in touched files), gpubench-vk (compute.heavy d1 372.4 us / d4 262.8 us, 8,171 GFLOP/s; render.heavy d1 260.4 / d4 125.3 us), Vulkan synchronization2.op.multi_queue (2,147 pass, 823 not supported, 0 fail), RTC deep-sleep wake (suspend_stats 0 -> 1), crashed=0, 0 GPU/DART faults.
    • Paginated CI check-runs at df36284f753b: 18/18 real CI checks completed / success (apple-build, host-tests, pr-text / pr-text, and all 15 KUnit suites including KUnit asahi, KUnit clpc, KUnit trusted-keys); 0 active, 0 failed (readiness / readiness had an earlier concurrency-cancelled run at 13:55:19Z that re-triggers on this review).

@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
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Tested (J700 MacBook Neo, Apple A18 Pro / G17P B1, combined Wave C g17 kernel): PASS (correctness, boot, stability) at exact PR head df36284f753bcf69c83ca964d0ba84ae45438c79 in combined tree 7bb607c48427f67f8c3cadb31aad26e017804e0d (origin/main 7c9d9adcda5a + #2947, #2955, #2969, #3024, #3036, #3023, #3025, #3035; kernel 7.3.0-neo-wavec, vmlinuz SHA-256 be56c16aa298..., aurora.ko SHA-256 bef28f236557...).

  • Host tests & boot: 215/215 g17 host tests passed on the combined tree (python3 -I tools/asahi/run-host-tests.py --only g17). Booted cleanly via one-shot grub2-reboot with default 7.3.0-41 kernel cmdline verbatim (wld0 Wi-Fi + eDP-1 display up, SELinux Enforcing, 0 failed units).
  • Vulkan CTS & correctness (7.3.0-neo-wavec, system Mesa git-d4ad4a4dce):
    • Full dEQP-VK.synchronization.timeline_semaphore.*: 2,880/2,880 Pass, 0 failures, 0 recoveries.
    • Focused compute/sync CTS (compute.pipeline.basic.*, synchronization*.smoke.*, synchronization.basic.*, timeline_semaphore subsets): 373 Pass, 7 NotSupported, 0 failures, 0 recoveries (380/380 recorded).
    • Vulkan compute CRCs: 5/5 matched (conv2d gaussian 2d55a14d / bilateral 6cdc0716, edge sobel 27c79e6d / harris 4cebadfc, stereo c62aadf9).
    • Offline Geekbench 6.7.1 Vulkan: 8/8 workloads completed, 0 validation errors.
  • Health & restore: 0 GPU faults, 0 kernel WARNs/BUGs/Oops, 0 AVC denials across boot and the full test window, 0 failed units. Restored cleanly back to 7.3.0-41.fc44.aurora.aarch64 with byte-exact /boot, ESP, /lib/modules, BLS, and grubenv verification.
  • Performance vs shipped 7.3.0-41 (note: compares origin/main + Wave C vs Nov 16 -41, not a main-only control): rt.scene raster d2 improved +19.1% (148.9 → 177.4 fps), copy.bw buf2img d1 -3.7% (1612.9 → 1552.8 µs), compute.heavy alu queues/d2 -2.0%. compute.light queue/d2 was slower vs -41 (35.1 → 47.6 µs, submit CPU 9.1 → 12.0 µs, d1 +3.3%, d4 +5.4%), and a single offline GB6 pass showed Edge +4.7% / Particle +6.2% (unconfirmed single pass); a main-only (7c9d9adc) arm is needed to separate main drift from the 8-PR stack.
  • Toolchain note: rustc 1.100.0 flags the new AtomicU32::fetch_update call at g17/context.rs:401 as deprecated in favour of try_update (non-fatal warning; not emitted on Fedora's rustc 1.99).

@DjDeveloperr
DjDeveloperr dismissed satchlj’s stale review November 25, 2026 19:05

The merge-base changed after approval.

satchlj
satchlj previously approved these changes Nov 25, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: MERGE at df36284f753b

Blockers: none

Checked:

  • Clean-room diff with no Apple copyrighted material, decompiled listings, or copied firmware/tuning data.
  • No hardcoded model, board, or firmware gates and no new module or command-line parameters; channel capacity is read from Board::compute_channels() and exposed via DRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNEL (bit 42).
  • No hardcoded hardware safety limits; safety and hardware values come from machine descriptors and runtime state.
  • Clean human Signed-off-by: DCO on every commit and zero AI attribution across commits and PR text.
  • Prior blocker at 9b419de5e66e resolved in df36284f753b, exact-head hardware rows pass on both J714s (M5 Pro) and J700 (Neo), and all paginated CI checks are green.
Evidence
  • Prior blocker resolution (df36284f753b on top of 9b419de5e66e):
    • drivers/gpu/drm/asahi/g17/runtime.rs and drivers/gpu/drm/asahi/g17/runtime/backend.rs: Registry::drain_compute_siblings() and Registry::rollback_unpublished_compute() now collect taken queues and displaced bindings into caller-owned [Option<T>; COMPUTE_CHANNELS_MAX] arrays (PerChannel<Uninstalled> and PerChannel<compute::Binding>), verifying free slots before mutating any channel so nothing allocates or drops under self.shared.state.lock().
    • Backend::finish_retired_compute() drops taken queues and cancels every reservation off-lock without short-circuiting on individual failures, closing the EINVAL owner-lockout leak across busy siblings (EAGAIN), partial rollback failures, and failed cancellations.
    • Removed unused Registry::compute_mut() and added tools/asahi/g17-compute-retired-tests.py (7 scenarios, 7 negative mutations) wired into tools/asahi/run-host-tests.py.
  • Incremental diff audit (e35ddb55bc59..df36284f753b): Verified Context::next_compute_identity() atomic shared ordinals/object IDs, QueueGuard::drop() cell stat sync, compute_direct() single-cell lock discipline and cross-channel barrier fallback, compute_exit.rs multi-channel kill-cookie propagation, compute_replay.rs per-QID replay prefix handling, and include/uapi/drm/asahi_drm.h bit 42.
  • Hardware rows & CI:
    • Exact-head Apple M5 Pro (T6050 / J714s / G17S B1) pass row at df36284f753b: native build clean, gpubench-vk ok (compute.heavy d4 8,171 GFLOP/s), Vulkan synchronization2.op.multi_queue 2,147 pass / 0 fail, RTC deep-sleep wake clean, 0 GPU/DART faults.
    • Exact-head MacBook Neo (J700 / G17P B1) combined Wave C pass row (7bb607c48427): 215/215 g17 host tests, 2,880/2,880 timeline semaphore CTS pass, 373 focused compute/sync CTS pass / 0 fail, 5/5 compute CRCs, 0 GPU faults / 0 AVCs.
    • Paginated CI check-runs at df36284f753b: 19/19 green (0 active, 0 failed), clean merge preview onto main.

@DjDeveloperr
DjDeveloperr dismissed satchlj’s stale review November 25, 2026 21:35

The merge-base changed after approval.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 25, 2026
Merge origin/main (f3bfe50) to keep the union of host test entries
in tools/asahi/run-host-tests.py after #3024, #3036, and #3023 landed.

Signed-off-by: Diljit Singh <[email protected]>
…sahi-g17-m5-sibling-compute

Bring in origin/main (f3bfe50) via the updated base branch so
tools/asahi/run-host-tests.py keeps the union of host test entries.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merged updated perf/asahi-g17-m5-direct-cross-qid-sources (c9d9d6be45d8, including main f3bfe5007089) into perf/asahi-g17-m5-sibling-compute at 75774d0dcebb (non-force-push, zero conflicts). All kernel source changes from df36284f753b are unchanged, carrying forward the J714s and J700 hardware verification rows.

@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 ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
@DjDeveloperr
DjDeveloperr merged commit 6d6e536 into main Nov 25, 2026
19 checks passed
@RyanTheTide
RyanTheTide deleted the perf/asahi-g17-m5-sibling-compute branch November 27, 2026 13:21
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-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.

2 participants