Repository navigation
drm/asahi: g17: link publications directly to timestamp writers and attach lazily - #3443
DjDeveloperr wants to merge 6 commits into
Conversation
…ttach lazily Avoid O(N^2) Publication link cliques and multi-millisecond event-worker stalls when deep timestamp-free chains queue behind pending timestamp writers: 1. Direct timestamp-writer linking (queue/mod.rs, job.rs): track inherited pending timestamp-writer publications in Fences::timestamp_publications and collect only actual timestamp writers (has_outputs()) or failed entries (status < 0) in EnqueueOrdering::build(), collapsing ~18,000 clique links per deeply pipelined frame to O(N). 2. Lazy successor attachment (completion/publication.rs): retain pre-allocated predecessor links on each successor with Link::target = None until finish() runs (preventing Arc self-cycles on unfinished teardown), fast-pathing cleanly settled predecessors via an Acquire load on settled_clean without locking them or draining eager successor lists on the event worker. Signed-off-by: DjDeveloperr <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
… chain Linking a command straight to the timestamp writers of the pending timestamp-free entries it covers dropped those entries from the chain. Such an entry can fail while its writer is still pending (its fence then still reads 0, so it is not linked as failed), or fail after the covering command was enqueued. Either way the covering command signalled success when the writer did, instead of inheriting the failure. Link the newest pending timestamp-free entry of each covered prefix that no newer linked entry covers. Each command records the prefix of its own engine it covers, and a linked entry reaches the entries it covers through its own links, so in-order submission adds one link per engine and no clique. These chain links are kept apart from the inherited writers, so later commands still flatten only to writers. Linked entries that have not retired keep their predecessors deferred, so bound how deep Publication::is_pending() follows them; a probe that stops early reports pending, which only links more. License the publication host test GPL-2.0-only, and test both failure orders and a chain-dropping mutation in KUnit and on the host. Signed-off-by: DjDeveloperr <[email protected]>
Publication::is_pending() settles a deferred timestamp-free publication once its predecessors are clean. Two cases were missing: A predecessor that released its successors early and then failed has pending and settled_clean both clear. The probe asked it, got "not pending", found it still unsettled and asked again, forever. Consume that link as terminal instead and keep PRODUCER_FAILED for finish(), so the probe ends and the failure is still published. Settling through the probe dropped the predecessor links but left successors that had already attached queued, so a successor that finished before the settlement waited for this command's own completion. Release them off-lock, as predecessors_done_ok() does. Add host tests for both cases. Signed-off-by: DjDeveloperr <[email protected]>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict — hold at 22a4e9c88267. The follow-ups fix the intermediate failure lost at 8442bb05b047, the retry loop after a late failure, and the host test license. One fence-progress blocker remains.
drivers/gpu/drm/asahi/g17/completion/publication.rs:348 attaches a finished successor S to timestamp-free B without subscribing B to its still-pending writer A. When A publishes successfully, S’s fence stays unsignalled until another caller probes or finishes B. The new host test (case 10) explicitly observes S’s zero fence status after A succeeds, then calls b.is_pending() to make the fence signal. A fence waiter does not perform that queue probe. On the previous eager path, A completing released B’s attached successors immediately. When the first successor actually waits on B, arrange notification from B’s pending predecessors. Test that S signals when A completes with no subsequent submission, probe, or B completion.
I checked the direct writer and error links, attachment and Arc ownership, terminal-error handling, and release ordering. The J714s candidate contains the original head. Both J714s and J700 need rows covering the revised runtime code.
… on it A timestamp-free publication links itself to its predecessors only at its own finish(), or when a probe settles it. A successor that finished first and queued on it therefore stayed unsignalled after the predecessors published, until that command retired or something probed it; a fence waiter never probes. When a waiter queues on an unfinished deferred timestamp-free publication, subscribe it to its predecessors right away, holding a sentinel as finish() does, so their completion settles it and releases the waiter. Subscriptions this starts in turn are bounded by the probe depth; a publication past the bound links at its own finish(), or when a probe settles it and releases what queued on it. Require in the host test that the waiter signals on the writer's completion alone, and cover the bounded chain. Signed-off-by: DjDeveloperr <[email protected]>
Subscribing a deferred publication when a waiter queues on it stopped four publications deep. Past that the intermediaries stayed deferred, so the writer's completion did not signal the waiter, and an intermediary failing later made that same waiter report the error. Subscribe iteratively instead: add_successor() only queues the link and reports whether the publication needs subscribing, and subscribe() walks a stack threaded through State::subscribe_next, linking each queued publication and pushing the deferred ones it reaches in turn. It neither recurses nor allocates, and each publication is queued at most once. Require in the host test that the writer's completion alone signals the waiter through 4, 5 and 6 deferred intermediaries, and that a later intermediary failure leaves it unchanged; both fail with the old depth limit. Signed-off-by: DjDeveloperr <[email protected]>
satchlj
left a comment
There was a problem hiding this comment.
Reviewed and host-tested at exact HEAD 69fd36afe7c4:
- Code review: forwarding only pending timestamp writers (
Fences::timestamp_publications+collect_publication_predecessors()) removes the O(N^2) clique across timestamp-free commands while preserving failed-entry propagation. Lazy attachment (deferred_links,settled_cleanfast path, and the intrusive non-recursivesubscribe_nextstack) avoids Arc cycles and stack/heap growth on deep pipelines, andpending_within()cleanly handlesfailed_after_release()and drops links off-lock. run-host-tests.py --only g17: 254/254 passed in 4 s.
|
Code review note at
Trace:
Gating |
The kernel prelude brings pin_init::Init::chain into scope, so `.iter().chain(...)` on the predecessor and chain link slices is ambiguous (E0034). Name Iterator::chain. Signed-off-by: DjDeveloperr <[email protected]>
|
J714s (MacBook Pro M5 Pro, T6050 / G17S B1) exact-head correctness row at
|
|
J700 (MacBook Neo, Apple A18 Pro
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
CODE-CLEAR at 1213e012b40c0d12b5662ebd6cd724a05fa55ef2. Writer completion now signals waiters across deep timestamp-free chains. I checked concurrent subscriptions, error propagation and teardown. No blocking findings.
Both exact-head runs passed with SLC enabled and reported zero CTS failures, GPU faults or recoveries. J714s passed the timestamp and synchronization cases. J700 passed 254/254 G17 host checks and 31,611 CTS cases, with all 22 benchmark rows passing and every CRC matching stock. J714s results · J700 results
satchlj
left a comment
There was a problem hiding this comment.
Re-reviewed at 1213e012b40c: the follow-up commit is a clean 3-line explicit Iterator::chain disambiguation in drivers/gpu/drm/asahi/g17/queue/mod.rs, preserving the verified deferred-subscription fixes, CODE-CLEAR review, and exact-head J714s + J700 hardware rows.
|
@DjDeveloperr this one doesn't merge mechanically any more. #3319 (merged 11-26) replaced the same timestamp-free chaining on |
What:
Stop building an all-pairs
Publicationdependency clique per frame on G17, and stop draining successor lists eagerly in the completion worker.queue/mod.rs,job.rs:Fences::timestamp_publicationscarries only the pending timestamp writers (has_outputs()) through timestamp-free commands, the same way timestamp waits are already inherited. Each command links directly to the pending timestamp writers instead of to every timestamp-free command in between, so a deeply pipelined GTA V frame drops from about 15,000-18,700KBox<Link>edges to one per real predecessor.PublicationChainlinks each command to the newest uncovered timestamp-free entry that is still pending (Fences::coversrecords how far a command's waits already reach), kept separate from the inherited writers. An earlier entry that fails before or after enqueue reaches every later command asPRODUCER_FAILED.completion/publication.rs: predecessor links are allocated up front and kept on the successor (deferred_links,target = None, so an unfinished drop leaves noArccycle). A predecessor that settled cleanly is recognised by anAtomicBoolread withAcquirebefore its lock is taken;publish(Err)clears it, so late failures still reach successors.DeferredBatch::finish()attaches only predecessors that are still pending or failed, and the probe ends on the first failed predecessor (Probe::Consumed) or releases a queued successor once its predecessor settles (Probe::Settled), so it never loops.in_order_writer_finish_drains_zero_deferred_links,deep_timestamp_free_chain_links_directly_to_writer_not_clique,timestamp_free_entry_failed_before_enqueue_fails_covering_successor,timestamp_free_entry_failing_after_enqueue_fails_covering_successor. Host testtools/asahi/g17-publication-direct-lazy-tests.py: 13 scenarios (failure before/after enqueue and after release, deep chains of 4-6 timestamp-free entries, queued-successor release) and 11 contract mutations, each caught (clique regression, failed-status propagation, eager attachment, unfinished-dropArcleak, late-error flag clearing, lockless clean-predecessor path, dropped chain link, retrying a failed predecessor, kept attached successors, missing and depth-bounded subscription).Tested:
7.3.0-m5-pr3443built on the M5 from this tree with the default's config, SLC on (MCC node set tookay,apple-mccallocation enabled), Mesa kit inst-A: Vulkan CTS 0 failed (synchronization smoke 12/12, basic 29/29, synchronization2*read_image_compute*412/412, occlusion_query copy 152 passed / 7 not supported, concurrent_queries 2/2, multiview queries 16/16, pipeline timestamp basic_graphics 80/80, image_to_image simple 19 passed / 4 not supported); gpubench-vkcompute.cull_mdiCRC 07f6c861 valid; chainbench_diag clean; 0 GPU faults, 0 recoveries. Row: drm/asahi: g17: link publications directly to timestamp writers and attach lazily #3443 (comment)g17-*passed;checkpatch.pl --strict0 errors, 0 warnings, 0 checks.Risk: two-way · G17 Macs (M5 Pro, Neo)
Not yet: