Repository navigation
drm/asahi: g17: cut the references a pending command holds - #3681
jgoyvaerts wants to merge 3 commits into
Conversation
…reach A command chains its host publication behind every covered pending publication, one link each. Behind one stalled timestamp writer every later covered command joins the chain, so a queue of n pending commands held n(n-1)/2 links. On an M4 Pro, Cyberpunk 2077's busiest queue averaged about 310 links per pending command, 64% of what its pending commands hold, and filled the queue budget. A publication now records how far its ancestors reach on each engine: every publication of that engine up to that sequence which a later command could still link to (unfinished, publication pending) when it was accepted is one of its ancestors. A new command takes its candidates newest first and skips one whose sequence a kept predecessor already reaches. Its own reach is the covered prefix of each engine its rules link, or what its kept predecessors reach. Publication order and errors are unchanged: - a skipped publication is an ancestor of a kept one, so it fires first: a publication fires only once every predecessor has, and upstream release needs that too; - its error reaches the kept one, and through it this command, as PRODUCER_FAILED. Reach records only what a command actually linked, so per-command prefixes, a query-accessing compute's host waits instead of links, and host-wait queues reach nothing they did not link (the "newest only" counterexample keeps its link). Independent producers covered together (m x n) keep every link; the queue budget still bounds that. Timestamp waits are still collected from every candidate. A chain that waits for all earlier commands now takes one link per command. Signed-off-by: Jonathan Goyvaerts <[email protected]>
|
Hardware result on a backport, not the exact head. J616s M4 Pro, test kernel 7.3.0-m4.213 (m4/private-213, on m4/private-212): #3681's link cut (cherry-pick of 087a904), #3600, #3601 and #3602's first two commits, with main's 2048-submission order window. #3602's budget was 262,144 units per queue. Cyberpunk 2077 built-in benchmark, 1920x1200 Low, cold + warm, headless gamescope, alone on the GPU. Kprobes on the budget's two inlined charges read the new
|
A command kept one completed fence for every unfinished command of the other engine it waited for in firmware, only to fail when one of them failed. Behind a deep queue these were most of what its pending commands held. On an M4 Pro, once publication links had been cut, Cyberpunk 2077's commands held about 190 such references each, 98% of the references its busiest queue's budget counted, and that queue peaked at 85% of the budget. Each queue now keeps a failure log per engine. A failed command is entered before its terminal and output fences signal and marked done after both. A command that waits for the other engine's producers in firmware keeps that engine's log and two numbers instead: - since: the log count below its oldest failure still in flight, read before the command reads its producers' statuses; - its prefix of that engine. It fails if a failure past since is within the prefix. This fails a command exactly when one of its fences did: - a producer whose failure is at or below since had signalled it before the statuses were read, so it is found failed there and waited for on the host, as before; - a producer that fails later, or is still being signalled, is past since; - a producer that finished, or failed and retired before the command was accepted, never counts. A plain lowest failed sequence would have kept failing every later command covering it, which FailureRecord deliberately stopped. The log keeps a done failure only while an unfinished command of the other engine has a smaller since and covers it; it is trimmed at every enqueue. Each kept failure then stands for one (consumer, producer) pair that used to hold a completed fence, so the log never holds more than those fences did, and normally only recent failures. A failure that cannot be entered (the GFP_NOWAIT push fails) holds since below it while in flight, like an entry, and fails, conservatively, every command whose since is below the latest such failure. The scheduler still waits for the producers' latest scheduled fence. The quarantine-drain host test's Completion stand-in gets the new signal_result. Signed-off-by: Jonathan Goyvaerts <[email protected]>
602ea2f to
4d9cb2f
Compare
Signed-off-by: DjDeveloperr <[email protected]>
|
J700 (Neo, G17P) boot row at head Kernel: one trial boot (boot
Results
Not covered:
This row covers the success path and multi-queue progress only. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed c1fae1d. Raw failure is logged before terminal signalling. A deferred predecessor failure is also recorded before the public fence signals, and the model observed that failure through the consumer's log. The 291 driver checks passed. The mixed-engine hardware row is still open.
|
Recorded inherited publication errors before signalling the producer’s public fence in c1fae1d. |
|
Hardware result for the second commit, on a backport, not the exact head. J616s M4 Pro, test kernel 7.3.0-m4.219: the failure log as a cherry-pick of 4d9cb2f, on top of the link cut and #3600/#3601/#3602's budget (262,144 units per queue). The test kernel also has a local change that lets a command queued behind already-published producers be published from its ioctl. That change lowers scheduler dependencies but not the references counted here. Cyberpunk 2077 built-in benchmark, 1920x1200 Low, cold + warm, headless gamescope, alone on the GPU. The same kprobes as before sit on the budget's two inlined charges. 0 trace overruns.
This is a backport, so the PR stays a draft until the row passes at its own head. |
What: A pending G17 command kept references that grow with the queue's depth: one publication link per covered pending publication, and one completed fence per unfinished producer of the other engine it waits for in firmware. Behind a stalled job a queue of n pending commands held about n² of them (#2858). Cyberpunk 2077 filled #3602's queue budget with them (about 310 links and 170 producer fences per command on an M4 Pro). Two commits cut both at the source, with publication order and errors unchanged: (1) a publication records how far its ancestors reach, and a command skips a candidate a kept predecessor already reaches, so a chain that waits for all earlier commands takes one link per command; (2) each queue keeps a failure log per engine, and a command checks its producers through it (one reference and two numbers) instead of keeping a fence for each.
Tested: QEMU arm64 KUnit (asahi kunitconfig) at 4d9cb2f: Ran 958 tests: passed: 957, skipped: 1. Each commit's new cases fail on the code before it (link cut disabled: the link-count case fails, Ran 954; failure check stubbed: the 3 failure-log cases fail, Ran 957; lost failures tracked as first-only and not in flight: the lost case fails, Ran 958). tools/asahi host tests: the same failure set as on main 45d7f82 (at 602ea2f; the amend touches only
FailureLog, and g15-input-error, the one host test reading dependency.rs, passes at this head). J616s M4 Pro, backport of the first commit on test kernel 7.3.0-m4.213 (not this head): Cyberpunk 2077 benchmark 33.3 / 35.4 fps, 1.4 links per command (was ~310), busiest queue at 84.8% of the budget, 0 recoveries, 0 submit failures (result). The second commit is not on hardware yet.Risk: two-way door · M4 and M5 (G17 publication chaining in
EnqueueOrdering::build, the producer status checks ofPacket, and every command's failure path, which now enters a failure log before its fences signal). A wrong reach or a wrongsincecould let a command publish before an older publication it covers, or miss a producer's failure. The write-ups, with file:line references, cover ordering, error propagation, coverage, the in-flight race and the log's bound; the tests cover each. The many-to-many pattern (independent producers covered together) keeps one link each; #3602's budget still bounds it.Not yet: a hardware run of the second commit (expected: Cyberpunk's producer references from ~190 per command to none, and the busiest queue well under the budget). Not run on M5.
Details
Reach.
Publication::reach[e], set once before activation under the queue's lock (set_reach), is the largest s such that every publication of engine e up to seq s, which a later command could still link to (unfinished, publication pending) when this one was accepted, is an ancestor of this one.EnqueueOrdering::build:same_chain,cross_chain), or what its kept predecessors reach, whichever is further.Timestamp waits are still collected from every candidate.
Why it is sound (full write-up with file:line references: ordering, error propagation, coverage):
Order::newrefuses a prior past the base). So X is an ancestor of K. A publication fires only once every predecessor has (remaining == 0), and so does upstream release. So K, and this command, fire after X.predecessor_erroralong the path to K. That blocks K's upstream release and turns its result into PRODUCER_FAILED, and the command inherits it from K.Not changed: host waits, firmware producer waits and scheduler dependencies.
Builds on the analysis in #2858 (its option 2a, reach-based reduction) and bounds what #3602's budget has to hold.
Second commit: producer failures through a log
dependency::FailureLog, one per queue and engine:(count, seq, done), entered inCompletion::signal_resultbefore the terminal or output fence signals, and marked done after both;since()is the count just below the oldest entry still in flight;sinceright beforeEnqueueOrdering::buildreads their statuses, and keepsProducers { log, since, prefix }instead of a fence per producer;Why it matches the fences exactly. For any other-engine command X within the prefix:
sincewas read:build()finds X failed and waits for it on the host, as before, and the log doesn't count it again.sinceand counts.FailureRecordstopped on purpose.Bound.
sinceand covers it. In-flight entries stay.GFP_NOWAITpush fails) holdssincebelow it while in flight, like an entry, and conservatively fails every command whosesinceis below the latest such failure.New cases (asahi_g17_dependency):
The quarantine-drain host test's
Completionstand-in getssignal_result.Evidence
Measured motivation (before this change, m4.211, budget probes on the inlined charges): Cyberpunk's busiest queue, 680k commands. Per command: links mean 302-319 (64%), producer fences ~170 (35%), scheduler dependencies ~6 (1%). Peak 311,000 units against the 262,144-unit budget.