Repository navigation
drm/asahi: g18: repeat the audit's page walks only after a mapping changed (+19-21% fps on small frames) - #2652
Conversation
|
The speedup is clear, but this changes what the audit guarantees, so it needs an argument for why skipping is safe.
A row that changes a client's mappings between frames (for example, unmap and rebind a render target while it keeps rendering) would show the gate still catches it. Assisted-by: LLM (Claude:Opus 5.5) |
|
Following up on the earlier review with the project convention behind it. We treat checks that stand between a client's job and the firmware as safety policy, and those apply on every frame, without a switch. At The shape that keeps the speedup: skip the walk only when nothing it covers has changed since the last audit (a per-VM mapping generation plus the PB and UMA generations, compared with the audited values), and drop the parameter. We are happy to run the mapping-change row on our side once that is in. |
45d6d20 to
82d2c8b
Compare
|
@RyanTheTide agreed on both counts. I reworked it in
The mapping-change row you asked for is a GLES client that binds a buffer into its own VM and unbinds it between every two frames (VM_BIND). It got a walk on every frame: 256 per 256 frames, the client epoch advancing with them. Its frames are correct and there were no failures. The speedup is smaller than the counter version's but still clear: +19% at 200 triangles and +21% at 20000, interleaved on one boot. Tables are in the description. |
|
Checked 82d2c8b. This answers my concern. Only the page walk is reused, and only when the client VM and all four mapping epochs match the last walk. The key is read before the walk, so a change during it forces another walk on the next frame. A VM in the middle of a change ( One thing to confirm: Assisted-by: LLM (Claude:Opus 5.5) |
…anged Before every application kick, audit_application() walks the page tables behind the job: every target in the storage and client VMs, the UMA render mappings, the parameter buffer and the job VA in the kernel, kernel-lower and client VMs. With one job in flight, the GPU waits for it. On the J873g the walks took about 80 of the 180 us between a job's retirement and the next kick. A walk proves that those mappings are as expected. Each VM's mapping epoch (mapping_validation_epoch(), as the G17 validation cache uses) advances on every unmap and remap; an addition leaves every proven range mapped, and the epoch reads None while a change is in flight. Record the client VM and the epochs of the four VMs with each walk, and walk again only when any of them differs or is unknown: a new client, a target that was remapped or grown, any unbind in the client VM, a kernel mapping that went away. The PB and UMA rows, the scheduler and stamp checks and the command digests are still checked on every frame. Growth of the PB or the UMA pool only adds mappings the walk does not cover; the rows that describe them are among the per-frame checks. J873g, asyncbench, walking on every frame against walking after a change, interleaved on one boot through a temporary switch, four rounds each (frames/s, mean and range): - 200 triangles: 1588 (1574-1604) against 1896 (1854-1932) - 20000 triangles: 606 (596-619) against 733 (718-764) - 1000000 triangles: 20.0 against 20.1 (GPU-bound) A client that binds and unbinds a buffer in its VM between frames (an unmap between every two frames) gets a walk on every frame: 256 walks per 256 frames, the client VM's epoch advancing with them, and its frames render correctly. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
82d2c8b to
58fe4d8
Compare
|
@RyanTheTide ids aren't reused. G18 creates each user VM with |
|
Thanks, that settles it. VM ids come from the device's 64-bit counter and are never reused, so a recorded walk can't match a VM created later, and the |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial review against pre-pr-checklist.md (§1–§6) at 58fe4d8d90fe.
Code & checklist check (§1–§4, §6, CI)
- Correctness & safety (§3): Verified against
drivers/gpu/drm/asahi/mmu.rs,g18/boot/session.rs,g18/buffer/pool.rs,g18/buffer/object.rs, andg18/queue/graphics.rs.- Every range checked by
audit_render_mappings()and theif walkblock ofApplicationJob::audit()lives in[self.storage, self.job.vm(), uat.kernel_vm(), uat.kernel_lower_vm()]. Vm::id()is allocated from the monotonic 64-bitids.vmcounter (g18/drm.rs), never reused.- On G18 (
NoPeerRoots), all four VMs carry aMappingEpoch; everyKernelMappingmap/drop,unmap_gpuva, andremapcallsmapping_mutation()(advancing the epoch and returningNonewhile in flight), whilemapping_addition()returnsNonewhile in flight and preserves all previously proven ranges. - Reading
walk_key()before the walk ensures any concurrent mutation during a walk leaves the cached key stale (Noneor old epoch) so the next frame re-walks. - PB residency, UMA descriptor validation, scheduler counters, stamps, and uncached FNV64 command digests still run on every frame.
- Every range checked by
- §1 / §2 / §4 / §6 & CI: Clean.
g18_audit_intervalis gone (default kernel command line, no switches/hacks), single commit carries human identity +Signed-off-by:only, andhost-testsis green. - (Non-blocking note: on frames 2–3 when
walk == false,G18_APP_AUDITlogstranslations=0becausepagesis0; harmless unless anything parses non-zerotranslations=on those frames.)
Holding for §5 evidence
The same-machine J873g interleaved A/B (+19–21% on 200/20000 triangles) and the DRM_IOCTL_ASAHI_VM_BIND bind/unbind row (256/256 walks) are strong, but two §5 items remain owed for a performance-claim PR:
- Kernel/build identifier and regression run on
58fe4d8d90fe(or the identical code at82d2c8bdif clearly stated): explicit0 SELinux denials, 0 failed units, 0 new kernel errors. - Conformance unchanged on G18 (
J873g) — required by §5 for performance claims ("a same-machine A/B with conformance unchanged on every GPU generation the change applies to").
Code looks solid; happy to approve once those §5 rows are recorded.
Assisted-by: LLM (Gemini 4 Neon)
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-review against pre-pr-checklist.md (§1–§6) at verified live head 58fe4d8d90fe826f4e98605c4ffa38be31669d38: 0 code/policy/attribution/naming/CI blockers (host-tests: pass, mergeable/clean).
Status since 08:00Z
- §4 Attribution: Confirmed — the
08:15ZPR body update appendedAssisted-by:at the end of the description, and commit58fe4d8d90fecarries human author/committer +Signed-off-by:only. - §1 / §2 / §3 / §6: Unchanged and clean (no code changes since the prior review;
WalkKeyepochs, 64-bit monotonicVm::id(), and per-frame PB/UMA/scheduler/stamp/digest checks all hold).
Still holding strictly for §5 HW evidence before APPROVE
No new §5 hardware rows were added in the 08:15Z body edit. Two items remain owed for a performance-claim PR:
- Kernel/build identifier and §5 regression run on
58fe4d8d90fe(or the code-identical82d2c8bdif explicitly stated):0 SELinux denials, 0 failed units, 0 new kernel errors. - Conformance unchanged on G18 (
J873g), as required by §5 ("a same-machine A/B with conformance unchanged on every GPU generation the change applies to").
Happy to upgrade to APPROVE as soon as those §5 rows are recorded.
Assisted-by: LLM (Gemini 4 Neon)
|
@DjDeveloperr the two §5 rows on the J873g. Build.
Regression.
Performance. asyncbench, frames/s, two rounds interleaved:
Conformance. deqp-runner,
Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-review against pre-pr-checklist.md (§1–§6) at verified live head 58fe4d8d90fe826f4e98605c4ffa38be31669d38: LGTM — approving.
Verified Since Prior Review
- §1–§4, §6 & CI: Unchanged and clean at
58fe4d8d90fe(WalkKeyover monotonic 64-bitVm::id()and all 4 VMmapping_validation_epoch()values read before walking, per-frame PB/UMA/scheduler/stamp/digest checks intact, no module parameters, clean human commit identity +Signed-off-by:,Assisted-by:in PR body,host-testsgreen, clean againstintegration/aurora). - §5 Evidence (complete): Newly posted J873g (G18) rows on
7.3.0-aurora-j873-avd-usb4-perf+(default cmdline,aurora.kocarrying code-identical82d2c8bdwalk reuse) confirm:- Regression: 0 failed units, 0 AVC denials, 0 new kernel errors, 0 job failures from this PR's mode.
- Same-machine A/B performance + mapping-change proof: interleaved
asyncbenchspeedup confirmed alongside theDRM_IOCTL_ASAHI_VM_BINDbind/unbind proof (256/256 walks with advancing epoch). - Conformance unchanged:
dEQP-GLES31(compute.*+draw_indirect.*, 416 cases) identical (0 diffs) anddEQP-GLES3(1506 cases) unchanged on the 6 pre-existingtransform_feedbackfails with 0 PR-induced regressions (pre-existingreason=0x3recovery tracked inmesa#617).
Assisted-by: LLM (Gemini 4 Neon)
a5e9344
into
aurora-silicon:integration/aurora
Before every application kick,
audit_application()walks the page tables behind the job:With one job in flight, the GPU waits for it. On the J873g (M6 Mac mini) the walks took about 80 of the 180 µs between a job's retirement and the next kick.
Change. A walk proves those mappings are as expected. Each VM's mapping epoch (
mapping_validation_epoch(), which the G17 validation cache already uses) advances on every unmap and remap, and reads None while a change is in flight. An addition doesn't move it, because it leaves every proven range mapped.The audit now records the client VM and the epochs of the four VMs with each walk, and walks again only when one of them differs or is unknown:
Everything else is still checked on every frame: the PB and UMA rows, the scheduler and stamps, and the command digests. PB or UMA growth only adds mappings the walk doesn't cover, and the rows that describe them are among the per-frame checks. There is no module parameter.
J873g rows (asyncbench, headless; walking on every frame against walking after a change, interleaved on one boot through a temporary switch that is not part of this PR; four rounds each, frames/s mean and range):
Mapping-change row. A GLES client binds a 16 KiB buffer into its own VM between frames and unbinds it again (
DRM_IOCTL_ASAHI_VM_BIND, so there's an unmap between every two frames). It gets a walk on every frame: 256 walks per 256 frames, with the client VM's epoch advancing in step (555 → 811 → 1067). Its frames render with the expected pixel.A plain client (asyncbench) gets 13 walks in 8192 frames, all on clients' first frames. A GL client that recreates its FBO texture every frame causes no walks, because Mesa recycles its buffers and the VM doesn't change. There were no job failures.
Checks: builds on the integration tip with no new warnings.
cc @DjDeveloperr @RyanTheTide @Acelogic @LiamRay10
Assisted-by: LLM (Claude:Opus 5.5)