Repository navigation
Conversation
…ic phase Defer predecessor attachment in Publication so in-order command completions avoid locking predecessors during enqueue and avoid draining eager successor lists on the completion worker: - Keep pre-allocated predecessor links on the successor in State::deferred_links with Link::target = None so an unfinished drop never forms an Arc cycle. - Replace separate atomic pending/clean flags with a single AtomicU8 phase (PHASE_PENDING, PHASE_SETTLED_CLEAN, PHASE_FAILING_PENDING, PHASE_FAILED_PENDING, PHASE_FAILING_AFTER_SETTLE, PHASE_FAILED_AFTER_SETTLE) so lockless readers in is_pending(), link_deferred(), and failed_after_release() never see conflicting states. In-order successors skip locking cleanly settled predecessors via one Acquire load on PHASE_SETTLED_CLEAN. - Revoke upstream_released and transition to PHASE_FAILING_* inside claim_locked() before publish(Err) signals the error fence off-lock, so late attachments wait on state.successors until state.published is recorded, queries see is_pending() == true, and probes wait until publish(Err) transitions to PHASE_FAILED_*. - When an out-of-order waiter queues on a deferred timestamp-free publication, subscribe the deferred chain iteratively through State::subscribe_next (no recursion, no allocation, no depth bound), so writer completion alone releases the waiter. - Bound Publication::is_pending() probing (PENDING_PROBE_DEPTH), consume published failures without looping, and release any already-attached successors when a probe settles a clean chain. Based on the lazy publication attachment design from #3443 by DjDeveloperr, split out cleanly from the queue-side clique reduction handled independently in #3681. Add KUnit tests and the g17-publication-lazy-tests.py host test with contract mutations. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
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 76b855c. Deferred links gain their target after being moved out of the successor. The sentinel covers immediate notifications while the links are attached, and late subscribers wait for publication of a claimed error. The same-engine queue path rechecks completion status before bypassing the host wait. The reported J716c CTS and arm64 KUnit results exercise this head. J700 coverage is pending.
|
Checked Merge. #3681 should land first. After it, this PR conflicts only in Correctness. I ran the real publication and ordering code of main, #3681, this PR and both together against each other on the host (20,000 random command sequences without failures, 60,000 with failures, 118,000 commands accepted while a failure was being published, plus a threaded run):
Cost (host model on x86, so compare the columns, not the numbers). With #3681 a command links only the newest earlier command, so
So on top of #3681 this mostly trades a 19 µs worst completion for a slower submit. Also, after a writer completes with N commands in flight, about N/4 later commands still chain (none on main), because the probe stops four deep and Settling oldest first before the newest-first walk, with a probe depth of 0, removes the extra chaining and cost 29 µs instead of 74 in the 600 case. That is a quick test, not a patch. The A/B on top of #3681 should include submit time ( A behaviour change, not blocking. A writer succeeds, then P fails, then C (waiting for P) succeeds, all accepted before the writer finished: on main C succeeds, here C is cancelled, because C's link to P is still deferred when P fails. It needs a real failure, but it's different from eager settlement unless something probed P in between. Rows. The J716c result ran without #3681, so it doesn't cover the merged head. Owed: J700, and the A/B. No J773g row: T8132 runs |
|
We carry this PR in our unified daily kernel across J716c (M5 Max, T6050), J713 (M4 Air, T8132), and J313 (M1 Air, T8103) alongside Deferring publication predecessor attachment and tracking publication state in a single atomic phase avoids locking settled predecessors on the in-order submit path and eliminates eager successor-list draining on completion, pairing cleanly with Booted and verified on J716c, J713, and J313 (5/5 Vulkan CTS smoke pass on all three Macs, zero GPU errors). |
|
Forward-merged |
Keep main's publication reach tracking alongside the single-atomic phase. Preserve both the reach initializer and the lazy links. Signed-off-by: DjDeveloperr <hey@djdev.me>
What: Defer predecessor link attachment in G17
Publicationso in-order command completions skip predecessor mutex locks at enqueue and avoid draining eager successor lists on the completion worker. Split out from #3443 (based on @DjDeveloperr's lazy-attachment design) as a standalone change independent of #3681's queue-side link reduction and producer failure log.Tested: J716c (16" M5 Max, T6050 / G17C) at exact head
76b855c7237e, SLC enabled (32 planes), default command line, Borealis system Mesa: booted cleanly to desktop, Vulkan CTS 25,017 cases (24,985 Pass, 32 NotSupported, 0 Fail, 0 Crash, 0 DeviceLost), 0 GPU faults or recoveries, 0 new kernel errors. Arm64 Asahi KUnit 579 tests (574 passed, 5 skipped, 0 failed); G17 host suite 343/343 passed (g17-publication-lazy-tests: 10/10 including all 9 contract mutations).Risk: two-way door · G17 Macs (M4, M5, Neo)
Not yet: J700 / M4 hardware rows; combined performance A/B on top of #3681.
Details
drivers/gpu/drm/asahi/g17/completion/publication.rs):Prepared::activate()stores pre-allocated predecessor links on the successor (State::deferred_links,Link::target = Noneso unfinished teardown cannot form anArcself-cycle) instead of locking every predecessor during enqueue.Publication::phase: AtomicU8): Replaces separate atomic flags with a single 6-state phase (PHASE_PENDING,PHASE_SETTLED_CLEAN,PHASE_FAILING_PENDING,PHASE_FAILED_PENDING,PHASE_FAILING_AFTER_SETTLE,PHASE_FAILED_AFTER_SETTLE).Acquireload (PHASE_SETTLED_CLEAN) without taking the predecessor mutex.claim_locked()atomically clearsupstream_releasedand transitions toPHASE_FAILING_*understate.lock()beforepublish(Err)signals the error fence off-lock, so late attachments queue onstate.successorsuntilstate.publishedis recorded and probes wait untilpublish(Err)transitions toPHASE_FAILED_*.predecessor_error.is_none()) transitions toPHASE_FAILED_AFTER_SETTLEonce its error fence has signalled, matching eager settlement (is_pending() == false) even without an intervening probe.Publication::subscribe): When an out-of-order waiter queues on a deferred timestamp-free publication,subscribe()walks an intrusive stack throughState::subscribe_next(no recursion, no allocation, no depth bound) so writer completion alone releases the waiter.Publication::pending_within): Scansdeferred_linksin one pass, stopping at the first predecessor not inPHASE_SETTLED_CLEAN, consuming published failures viaswap_remove, probing timestamp-free predecessors up toPENDING_PROBE_DEPTH, and releasing already-attached successors on clean settlement.drivers/gpu/drm/asahi/g17/queue/mod.rs): Rechecksentry.status() < 0whenpending_publication()returnsNoneso an error signalling between those two reads still entershost_waits.asahi_g17_publication_orderandasahi_g17_cross_engine_timestamps, plus standalone host testtools/asahi/g17-publication-lazy-tests.py(9 behavioral scenarios + 9 contract mutations).Evidence
76b855c7237e7584da4619749f5528443c2efa68(based onmain37a630623169)python3 tools/asahi/run-host-tests.py --only g17):343/343 passedin 7 s (g17-publication-lazy-tests:10/10 passedin 0 s)../tools/testing/kunit/kunit.py run --arch arm64 --make_options LLVM=1 --kunitconfig drivers/gpu/drm/asahi):Ran 579 tests: passed: 574, skipped: 5(0 failed).76b855c7237e, default command line,apple-mcc 2220000000.memory-controller: system level cache allocation enabled on 32 planes, Borealis system Mesa,deqp-vk 7ba03cdac7ae(6 workers, shader cache on):synchronization.smoke.*11/11,synchronization.basic.*29/29,synchronization2.op.single_queue.barrier.*_read_image_compute*412/412,query_pool.occlusion_query.copy_*159/159,query_pool.concurrent_queries.*2/2,multiview.queries.*16/16,pipeline.monolithic.timestamp.basic_graphics_tests.*80/80,api.copy_and_blit.core.image_to_image.simple_tests.*19 Pass / 4 NotSupported).query_pool.*18,242 Pass / 28 NotSupported,synchronization.timeline_semaphore.*2,880/2,880,synchronization2.timeline_semaphore.*2,873/2,873,pipeline.monolithic.timestamp.*262/262).