Repository navigation
drm/asahi: g17: keep validation proof ranges sorted and batch VM job retention - #3325
Conversation
…ress Requests::covers() and Requests::insert() previously scanned the range array linearly (and insert() restarted from index 0 after every merge), turning coverage checks against the 128-entry persistent Proof cache into O(M * N) work on every submission. Keep Requests sorted by (access, start) with disjoint, non-adjacent intervals within each permission bucket (Read=1, Write=2, ReadWrite=3): - covers() uses binary search (partition_point) against bucket 3 and, for Read/Write queries, the requested bucket; - insert() merges overlapping or adjacent equal-permission neighbors in place via partition_point and prunes strictly weaker Read/Write intervals fully covered by a merged ReadWrite range. Update the expected order in only_uncovered_ranges_are_walked_again and add a KUnit test covering overlapping permission buckets, gap merging, and ReadWrite subsumption. Signed-off-by: oreater <[email protected]>
Queue::prepare_submission() previously called Vm::retain_job() in a loop for each additional command in a multi-command submit ioctl, taking both the residency gate mutex and the VM lifetime mutex once per command. Add Gate::enter_many(), Vm::enter_residency_many(), and Vm::retain_jobs() to acquire all additional residency leases and lifetime job references under a single lock acquisition for each mutex, and use Vm::retain_jobs() in Queue::prepare_submission(). Signed-off-by: oreater <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict at 6e552962caae: the code is correct, with no code blockers. It isn't ready to merge yet: CI and a G17 hardware row at this head are still owed (see below).
Checked
Requestsinvalidation.rs(ea19778):- Every write still goes through
insert(), andpages()already rejects overflowing ranges, so the uncheckedstart + lenadditions can't overflow. insert()keeps each access bucket sorted by(access, start)and keeps intervals disjoint and non-adjacent:- only the predecessor can overlap from the left;
- the forward scan merges every touching interval;
- a ReadWrite insert removes only Read and Write intervals that lie fully inside the merged range. These sit before bucket 3, so
lo/hishift down by the number removed.
covers()checks bucket 3 and then the requested bucket. That is the same single-interval containment rule as before.
- Every write still goes through
- Differential check against the old code: I ported the old and new
insert()/covers()side by side and fed both 40,000 random sequences (capacities 3/4/6/48), mixing unaligned, zero-size, overlapping, adjacent and duplicate ranges and invalid access values.- After every insert, the two produced the same set of ranges and the same
overflowflag. - They gave the same
covers()answers on random queries. - The new version kept its sorted, disjoint, non-adjacent invariant every time.
- The only visible change is ordering, which the updated
only_uncovered_ranges_are_walked_againtest reflects. Nothing readsRequestsin insertion order.
- After every insert, the two produced the same set of ranges and the same
- VM job retention (6e55296):
Gate::enter_many()isGate::enter()withcount: same busy, evicted and restore handling, with the interruptible waits kept.retain_jobs()reservesoutfirst and takes all leases, then the lifetime lock, the same order asretain_job(). It raisesactivebycountwith an overflow check, then builds oneVmJobGuardper lease.- On a closed, blocked or overflow error, the leases drop one at a time through
Lease::drop. Each guard later dropsactiveby one through the unchangedVmJobGuard::drop. prepare_submission()takes the samepending.len() - 1extra guards as before.- The new helpers are additive and only the g17 queue calls them, so other generations'
mmupaths are unchanged.
- Commits and checkpatch: both commits are signed off with no attribution.
checkpatch --strictreports 0 errors and 0 checks, plus one nit: a 101-column doc comment onretain_jobs().
Before merge
- CI hasn't run yet. At this head,
Apple build and KUnit,Host testsandpr-textare allaction_required, waiting for a maintainer to approve the workflow runs. The readiness comment's "no CI for this change" comes from that. - No hardware row at this head yet. The PR body's Tested section has a host build and tests, and the boots it mentions were on
7.3.0-40, not this head; Not yet says the same. One boot on a G17 Mac at6e552962caaeis needed: a J700 (G17P) or an M5 such as your J716c. It should run Vulkan work that sends multi-command submissions (soretain_jobs()runs), with the KUnitasahi_g17_validation_pagesresults and a clean kernel log.
Not blocking
- Risk line: it says "G17 Macs (M4/M5)", but G17 is the M5 family and the Neo. The M4 is G16, which this code doesn't run on.
- Host test:
--only asahi-m4doesn't cover these paths.
There was a problem hiding this comment.
Verdict: MERGE at 6e552962caae482f666f9ec035a094a20e533d19 once hardware evidence is complete.
Blockers: No code blocker found. Keep this unarmed until the exact-head J716c submission/VM pressure row and affected peer smoke are posted.
Checked: Reviewed all four files, including permission bucket separation, range arithmetic, capacity, the residency restore/wait path, and RAII rollback on close or error before job guards are built. I extracted the exact-head range implementation into a standalone Rust harness and checked 51,200 insertions across 800 sequences against a per-page permission model and a linear lookup. No ordering, permission, or lookup disagreement. This exercises the range logic, with runtime GPU and VM pressure verification still owed. No DT, per-board gates, private material, or attribution changes.
|
Hardware test row at exact head
|
erikwb
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 6e552962caae
Blockers: The J716c row at this head is missing. Complete the remaining CI checks.
Checked: The posted J616C exact-head row reports 27/27 benchmark cases and both CTS groups passing. T6041 can use the shared G17 backend through driver.rs:183, so the G16C hardware name alone does not rule out that coverage. Apple build, host tests and KUnit asahi passed. Other KUnit jobs are queued, and one PR-text run was cancelled while another passed. The branch has no conflicts. No new hardware gates, runtime parameters or safety limits.
Evidence
Equal-access intervals stay disjoint, and coverage still requires a containing interval with sufficient permissions. ReadWrite pruning keeps weaker ranges that extend outside the new interval. The sorted requests still use the existing epoch check and page-walk fallback. Batch retention reserves storage before counting jobs, keeps the original residency-before-lifetime lock order, and returns one guard per command. Close or overflow before raising the lifetime count drops the leases. Please record the J616C bound backend and whether the workload used multi-command ioctls so the peer coverage is clear.
|
J716c (16-inch M5 Max) at EvidenceBuilt into batched kernel Merged onto On |
Signed-off-by: Ryan Murray <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
|
I merged current |
|
@oreater the review app has no code blockers at |
main made the per-job guard list a KVVec, and this branch's new Vm::retain_jobs() still took a KVec, so the forward merge no longer builds (E0308 at g17/queue/mod.rs:542). Take &mut KVVec<VmJobGuard> and pass the caller's guards reference through. Signed-off-by: Ryan Murray <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
|
@oreater my forward merge ( |
There was a problem hiding this comment.
Verdict: HOLD at 195bfcc9 for hosted CI and current-head G17 evidence.
Checked: The caller already owns a mutable KVVec and reserves capacity before adding the parse guard. The follow-up passes that reference directly to the matching parameter type. The job-count, reserve and rollback paths are unchanged by the type fix. The reported arm64 LLVM build and 291 host passes cover the former build break.
Retain the J716c submission and VM-pressure row and the affected G17 peer smoke on the updated head, or maintainer acceptance of equivalent evidence. The earlier J716c row ran on 6e552962.
There was a problem hiding this comment.
Verdict: MERGE at 195bfcc93a49
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: The caller already owns a mutable KVVec and reserves capacity before adding the parse guard. The follow-up passes that reference directly to the matching parameter type. The job-count, reserve and rollback paths are unchanged by the type fix. The reported arm64 LLVM build and 291 host passes cover the former build break.
Retain the J716c submission and VM-pressure row and the affected G17 peer smoke on the updated head, or maintainer acceptance of equivalent evidence. The earlier J716c row ran on 6e552962.
Follow-ups (not blocking): hosted CI; J716c submission/VM-pressure row on updated head
|
Merging at |
What: Keep G17 validation
Requestssorted by(access, start)for O(log N) binary-search coverage checks and in-place merging, and batch additional VM residency/lifetime job pins under one lock acquisition per mutex inQueue::prepare_submission().Tested: J716c (MacBook Pro 16" M5 Max) host build + tests at
6e552962caae(make LLVM=1 ARCH=arm64 drivers/gpu/drm/asahi/clean with 0 warnings in touched files; all 10asahi_g17_validation_pagesunit tests plus 400-sequence pseudorandom reference-model check passing;run-host-tests.py --only m5-client-handoff2/2,--only asahi-m41/1). Equivalent validation and batched-pin paths previously boot- and Vulkan-stress-tested on J716c (7.3.0-40).Risk: two-way · G17 Macs (M4/M5) command submission validation and multi-command ioctl VM pinning.
Not yet: Bare-metal boot and KUnit run at this exact rebased
maincommit (6e552962caae).Commit summary and test evidence
ea197789bf12—drm/asahi: g17: keep validation proof ranges sorted by access and address:Requestssorted by(access, start)with disjoint, non-adjacent intervals per permission bucket (1=Read,2=Write,3=ReadWrite).covers()withpartition_pointlookup against bucket 3 and the requested bucket.insert()with bounded neighbor coalescing and ReadWrite subsumption pruning of weaker buckets.only_uncovered_ranges_are_walked_againfor sorted order and addssorted_requests_preserve_overlap_merge_and_subsumption.6e552962caae—drm/asahi: g17: batch VM job retention across multi-command submissions:Gate::enter_many(),Vm::enter_residency_many(), andVm::retain_jobs()so multi-command submit ioctls acquire all additional VM residency leases and active job guards under one lock acquisition per mutex instead of once per command.