Skip to content

drm/asahi: g17: defer housekeeping across transient idle gaps - #3023

Merged
DjDeveloperr merged 27 commits into
mainfrom
perf/asahi-g17-m5-defer-idle-housekeeping
Nov 25, 2026
Merged

DjDeveloperr merged 27 commits into
mainfrom
perf/asahi-g17-m5-defer-idle-housekeeping

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What: Stacked on #2969. A completion that briefly left no work in flight (!in_flight) triggered housekeeping at once, bypassing the single-lock fast_done path and forcing a second device-mutex pass (full M5 report drains with three uncached core-power register reads, linger/pool/heap sweeps, teardown checks) on every sparse completion. Housekeeping is now gated on HOUSEKEEPING_NS (1 ms) plus explicit triggers, with a bounded delayed timer so idle cleanup, report drains and quiet-sleep transitions still run within 1 ms once work stops.

Tested: J714s M5 Pro (G17S B1), Aurora 7.3.0 M5 integration test kernels (builds 7 and 8): 0 GPU faults, 0 kernel warnings, Vulkan CTS 2,984/2,985 pass, 0 fail; sparse idle-wake latency +5.6 % to +7.2 % at 2 / 20 / 200 ms gaps, no regressions across the Vulkan and OpenGL suites. Host tests --only g17 110/110 pass (4/4 mutations killed).

Risk: two-way · G17 Macs: Neo (G17P) and each M5 board (the change sits in the shared G17 event worker).

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; failed systemd units not captured (SELinux is not enabled in the test kernel config).

After the main merge (11-25, main a73023bc5f1f): no conflicts.

Details

Stacking: stacked cleanly on #2969 (d13f2358d742, which builds on #2947 and #2955). The sole new commit on top of #2969 is drm/asahi: g17: defer housekeeping across transient idle gaps. Independent of the other M5 completion/cross-QID follow-up PRs; targets integration/aurora so Host tests CI runs on the full stack.

New commit: 6c2a20ce7b50.

This commit:

  • Extracts housekeeping_due() to gate housekeeping strictly on HOUSEKEEPING_NS (1 ms) plus explicit triggers (requested passes, recovery, pending teardown, and active capacity waiters), rather than firing immediately on transient !in_flight gaps.
  • Passes the true in_flight state to firmware.idle_check() on the fast_done path.
  • Adds deferred_housekeeping_delay() and a bounded HOUSEKEEPING_WORK delayed timer (Shared::queue_housekeeping(), cancelled in sleep_quiet()) whenever a pass defers housekeeping with no work remaining in flight, guaranteeing true idle cleanup, report drains, linger/pool expiry, and quiet-sleep transitions still run within 1 ms once work actually stops.
  • Adds host unit tests and 4/4 mutation controls in tools/asahi/g17-m5-idle-housekeeping-tests.py.

Reach beyond M5. housekeeping_due() and the deferred HOUSEKEEPING_WORK timer are not confined to the M5 direct-submit path. They sit in the shared G17 event worker, runtime_event_turn() in g17/runtime/events.rs. Its fast path runs on any compute completion (Service::complete_compute()) and its full pass runs on every event pass. So the change reaches every G17 part: G17P (Neo) and every M5 board, not just the M5 Pro. The non-M5 behaviour change is the same as on M5: a completion that leaves no work in flight no longer forces housekeeping at once; it runs within HOUSEKEEPING_NS (1 ms) through the timer. This PR has hardware rows for the M5 Pro only; G17P has not been run.

Evidence
  • Host tests (python3 -I tools/asahi/run-host-tests.py --only g17): 110/110 passed (g17-m5-idle-housekeeping-tests: base pass + 4/4 mutations killed: idle-forces-housekeeping, no-deferred-timer, hardcode-in-flight-true, skip-cadence-expiry).
  • Hardware (Apple M5 Pro / J714s / G17S B1): qualified in Aurora 7.3.0 M5 integration test kernel builds 7 and 8 (0 GPU faults, 0 kernel warnings, 2,984/2,985 Vulkan CTS passed with 0 failures); improved sparse idle-wake latency across 2 ms / 20 ms / 200 ms inter-submission gaps by +5.6% to +7.2% (363.7 -> 340.8 us, 537.8 -> 501.6 us, 418.9 -> 396.8 us) with zero regressions across Vulkan and OpenGL suites.

Regression tuple (pre-PR checklist §5)

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 kernels, builds 7, 8 and 9 (build 9 carries all five PRs: #3023, #3024, #3025, #3035, #3036)
Mesa test build 60a40c285f on builds 7/8; test build git-8956dffd84 (with aurora-silicon/mesa#793) on build 9
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 build 8: 2,984/2,985 passed, 0 failed; build 9: 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)

On M5 (G17S/G17C/G17D), compute_direct() returned None unconditionally
because M5 compute shares the per-priority outer work ring with render
and issues host-port gating and submission-history updates. As a result,
every steady-state M5 compute submission fell back to the global device
mutex (shared.state), serializing concurrent compute queues against each
other and against the event worker.

Add a dedicated port-level M5 outer-ring mutex (Port::m5_outer) ordered
after the compute queue cell and render publication lock (device mutex
-> compute cell -> port.render -> port.m5_outer -> port.qos/mailbox),
and expose non-interfering direct credit consumption on OuterCredits
(is_scoped() / consume_direct()) plus direct port views for M5's shared
outer ring and submission-history table.

Guard device-mutex M5 compute and render outer-ring publications with
m5_outer_lock(), reset the cached history geometry on recovery restart,
and allow steady-state M5 compute submissions to publish through
compute_direct() without taking shared.state. Add a KUnit test covering
direct credit consumption alongside OuterScope.

Signed-off-by: Diljit Singh <[email protected]>
Each completion pass in run_runtime_events() / runtime_event_turn()
previously took the global device mutex (shared.state) up to five times
and ran M5 firmware.drain_reports() (trace/statistics rings plus GPU
power register reads) on every completion interrupt, even during tight
compute loops where no render mask was pending.

Coalesce the worker_deferred take and empty-batch restore into the
existing device-mutex holds, avoid dropping and immediately re-acquiring
shared.state around a no-op observe_renders() when render masks are
zero, and throttle M5 post-signal report draining
(drain_post_signal_reports()) to the HOUSEKEEPING_NS (1 ms) cadence
while work remains in flight.

On recovery passes, drain post-signal reports before
service_runtime_recovery() resets firmware rings (matching the
unthrottled post-signal ordering and #2909) without double-draining in
housekeeping. Add host tests (g17-m5-direct-compute-tests.py) covering
mixed render/compute ring wrap, generation-change queued-claim handling,
concurrent direct/scoped credit safety, and post-signal/pre-recovery
report ordering.

Signed-off-by: Diljit Singh <[email protected]>
On M5 (G17S/G17C/G17D), render_direct() returned None unconditionally,
forcing every steady-state TA/3D render pass through the global device
mutex (shared.state) across prepare_render() and publish_render(),
serializing multi-pass graphics and multi-queue render submissions
against each other and the event worker.

Extend Port and OuterCredits so steady-state M5 render pairs can reserve
two slots on M5's shared outer ring under the existing lock order
(render publication lock -> m5_outer -> admission, QoS, mailbox), write
both Compute-master WorkSlots, issue the HardwareSubmission::advance_pair
host-port write, expose the retained pair while consuming two direct
credits, and record submission history and the pipe-2 doorbell (pipe 0
on J813) without holding shared.state across preparation or publication.

Bind M5 PB tokens via acquire_owner_bound() in lend_render(), track the
submitting CPU in render_direct(), and extend the asahi_g17_outer_credit
KUnit test to cover two-slot direct render credit consumption.

Signed-off-by: Diljit Singh <[email protected]>
Eliminate remaining mutex and MMIO overhead on the M5 direct submission
and completion paths:

- Coalesce M5 compute_direct() outer-ring publication, host-port
  submission, and submission-history update under one held Port::m5_outer
  guard (released before ringing the mailbox doorbell), avoiding repeated
  mutex round-trips and keeping m5_outer free during descriptor writes.
- Skip the uncached G17_CORE_POWER MMIO read in Port::note_gpu_activity()
  when back-to-back work falls within FIRMWARE_IDLE_OFF_MS.
- Expose Port::outer_domain() and Port::reserve_m5_outer() so steady-state
  prepare_compute() acquires M5 outer-ring availability and credits
  without locking shared.state.
- Track active, retiring, terminal, witness, replay and polling slots
  with bitmasks in scan_compute_summary() so steady-state completions
  avoid redundant full-registry ComputeCell locks, filter
  retain_render_completions() to matched render QIDs, move
  worker_deferred onto Shared, and complete steady-state pure-compute
  event passes in a single shared.state lock hold while preserving
  idle_check() timer scheduling.
- Use a per-CPU high-priority reclaim-safe workqueue for aurora_g17_events
  on M5 as on other G17 parts so enqueue_on(submitter) dispatches directly
  to the submitting CPU.

Signed-off-by: Diljit Singh <[email protected]>
…trips

Two sources of unnecessary host contention on single-die M5 multi-queue
workloads, plus M5 outer-credit locking fixes exposed by concurrent direct
compute and device-mutex publishers:

1. creator_cluster_scheduling() restricted every drm_sched ordered
   submit workqueue on M5 to Cpumask::cluster_of(CpuId::current()) at
   queue creation time. That pinning prevents cross-die migration on
   multi-die M5 Ultra (num_dies > 1), but on single-die M5 parts
   (num_dies == 1) queues created on one main thread all get pinned to
   a single CPU cluster and contend when submitted from worker threads
   across clusters. Keep event-work submitter tracking on all M5 parts
   and restrict scheduler clusters only when num_dies > 1.
2. compute_direct() previously ignored the M5 OuterClaim already
   reserved in self.outer_compute during prepare_compute() and called
   port.reserve_m5_compute(), causing a redundant Port::m5_outer lock
   round-trip, double-booked outer-ring slots, and an unused-claim
   availability wakeup on every direct compute submission. Reuse the
   held self.outer_compute claim when its remaining count and priority
   match before falling back to port.reserve_m5_compute(), and restore
   any unspent held claim back into self.outer_compute outside
   cell.lock() when compute_direct() falls back to the device-mutex
   path so pre-reserved credits are preserved without spurious wakeups.
3. Serialize device-mutex OuterClaim reservations (Backend::claim_outer)
   and OuterScope entry/Drop transitions (Port::outer_scope /
   PortOuterScope) under Port::m5_outer so Credits::reserved[] and
   Credits::scoped never race against concurrent direct M5 reservations
   (Port::reserve_m5_outer / Port::reserve_m5_render_locked).

Signed-off-by: Diljit Singh <[email protected]>
Event passes previously treated any completion that momentarily left no
work in flight as an immediate housekeeping trigger, bypassing the
single-lock fast_done path and forcing a second device-mutex pass with
full report drains (including three uncached core-power register reads),
linger/pool/heap sweeps, and teardown checks on every sparse completion.

Gate housekeeping strictly on HOUSEKEEPING_NS (1 ms) plus explicit
triggers (requested passes, recovery, pending teardown, and active
capacity waiters). Pass the true in_flight state to idle_check() on the
fast path and arm a bounded HOUSEKEEPING_WORK delayed timer whenever a
pass defers housekeeping with no work remaining in flight, so true idle
cleanup, report drains, linger/pool expiry, and sleep_quiet() continue
to run within 1 ms once work actually stops.

Add host tests and mutation controls in g17-m5-idle-housekeeping-tests.

Signed-off-by: Diljit Singh <[email protected]>
…lock release

Steady-state render submissions and completions previously incurred three
avoidable lock holds and wakeups on the hot path:

1. runtime_event_turn() always exited its fast path whenever any render
   completion mask arrived, forcing four separate Shared::state mutex
   acquisitions per render retirement (drain events, drain deferred
   errors, observe_renders(), and final idle/housekeeping pass).
2. DirectHost::notify_render() held both Port::m5_outer and Port::render
   across mailbox doorbell I/O even after outer ring producers, credits,
   and hazard ordering were already committed.
3. Availability::advance() unconditionally acquired the waiter mutex even
   with zero waiters, and Shared::note_changed() unconditionally called
   changed.notify_all() even when no thread waited on the condvar.

Add Firmware::try_fast_observe_render() to retire healthy coalesced ready
render completions (bounded by RENDER_SLOTS and preallocated DeferredBatch
room) directly inside runtime_event_turn()'s single device-mutex hold
under a pre-acquired preparation epoch, falling back to observe_renders()
on any pending error, timeout, close, growth, replay, terminal fault,
deferred-room shortage, or remaining backlog. Fold slow-path deferred
error draining and rescan checks into runtime_event_turn()'s existing
mutex holds so observe_renders() takes only one state lock per turn.

Release m5_outer (after submission history) and render in reverse order
before port.notify() in DirectHost::notify_render(). Keep Availability's
generation bump lock-free when has_waiters is false (preserving Dekker
ordering against wait()), and wrap Shared::changed in TrackedCondVar so
zero-waiter notify_all() skips the condvar waitqueue lock.

Add host unit tests and mutation controls in g17-m5-render-fast-done-tests.

Signed-off-by: Diljit Singh <[email protected]>
Since the event queue became per-CPU on every G17 part, M5's
queue_event_records() aims the event work at the CPU that last published
work with queue_work_on() on a bound pool, so the worker runs on that
very CPU. A thread that publishes directly from its submit ioctl is then
preempted by every completion: the event worker has the higher priority,
and the completion interrupt is either taken on the submitter's CPU (the
AIC cannot be steered) or reaches it by an IPI.

The preemption often lands in the middle of a direct compute
publication, which holds the compute cell's mutex across
Queue::publish(), and the event pass takes that cell next. Its owner is
not running, so the worker cannot spin on it: it sleeps, the submitter
resumes, and its mutex_unlock() wakes the worker, which preempts it
again. Each completion costs the submitter two context switches.

Profiled on M5 Pro, one thread keeping 16 light compute submissions in
flight took 18.0 us per submission, 11.8 us of it in the submit ioctl,
with 93,000 function-call IPIs per second (1.7 per submission), 0.82
context switches of the submitting thread per submission and an IPC of
1.12. __schedule took 8.9% of the cycles, preempt_schedule_irq 7.0% and
mutex_unlock 4.4%, all in the submitter's ioctl after an interrupt. Two
queues signalling each other showed the same profile. With 64 in flight
the scheduler's worker publishes instead, so the event work lands on its
CPU, beside the submitting thread rather than on it: 0.26 context
switches per submission, an IPC of 2.39, 3.5 us in the submit ioctl and
11.4 us per submission.

Make the queue unbound again where the event work follows the submitter,
as it was on M5 before. Aimed at a CPU, an unbound queue takes only that
CPU's affinity pod, the CPUs sharing its L2, and the scheduler wakes the
worker on an idle CPU of the pod. Completion processing stays in the
submitter's cluster and on its die, which is why it follows the
submitter, and a running submitter is left alone: a worker that meets
the cell lock spins on its running owner. Other G17 parts keep the
per-CPU queue, where the event work runs on the CPU that queues it, as
on system_highpri_wq. The queue stays reclaim-safe and high priority.

Shared::new_events_queue() derives the queue's kind from the same
follows_submitter value that Shared keeps, so the two cannot disagree.

The per-CPU queue reached M5 with "drm/asahi: g17: reduce M5 direct
submit and event lock overhead", which this series builds on and which is
still under review (#2955). This change takes back that
part of it on M5 only, and is not tagged as a fix since that commit is not
in any merged tree yet.

Add a host test that compiles the queue choice, the event work's
queuing and the submitter tracking against a model of where the kernel
runs the woken worker: on M5, a completion taken on the submitter's CPU,
on another cluster or on the other die runs in the submitter's pod
without preempting it, and elsewhere it runs on the queuing CPU. Its
mutations include the previous per-CPU queue.

Signed-off-by: Diljit Singh <[email protected]>
…turned

The direct render path lends an owner's pair out of the registry under the
device mutex, prepares and publishes into it without that mutex, and puts
it back under the mutex again. An event pass that meets a completion of a
lent pair skips the pair and records the completion for its borrower
(missed_event); the return then requested another event pass.

Since M5 event work runs beside the submitter rather than on its CPU, that
pass starts on another CPU while the submitter goes straight on to its
next publication, whose lend takes the device mutex first and lends the
same pair again: the pass finds it lent once more and records the
completion again. A client publishing a run of passes keeps its pair lent
for most of that run, so a completion of its previous submission retires
only once the whole run is published. A client keeping two multi-pass
submissions in flight waits for the older one's fence before it submits
again, so each of its submissions waited for the publication of the next
one: such clients ran 8 to 31% slower than with the event work on the
submitter's CPU, where the requested pass preempted the submitter before
its next lend, while clients with one submission in flight ran 5% faster.

Each such pass also took the device mutex four times: its single-hold
fast path fell back to the full pass, which takes the mutex three more
times to find nothing to retire and arm the rescan poll. It did the same
whenever a retirement left later work of the pair in flight with its
completion noted, the steady state of a pair with several renders in
flight. Those holds contend with the publisher's lends and returns.

- The return observes the pair itself, in the hold that put it back:
  Firmware::observe_returned_render() runs the event worker's single-hold
  retirement (fast_observe_renders(), which try_fast_observe_render() now
  shares) for that slot alone, under the same steady-state checks of
  every slot, with a live preparation lease, outside recovery and a
  crash, into a collector of the worker's size (Shared::render_collector)
  that is taken only with try_lock() and finished after the device mutex
  is dropped. A state the fast path leaves to the full pass (another
  slot's error, timeout, close or growth, a replay, recovery, a fault, no
  room), or a busy collector, requests the event pass as before. As on
  the watchdog's final scan, the retirement runs off the event worker:
  completion fences have contexts of their own and ordered outputs
  publish only after their predecessors, so nothing signals out of order.
- render_needs_rescan() no longer counts a borrowed pair whose completion
  is recorded for its borrower: every borrower's return (direct,
  preparation, growth) observes it or requests a pass.
- The fast path retires every ready observation in its hold instead of
  stopping at the first retirement that leaves noted work in flight, and
  reports that state as Rescan rather than Fallback. runtime_event_turn()
  then ends the pass in its first hold and arms the rescan poll, which is
  all the full pass would add; so does a pass whose render completions
  found nothing to retire because their pairs are lent (Idle with render
  masks). A returned pair in that state also arms the poll.

The publication itself still takes the device mutex twice: the free-list
lease, the parameter-buffer reference, the admission hold and the
registry entry of a loan are device-wide state that retirement, growth,
parking and teardown change under it.

Host tests: tools/asahi/g17-render-return-observe-tests.py compiles the
production take_pair(), return_pair(), take_missed_event(),
retain_render_completions(), render_needs_rescan() and observation loop
against host stubs: a completion owed to a borrower needs no rescan and
ends the worker's pass, a return retires everything that completed during
its loan (two completions too) in order and only in its own slot, every
non-steady state falls back, a fault is settled, and a publisher, an event
worker and a GPU thread retire 4000 commands exactly once and in order,
the returns retiring some; structural checks cover render_direct()'s
guards, try_lock() and off-lock finish and the event pass's single-hold
exit (13 mutation controls). g17-m5-render-fast-done-tests.py follows the
shared loop.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr
DjDeveloperr force-pushed the perf/asahi-g17-m5-defer-idle-housekeeping branch from 6fd03a4 to 6c2a20c 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 c5e540f9: ready to merge

Check Detail
CI at head ok 19 checks passed
Review ok review verdict MERGE at c5e540f9; no GitHub approval yet, so approve it or merge through the bypass (--admin)
Requested changes ok none
Hardware row at head ok comment at c5e540f9
Conflicts ok none
PR text ok Risk: two-way · G17 Macs: Neo (G17P) and each M5 board (the change sits in the shared G17 event worker).

Areas: area:gpu
Merge: gh pr merge 3023 --merge (Owners and Core through the bypass: add --admin).

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 a4b51cdff0a7): 6fd03a4cef14 → 6c2a20ce7b50.

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 #2969 (d13f2358d742). Every other commit is unchanged (git range-diff: patch-identical).

Host tests: tools/asahi/run-host-tests.py --only g17 110/110 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
Bring in main up to a73023b (among others the G17 submit-latency,
compute completion fast path, completion cluster and page-fault blame
work).

Conflict:
- drivers/gpu/drm/asahi/g17/runtime/events.rs: main now drains the
  trace and statistics reports after the pass's completions are
  signalled on every G17 (c56132f, from #2909), where it was M5
  only. This branch throttles that post-signal drain to the
  housekeeping cadence while work is in flight and drains first on a
  recovery pass, through drain_post_signal_reports(), which drained on
  M5 only because only M5 deferred the reports. As every G17 defers
  them now, the helper and its is_m5() check go away and the throttled
  sites call drain_reports() directly, as planned when this branch was
  reconciled with #2909. g17-m5-direct-compute-tests.py checks the
  same order under the new name.

Signed-off-by: Diljit Singh <[email protected]>
…5-direct-render-and-locks

Bring in the base branch, which now carries main up to a73023b.

Conflicts:
- drivers/gpu/drm/asahi/g17/runtime/events.rs: as on the base branch,
  every G17 now drains its reports after signalling, so the M5-only
  drain_post_signal_reports() goes away and the recovery and
  housekeeping sites call drain_reports(). This branch's single-lock
  fast path for pure-compute passes is kept as it was; it skips the
  drain only while housekeeping is not yet due, as the slow path does.
  g17-m5-direct-compute-tests.py follows the new name.
- drivers/gpu/drm/asahi/g17/port.rs: main skips the core power register
  read in note_gpu_activity() within the firmware's idle-off delay
  (99b0b4c), as this branch did; main's version is kept.
- drivers/gpu/drm/asahi/g17/mod.rs: main places the event work in the
  last submitter's cluster on every G17 and drops follows_submitter
  (6ff7967), keeping M5's event queue unbound so the worker runs
  in the submitter's affinity pod. That replaces this branch's switch
  of M5 to the per-CPU queue, so main's queue choice is kept, without
  follows_submitter. The worker's preallocated deferred batch stays on
  Shared, as this branch moved it.

Signed-off-by: Diljit Singh <[email protected]>
…ahi-g17-m5-multiqueue-contention

Bring in the base branch, which now carries main up to a73023b.

Conflicts:
- drivers/gpu/drm/asahi/g17/mod.rs, runtime/backend.rs: main restricts
  every G17's scheduler queues to their creator's cluster and drops
  follows_submitter (6ff7967). This branch restricts them on M5
  only where it has more than one die, so the queues of a single-die M5
  are not all tied to the cluster of the thread that created them.
  Both are kept: pin_scheduler_cluster is now !m5 || id.num_dies > 1,
  so every other G17 keeps main's restriction and a single-die M5
  keeps this branch's unrestricted queues. Without a cpu-map a queue
  stays unrestricted anyway, as on main.
  g17-m5-multiqueue-contention-tests.py checks the new expression, and
  its pin-single-die mutation now pins every queue.

Signed-off-by: Diljit Singh <[email protected]>
…i-g17-m5-render-fast-done

Bring in the base branch, which now carries main up to a73023b.
No conflicts.

Signed-off-by: Diljit Singh <[email protected]>
…-m5-events-and-render-return

Bring in the base branch, which now carries main up to a73023b.

Conflict:
- drivers/gpu/drm/asahi/g17/mod.rs: this branch makes M5's event queue
  unbound again after the base branch had made it per-CPU, and keys the
  queue kind and the submitter tracking to follows_submitter. main
  (6ff7967) already keeps M5's queue unbound, records the
  submitter on every G17 and drops follows_submitter, and the base
  branch no longer makes M5 per-CPU. So the queue choice stays as
  main's, built through this branch's new_events_queue(), which now
  takes m5 and documents where the event work runs on main's
  cluster-aware queuing. The render collector of the lent-pair return
  path is kept, and so is the base branch's pin_scheduler_cluster.
  g17-m5-event-placement-tests.py now models main's queuing (a mock
  cluster_of(): work stays local in the submitter's cluster and is
  aimed at the submitter from another one) and checks that other G17
  parts follow the submitter's cluster too; the record-always mutation
  becomes record-never, as every part records the submitter now.

Signed-off-by: Diljit Singh <[email protected]>
…sahi-g17-m5-defer-idle-housekeeping

Bring in the base branch, which now carries main up to a73023b.
No conflicts.

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 merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
"drm/asahi: g17: reduce M5 direct submit and event lock overhead" moved
every caller of Port::note_m5_submission_history() to the variant that
runs under a held m5_outer, which left the unlocked wrapper unused and
the build warning that it is never used. Remove it and describe the
locked variant on its own. No functional change.

Signed-off-by: Diljit Singh <[email protected]>
…ahi-g17-m5-multiqueue-contention

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

Signed-off-by: Diljit Singh <[email protected]>
…i-g17-m5-render-fast-done

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

Signed-off-by: Diljit Singh <[email protected]>
…-m5-events-and-render-return

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-defer-idle-housekeeping

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 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 c5e540f93063

Blockers: none

Checked: incremental diff against #3036 (drivers/gpu/drm/asahi/g17/mod.rs, runtime/events.rs, sleep.rs), timer lifecycle on suspend and teardown, and CI/hardware evidence.

Evidence
  • Incremental audit vs #3036 (69f46da9a86f):
    • g17/mod.rs: Adds HOUSEKEEPING_WORK (DelayedWork<Shared, 7>) on workqueue::system_highpri() via queue_housekeeping() (delay_ns.div_ceil(1_000_000).clamp(1, u32::MAX)), skips queue_events() when this.sleeping(), and cancels it via disable_timer(&self.shared.housekeeping_timer) in Gpu::drop.
    • g17/runtime/events.rs: Factors housekeeping_due() and deferred_housekeeping_delay(), passes actual in_flight to firmware.idle_check(now, in_flight) on the fast_done path so idle timers still arm when !in_flight, and arms queue_housekeeping(delay) whenever !in_flight && !housekeeping_ran so deferred report drains, linger/pool/heap trims, and quiet-sleep transitions still complete within HOUSEKEEPING_NS (1 ms).
    • g17/sleep.rs: Cancels self.housekeeping_timer in join_event_workers() before flush_work(&self.work), matching poll and idle.
  • CI & Hardware: All 19/19 paginated checks passing (0 active / 0 bad); exact-head J714s M5 Pro (G17S B1) fleet candidate hardware pass row (0 GPU faults, 0 kernel warnings, Vulkan CTS 2,984/2,985 pass, 0 fail) and 110/110 host tests (4/4 mutations killed) reported.

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

Verdict: FINISH, then merge at c5e540f930639490705bd334c0da7ab0394e9af7.
Blockers: The changed event worker needs the current Neo G17P regression row. Land the dependencies before merging this PR, including #2969 and the #3036 event changes it carries.
Checked: J714s ran this exact head in b7b130a75bab. Independently ran the host fixture and verified all four runtime mutation failures. The timer wakes the regular worker, keeps recovery, teardown and capacity waits on the immediate path, and is joined or disabled on sleep and removal.

Evidence

The sparse wake results improve from 363.7 to 340.8 µs, 537.8 to 501.6 µs, and 418.9 to 396.8 µs at the reported 2, 20 and 200 ms gaps. The nominal cadence is 1 ms. The delayed-work deadline is tick-rounded and subject to scheduling, so please describe it as a target cadence in the PR. The functional wait paths do not rely on a hard 1 ms deadline.

J714s row

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label 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 c5e540f930639490705bd334c0da7ab0394e9af7 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.

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

The merge-base changed after approval.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Follow-up (J700 origin/main 7c9d9adcda5a control kernel arm): Wave C cleared — both the compute.light queue/d2 regression and the GB6 Particle Physics +5% increase vs shipped 7.3.0-41 are already present in plain origin/main (7c9d9adcda5a), built with the identical -41 config and toolchain:

  • compute.light queue/d2: -41 35.1–35.6 µs (0/14 slow reps, submit CPU 8.9–9.8 µs) vs plain origin/main 44.1 µs (4/8 reps lost two-deep overlap at 46.2–52.5 µs, submit CPU 10.9–12.6 µs) vs Wave C 47.6 µs (2/3 slow reps 47.6–47.8 µs, submit CPU 11.9–12.6 µs).
  • GB6.7.1 Vulkan: Particle Physics -41 142.1 / 142.9 ms vs plain origin/main 149.0 / 150.9 ms (+5%) vs Wave C 150.5 ms; Edge Detection -41 26.1 / 26.2 ms vs plain origin/main 26.2 / 26.7 ms vs Wave C 26.5 ms.
  • rt.scene raster (176.9 vs 177.4 fps), copy.bw buf2img d1 (1552.8 µs on both), and compute.heavy alu queues/d2 (1213.6 vs 1219.5 µs) likewise match origin/main.
  • Clean boot/restore to 7.3.0-41, 0 GPU faults / 0 WARNs / 0 AVCs, 5/5 compute CRCs.

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 c5e540f93063

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.
  • 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.
  • Exact-head hardware rows pass on both J714s (M5 Pro) and J700 (Neo, including origin/main control arm clearing Neo performance parity), and all paginated CI checks are green.
Evidence
  • Incremental diff audit above #3036 (5 files):
    • drivers/gpu/drm/asahi/g17/mod.rs and sleep.rs: adds HOUSEKEEPING_WORK (DelayedWork<Shared, 7>) on workqueue::system_highpri() via queue_housekeeping(), skips queueing when this.sleeping(), cancels it in join_event_workers() before flush_work(), and disables it in Gpu::drop().
    • drivers/gpu/drm/asahi/g17/runtime/events.rs: factors housekeeping_due() and deferred_housekeeping_delay(), keeps requested passes, recovery, teardown, and capacity waiters immediate, passes actual in_flight to firmware.idle_check(), and arms queue_housekeeping(delay) when !in_flight && !housekeeping_ran so deferred cleanup still runs at the HOUSEKEEPING_NS target cadence.
  • Hardware rows & CI:
    • Exact-head Apple M5 Pro (T6050 / J714s / G17S B1) pass row in fleet candidate b7b130a75bab (gpubench-vk ok, Vulkan CTS 0 fail, 0 GPU/DART faults).
    • Exact-head MacBook Neo (J700 / G17P B1) combined Wave C pass row (7bb607c48427: 2,880/2,880 timeline semaphore CTS pass, 373 focused compute/sync pass / 0 fail, 5/5 compute CRCs, 0 GPU faults / 0 AVCs) plus follow-up origin/main 7c9d9adcda5a control kernel arm confirming zero Wave C Neo regression.
    • Paginated CI check-runs at c5e540f93063: 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 ready-to-merge Meets the merge policy: merge it (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 25, 2026
@DjDeveloperr
DjDeveloperr merged commit f3bfe50 into main Nov 25, 2026
26 of 28 checks passed
DjDeveloperr added a commit to techmore/linux that referenced this pull request Nov 26, 2026
Merge origin/main (f3bfe50) to keep the union of host test entries
in tools/asahi/run-host-tests.py after aurora-silicon#3024, aurora-silicon#3036, and aurora-silicon#3023 landed.

Signed-off-by: Diljit Singh <[email protected]>
@RyanTheTide
RyanTheTide deleted the perf/asahi-g17-m5-defer-idle-housekeeping 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) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants