Repository navigation
drm/asahi: g16: cut the added latency of short and interleaved submits - #4034
DjDeveloperr wants to merge 5 commits into
Conversation
…tion On an idle-to-active submission (!had_flights with a flight published, such as d=1 workloads and sync.signal host after its 200 us spin), submit_locked() previously checked housekeeping_due against the 1 ms HOUSEKEEPING_NS interval and immediately queued poll_now() onto the submitting CPU. Because the new single flight is still executing on the GPU, FAST_POLL_WORK immediately entered poll_step() without retiring anything and ran run_housekeeping() (session.check(), objects.health(), service_power(), auxiliary ring drains) under Shared::state right in the middle of the flight, blocking the incoming EP 0x20 completion and userspace wakeup. Skip the eager housekeeping poll_now() kick when transitioning from idle to active (!had_flights && !flights.is_empty()). submit_locked() already arms the resnap hrtimer (default 100 us, tunable 25-1000 us) and 1-jiffy backup poll, so short d=1 flights complete on EP 0x20 and wake userspace via complete_all() before deferred housekeeping runs. Long flights still service housekeeping on a later poll tick once the 5 ms ACTIVE_HOUSEKEEPING_NS deadline elapses (the first resnap tick can precede that deadline), and active bursts (had_flights) keep the 5 ms ACTIVE_HOUSEKEEPING_NS cadence unchanged. Add a host selftest regression verifying both idle-to-active suppression and idle no-flight housekeeping delivery. Signed-off-by: DjDeveloperr <hey@djdev.me>
…eues can_defer_busy_coalesce() holds a single-queue submission for up to COALESCE_WINDOW_US (18 us) when the queue already has >= 2 commands of that class in flight so consecutive same-class submits fold into one multi-command flight. When the same queue already has active flights of the other engine class (such as single-queue compute/render interleaving in concurrent.cr interleave), the next submit alternates classes and cannot fold, so holding for 18 us only stalls cross-engine overlap. Bypass busy coalescing in can_defer_busy_coalesce() whenever the other engine class is currently active in flights, and extend test-publication.py to cover same-queue interleaved C+R bypass in both directions. Signed-off-by: DjDeveloperr <hey@djdev.me>
G16 logical queues currently allocate their ordered drm_sched submit workqueue with OwnedQueue::new_ordered_reclaim() (normal nice-0 CFS priority) and unconditionally restrict it to the creating CPU's cluster. When a host-signalled or dependency-blocked submission wakes via drm_sched_entity_wakeup() (such as sync.signal host after DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL), the submit kworker competes at normal CFS priority with busy application threads on the same cluster before running SchedJob::run() and ringing the doorbell. Switch Scheduler::new() to OwnedQueue::new_ordered_highpri_reclaim() (WQ_MEM_RECLAIM | WQ_HIGHPRI) and restrict to the creating CPU's cluster only when cluster.weight() > 1, matching g17/job.rs. Raising worker priority reduces contention with normal-priority threads, though scheduler latency remains possible. Add a host selftest regression executing production Scheduler::new() for both multi-CPU and single-CPU cluster topologies. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed 1408ae8. The mixed-flight checks bypass a wait that cannot fold the head job. Idle-to-active submit keeps the completion and timer paths for housekeeping, and the high-priority worker retains cluster affinity where topology permits it. Hardware A/B is pending.
|
J516s (M3 Pro) g16batch row: FAIL (judge exit 1). Except for one CPU-time flag that looks like noise, every failure also happens on base. For this PR: Kernel Same on both arms:
Why the judge says FAIL:
The J516s is back on its stock kernel ( |
|
J516s |
|
Both J516s arms lost the device on the 2.5 s long job. The remaining row at |
J773g (Mac mini M4, T8132, G16G B0)
|
|
The long-job failure in the g16batch row comes from the test, not the driver.
New kit: |
|
Hardware row at head Kit: Boots:
|
|
J773g (Mac mini M4, 27.2) row at head e492e5d: FAIL, so not for merge as is.
|
The matched J773g ABBA run found idle.wake d1 wake latency increased by 8.4% at a 20 ms gap. Awake latency matched the control. Restore the previous idle-to-active housekeeping path while keeping the mixed-flight coalescing and high-priority submit worker changes. The poll-retire host fixture passes all 44 remaining cases. The removed case asserted that the idle-to-active path suppressed housekeeping. Signed-off-by: DjDeveloperr <hey@djdev.me>
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 4fbf8db84b59af450d75f8da76d2a20ca9dae960
Checked: The opposite-engine test is reached only when the active flights belong to the submit queue. Single-engine coalescing and the idle-to-active housekeeping path are preserved. The workqueue is still ordered and reclaim-capable, with high priority and affinity limited to multi-CPU clusters. Exact-head Host tests passed.
|
Hardware row at head Matched
Deciding gate & gpubench-vk ABBA:
Bounded long-job (
|
|
J773g ( Preserving the earlier
|
|
The current matched J516s pins are main Exact-head PR text has since passed, as have Apple Build, Host Tests, and Asahi KUnit. The J516s matched run is the remaining merge gate. |
What: In the shared G16 submit path, bypass the coalescing delay for mixed render and compute flights and run the submit worker at high priority. This revision restores the original idle-to-active housekeeping behavior after the previous J773g ABBA measured an 8.4% wake-latency regression at a 20 ms idle gap.
Tested: At
4fbf8db84b59, the poll-retire host fixture passed 44/44. In the candidate merged onto main11306b42248e,test-job-failure.pypassed 29/29 andtest-publication.pypassed 94/94.J773g at
4fbf8db84b59passed the matched four-boot ABBA 20 ms idle-wake gate (184.93 to 185.48 µs, +0.30%), bounded long jobs and s2idle. The separate zero-gap burst was 114.74 to 142.60 µs (+24.28%). The warmed samples had overlapping ranges and came from unmatched runs. J773g receipt.J773g's controlled zero-gap ABBA passed on
f02bd68a08cbawith scheduler commit41bfeb93567bin both arms. With equal warmup, wake-latency deltas were +0.86% on P-cores, −1.67% on E-cores and +1.16% unpinned. Cold-idle pinned runs improved by 1.68% to 3.06%. All four boots had zero GPU faults, recoveries or hang kills. Controlled J773g receipt.Risk: two-way · M4 (T8132) and M3 (T8122, T6030), which share the G16 backend.
Not yet: The shared J516s matched baseline and candidate run is pending. Use main with scheduler commit
41bfeb93567band the shared VM guard update from #4357 in both arms.Details
can_defer_busy_coalesce()holds a single-queue submit for up to 18 µs so the next one can fold into the same flight. When that queue also has work of the other engine in flight, the next submit alternates and cannot fold, so it is no longer held. The function already requires every active flight to belong to the same queue, so another process's work never turns folding off.drm_schedsubmit workqueue becomesWQ_HIGHPRI, and it is pinned to the creating CPU's cluster only when that cluster has more than one CPU.Evidence
Hardware, supporting only: J773g, gpubench
7a0dfcf8. Stock kernelefed1ae377baon 12-01 (Mesadfc5b9016749), against the 16-commit tree53599499071aas a module on kernel6c83a2a64539on 12-02. These are different boots and base kernels, and the stack holds other changes, so this is not an A/B of this PR. All CRCs were valid.sync.signalhost d1, latencyconcurrent.crinterleave d4Host tests: the idle-to-active housekeeping rule and the idle delivery, the interleaved bypass in both directions, and
Scheduler::new()on single-CPU and multi-CPU clusters.Checks ran on main
d1ae4f292b93plus this branch.