Repository navigation
drm/asahi: charge GPU page tables to their client and cap VMs per file - #2530
Conversation
7c99f6e to
22b9bb2
Compare
|
No blockers. Checked the ledger split (
HW row: one G13 or G14 Mac (M1/M2) on this head: Assisted-by: LLM (Claude:Opus 5.5) |
22b9bb2 to
6386898
Compare
|
Thanks, Ryan. Both points are fixed in the commits, now at 6386898.
J775D on this head (stacked with #1973 and our other three open drm/asahi PRs on integration/aurora cc14570, 27.0 firmware, default command line; the kernel also carries a local fix for an appledrm boot oops, see #1973):
Rows we can't run: could your lab, or an M1 or M2 owner, run this head on a G13 or G14 Mac? The useful row is |
|
Re-review of 6386898: No blockers.
Nothing else changed since the last review (second commit unchanged, third only in its message). Trailers are a human Signed-off-by plus Suggested-by only. HW row: still only the M5 Ultra, on an integration stack with other open PRs and a local appledrm fix. Needed: one G13 or G14 Mac (M1/M2) on this head alone, Assisted-by: LLM (Claude:Opus 5.5) |
There was a problem hiding this comment.
Pre-PR checklist review (§1–§6) on live head 63868987c8536c7612d1c4cdf198c39ad37a8b50 (host-tests: pass).
Checklist Summary
- §1 No model gating: Pass — shared
file.rs,memacct.rs,mmu.rs,mmu/bind.rs, andpgtable.rspaths apply uniformly across all GPU families with zero chip/SoC/board/firmware gates. - §2 Production-ready, no hacks: Pass — works on default kernel command line, no new module parameters, no sleeps/retries/lab-only paths.
- §3 Safety: Pass — no hardcoded hardware safety constants;
MAX_VMS_PER_FILE = 64is a per-file DoS/resource bound matching the existing per-file memory-limit model. - §4 Clean-room & attribution: Pass — all 3 commits (
7d82a3723bc8,62174055d25f,63868987c853) carry human author/committer and humanSigned-off-by/Reported-by/Suggested-bytrailers only; PR body includesAssisted-by:. - §6 Naming: Pass — uses Borealis and Aurora naming.
- §5 Evidence: Holding for cross-family hardware proof.
Code Audit (0 blockers)
memacct.rs:Ledger::reserve()split fromadmit()preserves rollback-on-device-limit-failure semantics;Usage::{new, try_add, add, hold}andDropkeepclient.{committed,resident}andledger.{user_committed,user_resident}balanced.pgtable.rs:UatPageTable::with_pages()allocates withGFP_KERNEL_ACCOUNTonce charged, runsclean_pocanddriver_tables.reserve(1, GFP_KERNEL)beforecharge.try_add(UAT_PGSZ as u64), and only then records viapush_within_capacityand incrementstables. Any failure frees the page with no phantom charge. Verifiedfree_table()is only reachable fromUatPageTable::drop(). KUnitasahi_pgtable_chargecovers normal lifecycle, client-limit refusal, and borrowed-root refusal.mmu.rs&mmu/bind.rs: Verified all threeGpuVaAlloc::newallocation sites useGFP_KERNEL_ACCOUNT.file.rs: Verifiedvm_xa.lock().reserve_limit(1..=MAX_VMS_PER_FILE, GFP_KERNEL)returns-EBUSY(__xa_allocinlib/xarray.c) when full, andfailed_vmcleans up the newly createdvm(releasing its initial root-table charge) on refusal.
Holding For (§5)
0 code/policy/attribution/naming/CI blockers. Holding approval solely for the missing cross-family hardware row on this head (this change applies to all GPU families, and the J775D run was stacked with #1973 and other open PRs):
- One non-M5 Mac (e.g. G13/G14 M1 or M2) running this head:
dEQP-VK.sparse_resources.*and render CTS subset matching baseline, fdinfo sparse page-table charge and release onVM_DESTROY, 0 SELinux denials (if enabled), 0 failed units, and 0 new kernel errors.
|
Thanks. The J775D row is now on this PR's own base: integration/aurora b21dcc6 plus #1973 (the J775D's GPU node and G17D binding), with and without this PR, nothing else. Kits
The Testing section now leads with this row; the earlier stacked run stays only as labelled extra evidence with its base. The cross-family row (an M1 or M2 with Assisted-by: LLM (Claude:Opus 5.5) |
|
Review notes (non-author):
|
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at 6386898. Accounting client page tables changes AGX2 as well as newer GPUs. Please show charge and release for failed map, teardown, and closing a file at the VM limit while another file continues to use its VMs. The G14G sparse-resource row should include reuse after close and report the final fdinfo charge.
There was a problem hiding this comment.
Formal §1–§6 review at verified live head 63868987c8536c7612d1c4cdf198c39ad37a8b50 (live integration/aurora 70a00e583b03, not superseded; CI: host-tests green).
Checklist Summary
- §1 No model gating, §3 Safety, §4 Attribution, §6 Naming: PASS — shared
drivers/gpu/drm/asahiaccounting applies uniformly across all GPU families;UatPageTable::with_pages()cleanly allocates, cleans, reservesdriver_tablescapacity, and charges last (charge.try_add()) so refused/failed tables leave zero phantom charge; all 3 commits (7d82a3723bc8,62174055d25f,63868987c853) carry human author/committer and humanSigned-off-by:/Reported-by:/Suggested-by:only; PR body carriesAssisted-by:. The new standalone J775D own-base row (b21dcc633b32 + #1973 + 63868987c853) cleanly validates M5 Ultra.
Remaining Blockers
- §2 Early VM-slot reservation on the refusal path (
drivers/gpu/drm/asahi/file.rs:713-734):vm_xa.lock().reserve_limit(1..=MAX_VMS_PER_FILE, GFP_KERNEL)?still runs aftergpu.new_vm_for_file()andwith_memory_client(). Becausereserve_limit()drops the xarray lock immediately and returns an ownedReservationthat releases the slot automatically on error unwind, reserving the slot beforenew_vm_for_file()avoids allocating a root page table, initializingGpuVm, registering G16 backend state, mutatingLEDGER, and running fullScopeGuardteardown on every refusedVM_CREATEpast the 64-VM cap (matching Ryan's note; a KUnit case for the cap would also strengthen coverage). - §5 Missing cross-family hardware row (G13/G14 M1 or M2): This series changes shared page-table and VM lifecycle accounting for every GPU family, and only J775D (M5 Ultra, ALARM without SELinux) has been run. Still needed on a non-M5 Mac (G13/G14):
dEQP-VK.sparse_resources.*and render CTS subset unchanged vs baseline, fdinfo charge & release across failed map, teardown, and close/reuse at the 64-VM limit while another file uses its VMs, plus the full §5 regression tuple (0SELinux AVC denials on an enforcing host,0failed units,0new kernel errors). - Open accounting question from review (GPUVA nodes): Please either also account
GpuVaAllocnodes inmemacct(so client limits and fdinfo reflect kernel memory from large numbers of small binds) or explicitly answer why memcg-only (GFP_KERNEL_ACCOUNT) is the intended boundary.
6386898 to
39f1f06
Compare
|
Updated the series (rebased onto
KUnit (built-in Still to run on this head: a fresh own-base J775D hardware row after push (J775D runs ALARM, so no SELinux; units and kernel error checks apply there), and the requested cross-family G13/G14 row ( Assisted-by: LLM (Claude:Opus 5.5, Gemini:Neon) |
|
Fresh own-base J775D (Mac Studio, M5 Ultra) A/B hardware row at live head
Assisted-by: LLM (Gemini:Neon) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: HOLD at 39f1f067e77a
Blockers:
drivers/gpu/drm/asahi/mmu.rs(EOF aftermod execution_context_tests): merge conflict (CONFLICTING/dirty) againstmain(a9cd131e8207), which appendedFirmwareWindow(CONFIG_DRM_ASAHI_G14_V27_2) in the same location asmod gpuva_charge_tests. Rebase ontomainand refresh exact-head verification.drivers/gpu/drm/asahi/mmu.rs:926-944and3367-3380(sm_step_remap/unmap_prepared_cleanup): an already-accepted deferred hole-punch unmap (has_prev && has_next) queued under quarantine (defer_bind_batch()/defer_unmap()) callscharge.try_fork(GPUVA_BYTES)duringdrain_mappings(). If the client or device is at itsmemacctlimit at drain time,ENOMEMtripsstate.cleanup_failed/state.blockedinmmu/lifetime.rs:753-786and leaves stale page-table leaves afterVM_BINDreturned0anduntrack_context_ranges()already ran. On theunmap_prepared_cleanup()path (whose splitGpuVaAllocnodes were already preallocated before deferring), charge the extra split node unconditionally (e.g. viatransfer_copy()gated by a flag onStepContext).- §4 Attribution (PR body): remove the AI-attribution footer line at the bottom of the PR body (and omit attribution footers from future PR comments). All three commits are clean.
- §5 PR structure & cross-family HW evidence: update the PR body with the required
**What:**,**Tested:**,**Risk:**, and**Not yet:**header lines and refresh the stale## Change/## Testingtext (still describing63868987c853and memcg-only GPUVAs) to match the rebased head; add a cross-family G13/G14 (M1 or M2) exact-head row (dEQP-VK.sparse_resources.*and render CTS subset vs baseline, fdinfo charge/release across failed map, teardown, and close/reuse at the 64-VM limit while another file uses its VMs, plus 0 SELinux AVC denials on an enforcing host, 0 failed units, and 0 new kernel errors — especially important now thatVm::drop()routes untracked G13/G14 VMs throughunmap_user_ranges()).
Checked: Full diff and 63868987c853..39f1f067e77a interdiff (file.rs, memacct.rs, mmu.rs, mmu/bind.rs, pgtable.rs), 3-way merge check against main (a9cd131e8207), commit/PR hygiene (§1–§6), CI (host-tests green), and J775D exact-head row (39f1f067e77a).
Evidence
Resolution of prior 63868987c853 code blockers
- Early VM-slot reservation (
39f1f067e77a,file.rs:68-72, 675-677): Resolved.reserve_vm_slot(vm_xa.get_ref())?now runs beforeadmit_vm(),gpu.new_vm_for_file(), andwith_memory_client(). RefusedVM_CREATEpast 64 VMs returnsEBUSYbefore building or tearing down any VM state, and any later error unwindsresvcleanly. Covered by new KUnit suiteasahi_vm_table(a_file_holds_at_most_max_vms_per_file). - GPUVA node
memacctaccounting (df9812344d81,memacct.rs,mmu.rs,mmu/bind.rs,file.rs): Mostly solid.VmOpResources::with_gpuvas()reservesGPUVA_BYTESup front;sm_step_map()movesctx.preallocated_charge()intoVmGpuVaonly atop.insert()after all fallible steps so failed maps leave zero phantom charge;VmGpuVa::clone()drops_chargetoNonefor snapshots; whole/truncating unmaps never fail on limits (for_unmap()takes no charge andsm_step_remap()usestransfer_copy()before droppingremap_ret.unmapped_va);Vm::drop()unifies untracked G13/G14 VMs onto allocation-freeunmap_user_ranges()->unmap_all(VmInner::unmap_gpuva)(verified all VMs useDRM_GPUVM_IMMEDIATE_MODE,kernel_alloc_nodeis skipped, and kernel mappings usemm::Node). One remaining edge case noted in Blockers above (unmap_prepared_cleanuphole-punch split underdrain_mappings()). - Page-table charging (
ee1f1a60c453,pgtable.rs): Unchanged from63868987c853; allocates withGFP_KERNEL_ACCOUNTonce charged, cleans PoC, reservesdriver_tables, charges last (charge.try_add()), then records viapush_within_capacity().
Pre-PR Checklist (§1–§6)
- §1 No model gating: Pass — applies uniformly across all GPU families with no chip/SoC/board/firmware gates.
- §2 Production-ready, no hacks: Hold for the
unmap_prepared_cleanup()deferred split-charge bug above; otherwise clean (default cmdline, no new module params, no sleeps/retries/lab paths). - §3 Safety: Pass — no hardcoded hardware safety constants;
MAX_VMS_PER_FILE = 64is a per-file DoS/shrinker bound matching the existing per-filememacctmodel. - §4 Clean-room & attribution: Fail on PR body (carries an AI-attribution footer; recent comments also carried footers). Commits pass: all 3 commits carry human author/committer (
Jeff Queisser) and humanReported-by:/Suggested-by:/Signed-off-by:trailers only; no copyrighted Apple material. - §5 Evidence & PR structure: Fail — PR body lacks required
**What:**/**Tested:**/**Risk:**/**Not yet:**headers and still reflects63868987c853. J775D (M5 Ultra, ALARM, no SELinux) exact-head A/B row at39f1f067e77aon bareintegration/aurora5746ef8a5afd(published auraf13056d95af6) passed in comment7121659967(+512.3 MiBbind charge/release, 64-VMEBUSY, 571/57/0 Borealis render CTS, 0 new failed units / 0 new kernel errors), andkunit-vzpassed 399/401 (2 baseline skips;asahi_memacct12/12,asahi_pgtable_charge3/3,asahi_gpuva_charge3/3,asahi_vm_table1/1). Cross-family G13/G14 exact-head row with SELinux enforcing tuple is still missing. - §6 Naming: Pass — uses Borealis and aura throughout.
Commits & Mergeability
ee1f1a60c453:drm/asahi: charge a VM's page tables to its client's memory limitdf9812344d81:drm/asahi: charge GPU mapping records to the client and the memory cgroup that create them39f1f067e77a:drm/asahi: allow at most 64 VMs per file, so VM memory and reclaim work stay bounded- 3-way merge check vs
main(a9cd131e8207):file.rs,memacct.rs,mmu/bind.rs,pgtable.rsmerge cleanly;drivers/gpu/drm/asahi/mmu.rsconflicts only at EOF (mod gpuva_charge_testsvsFirmwareWindow).
CI
host-tests:SUCCESSon39f1f067e77a(runs/45295968115/job/138116291384).- Note: after rebasing onto
main,pr-textwill also enforceTested:/Risk:and zero AI attribution in the PR body.
Non-blocking Notes
- Commit
df9812344d81message mentions "including kernel maps into a client VM" for GPUVA node accounting, whereasmap_in_range_with_mode()/map_at_with_guard_size()/map_io()usemm::Noderather thandrm_gpuva(they only allocate page tables, covered by commit 1). Minor wording nit only.
A client VM's page tables are allocated as the client maps and kept until the VM is destroyed, but they were not counted by the GPU memory limits, not shown in the client's fdinfo and not charged to any memory cgroup. Because sparse and single-page binds map a small object over a large range, the table memory a client causes was not bounded by the memory it holds. Charge the tables to the client that created the VM, as a held user buffer of the same size would be. The root and the tables that exist when the VM gets its client are counted at once. Each later table is admitted against the client's and the device's memory limits once it is allocated, after every other step that can fail, so a table that is not installed leaves no charge behind. A refusal frees the table and fails the bind or kernel mapping that needed it with ENOMEM. From then on the tables are also allocated with GFP_KERNEL_ACCOUNT, so they count towards the memory cgroup of the task that maps. The charge is released when the page table is freed with the VM. Kernel VMs are not charged. Legitimate use stays far below the limits: the Borealis Vulkan driver's sparse address space on M5 is 16 GiB per device, 8 MiB of tables (16 MiB with its read-only shadow). This applies to the client VMs of every GPU family. Reported-by: Erik Bourget <erik@ebourget.net> Suggested-by: Erik Bourget <erik@ebourget.net> Suggested-by: Ryan Murray <ryan@aurorasilicon.org> Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
…roup that create them Each mapping in a VM is recorded in a GPUVA node until it is unmapped, and those nodes were not charged anywhere. Mapping one page after another needs a page table only every 2048 pages but a node for every mapping, so the nodes can outweigh the tables the previous commit charges many times over. Allocate the nodes that binds and unbinds use with GFP_KERNEL_ACCOUNT, so they count towards the memory cgroup of the task that asks for the operation. In a VM charged to a client, also charge each node's size against the client's and the device's memory limits, through the same memacct::Usage that the previous commit uses for page tables, so both committed and resident totals in fdinfo and gpu_memory reflect them. A map operation reserves one node's charge in gpuva_charge before preallocating nodes or changing mappings; a recorded mapping keeps its charge until removed, and an unused charge is returned when the operation ends. Whole-mapping and truncating unmaps never fail on memory limits: unmap preparation reserves no charge, and a truncating remap transfers the removed node's charge to the single surviving piece before dropping the old node (net zero). Only an operation that increases the node count -- a new user map, or a remap that splits one mapping into two -- checks the client and device limits and can fail with ENOMEM, before modifying any page table. When a VM is quarantined, defer_bind_batch() and defer_unmap() check under the VM reservation whether an unmap lies strictly inside an existing charged GPUVA (range_strictly_inside_va()) and pre-reserve a separate split_charge before accepting it (refusing with ENOMEM if over limit), so deferred hole-punch unmaps neither bypass limits nor fail during drain_mappings(), and a map strictly inside an existing mapping cannot consume gpuva_charge during its remap step. Use the existing allocation-free unmap_user_ranges() path in Vm::drop() for every GPU family, so tearing down an untracked VM while its client is at its memory limit never needs to preallocate split nodes. This applies to every GPU family. Reported-by: Erik Bourget <erik@ebourget.net> Suggested-by: Erik Bourget <erik@ebourget.net> Suggested-by: Ryan Murray <ryan@aurorasilicon.org> Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
…rk stay bounded Besides its page tables, each VM holds kernel memory that is not charged to its client: its GPUVM, its kernel allocators and per-VM objects. A G17 user VM also registers two shrinkers of its own, and every reclaim pass walks all registered shrinkers. The number of VMs one file could create was not limited. Refuse VM_CREATE past 64 VMs in one file with EBUSY, as the ID allocator reports a full range. VM_CREATE takes its table slot before it builds anything of the VM, so a refused create costs nothing. Mesa creates one VM per file. The limit is a count, not a charge against the client's memory limit: the VM's memory could be charged as its page tables are, but the shrinker registrations are not memory, and the time reclaim spends walking them grows with their number. Neither the machine nor a memory limit bounds that. Shrinkers registered once per device, walking the device's VMs, would make the count unnecessary. The cap is per file, as the existing memory limits are: a client that opens the device again gets another 64 VMs in the new file, each file accounted on its own. This applies to every GPU family. Reported-by: Erik Bourget <erik@ebourget.net> Suggested-by: Erik Bourget <erik@ebourget.net> Suggested-by: Ryan Murray <ryan@aurorasilicon.org> Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
39f1f06 to
b59b999
Compare
|
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: FINISH, then merge at b59b99938ace: the code points are fixed; it needs rows at this head.
Blockers: none in the code. A deferred hole-punch unmap now reserves its split charge when it's accepted into quarantine (reserve_split_charge()), so drain_mappings() can't fail at the limit, and the branch merges cleanly with main again.
Rows before merging: mmu.rs and file.rs run on every GPU, so at this head it needs one run on the J775D and one on a Mac from another generation (M1–M4 or the Neo), with no new faults.
Checked: thank you. No Apple material, no gates. Page tables are charged to the client after allocation and recorded within capacity, failed maps leave no phantom charge, plain unmaps never fail on limits, and a refused VM_CREATE past 64 VMs costs nothing. The J775D A/B on the PR's own base shows no regression.
Superseded by the review at b59b999
|
@erikwb Would you be able to run a quick check of this PR at @DjDeveloperr approved the code ( |
Merge origin/main (8a76aa1, including aurora-silicon#2531) to resolve the conflict at the end of drivers/gpu/drm/asahi/file.rs, keeping both the asahi_vm_table and asahi_bound_object_charge KUnit test modules. Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
|
Could you merge current The recorded J775D row is at |
|
Merged Re-verified at
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verified the main merge-forward conflict resolution in drivers/gpu/drm/asahi/file.rs: both asahi_vm_table and asahi_bound_object_charge KUnit modules are cleanly preserved with no unintended diff. Holding merge until CI completes green and a non-M5 generation row is posted.
|
|
|
Note 🤖 Claude Sonnet 5.5 responding on behalf of erikwb Verdict: MERGE at Two things J713 cannot show, so the J775D row still carries them: One wording point, not a blocker: a bind refused partway at the limit keeps the page tables it had already built, with their charge, until the VM is destroyed (18.5 to 27.4 MiB in these runs). The charge equals the memory held and the retry adds only the rest, so nothing leaks, but "refusals leave no charge behind" in the PR text is true only for the table page admitted last. EvidenceSetup: J713 (T8132,
CTS detail: the Fail, Crash and ResourceError cases are the same families on both kernels ( Not run: M1 ( The default kernel was restored afterwards (default entry never changed, 0 failed units). |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at e517f858: approve. Merging.
Blockers: none.
Checked
e517f858is a single merge of main. The PR's own diff against main is identical to4804a6eb, the commit of the J775D (M5 Ultra) row.- Of the 7 files the PR touches, only
drivers/gpu/drm/asahi/file.rsdiffers from that commit, by main's unrelatedDRM_ASAHI_FEATURE_COMPUTE_MULTI_CHANNELconstant (4 lines). So the row carries over to this head. - Dj APPROVED at this head. CI is 24/24 after re-running the cancelled jobs.
- Other generations' rows stay in "Not yet" as follow-ups.
What: Charge every client VM's page tables to its
memacctledger (and memory cgroup viaGFP_KERNEL_ACCOUNT, admitted after every other fallible step so refusals leave no charge behind), charge GPUVA mapping records (GFP_KERNEL_ACCOUNT+ pre-allocated charge split cleanly from remap split-charge reservations), and cap client VMs at 64 per open file (EBUSYpast 64) across all AGX GPU families.Tested: J775D (Mac Studio, M5 Ultra) at
4804a6ebc803on baremain72845421def0(published Auramain7bf44a6374af, 27.0 stub, default command line, own-base A/Bpr2530-m8vspr2530-m8b): 1024 GiB single-page bind (512.25 MiB of tables, bothSINGLE_PAGEandSINGLE_PAGE|SPARSE_TILE) charges+512.3 MiBfdinfo /user_committedand+511.0–+511.9 MiBcgroup (vs+0.0 MiBon baseline) and releases onVM_DESTROY;VM_CREATEcaps at64thenEBUSY(vs100on baseline); render CTS subset571/57/0,0GPU faults/recoveries/oops,2/2baseline failed units,0new kernel errors (9vs9baseline; ALARM has no SELinux). Automated: modular build (pr2530-m8) has0warnings indrivers/gpu/drm/asahi/andrust/kernel/drm/gpuvm/;kunit-vz(pr2530-m8k) 90 suites451/455pass,0fail,4baseline skips (asahi_pgtable_charge3/3,asahi_pgtable_segments3/3,asahi_gpuva_charge3/3,asahi_vm_tableok,asahi_memacct12/12,asahi_bound_object_charge2/2,asahi_timestamp_buffer2/2);tools/asahi/run-host-tests.py(ht-2530m8)560/564pass on both base and series (0of564runs differ).Risk: two-way door · affects client VMs on all AGX GPU families (
drivers/gpu/drm/asahi+rust/kernel/drm/gpuvm/mod.rs); kernel VMs are unchanged and Mesa uses 1 VM per open file (far below the 64-VM per-file cap).Not yet: Non-M5 Mac row (G13/G14 M1/M2 or G15/G16/G18) running
dEQP-VK.sparse_resources.*, render CTS subset, and verifying sparse table charge infdinfowith 0 regressions.Details
Problem
A client VM's page tables and GPUVA mapping records were not counted by the GPU memory limits (
memacct), not shown in the client'sfdinfo, and not charged to its memory cgroup, and the number of VMs one file could create was unbounded. Sparse and single-page binds map a small object over a large virtual address range, leaving the kernel memory a client could allocate through page tables and mapping records unbounded by its GPU memory limits.Why this shape
memacctledgers, shown infdinfo, and charged to the memory cgroup, while page tables and GPUVA mapping records created by binds were outside every limit.fdinfoand memory cgroups blind to the memory.memacctledger andGFP_KERNEL_ACCOUNTcharging path that client buffers already use, with limits derived from machine RAM. Each page table is charged only after every other step that can fail (allocated, cleaned, driver-tables slot reserved, charged, then recorded), so a refusal leaves neither a leaked page nor a stale charge. GPUVA map charges and remap-split charges use distinct reservations (gpuva_chargevssplit_charge) so an interior remap never consumes a map's preallocated charge and fails cleanly before modifying page tables. The 64-VM per-file cap bounds per-file VM structures and reclaim work across all GPU families with no chip, board, or firmware condition.Change
Three feature commits plus a non-force-push merge of
main(8a76aa157b1ff, including merged#2531):drm/asahi: charge a VM's page tables to its client's memory limit(31e8f6fe2ba7): Admit client VM page tables againstmemacctafter the last fallible step, allocate withGFP_KERNEL_ACCOUNT, release on VM destroy, leave kernel VMs uncharged, and cover withasahi_pgtable_charge(3 KUnit cases, inmod pgtable_charge_testsalongside upstreammod testsforSegmentCursor) andasahi_memacct.drm/asahi: charge GPU mapping records to the client and the memory cgroup that create them(3f81108853bc): Allocate GPUVA nodes withGFP_KERNEL_ACCOUNTand charge mapping records againstmemacct, keepinggpuva_charge(forsm_step_map()) separate fromsplit_charge(forsm_step_remap()whenhas_prev && has_next) withasahi_gpuva_chargeKUnit coverage.drm/asahi: allow at most 64 VMs per file, so VM memory and reclaim work stay bounded(b59b99938ace): CapVM_CREATEat 64 VMs per open file (EBUSYpast 64) withasahi_vm_tableKUnit coverage.Merge branch 'main' into pr/asahi-pagetable-charge(4804a6ebc803): Mergemain(8a76aa157b1ff), keeping bothasahi_vm_tableand#2531'sasahi_bound_object_chargeKUnit test modules indrivers/gpu/drm/asahi/file.rs(diff againstmainunchanged: 7 files, +862/-144).Evidence
Testing
J775D (Mac Studio, M5 Ultra) own-base A/B row at
4804a6ebc803Bare
main72845421def0(no extra PRs), published Auramain7bf44a6374af, 27.0 stub, default command line, read-only root, ALARM (no SELinux): kitpr2530-m8(windowpr2530m8@20261125-1344) vs baseline kitpr2530-m8b(windowpr2530m8@20261125-1344). Peak SMC sensor 40.1 C, peak DC input 46.5 W.pr2530-m8b)pr2530-m8)SINGLE_PAGE, 512.25 MiB tables)+0.0 MiB,user_committed +0.0 MiB, cgroup-1.0 MiB(kernel +0.0 MiB, uncharged);MemFree -516.0 MiB+512.3 MiB,user_committed +512.3 MiB, cgroup+511.0 MiB(kernel +510.2 MiB), kept across unbind, released onVM_DESTROY(-0.1 / -0.1 / -2.4 MiB)SINGLE_PAGE|SPARSE_TILE, 512.25 MiB tables)+0.0 MiB,user_committed +0.0 MiB, cgroup+0.0 MiB(kernel +0.0 MiB, uncharged);MemFree -522.3 MiB+512.3 MiB,user_committed +512.3 MiB, cgroup+511.9 MiB(kernel +512.3 MiB), kept across unbind, released onVM_DESTROY(-0.1 / -0.1 / -0.0 MiB)VM_CREATEin one file100created (test stops)64created, thenEBUSY571 Pass / 57 NotSupported / 0 Fail571 Pass / 57 NotSupported / 0 Fail002(iwd.service,systemd-networkd-persistent-storage.service) /92(same) /9(0new kernel errors)Automated checks at
4804a6ebc803pr2530-m8on baremain72845421def0):0compiler/rustc warnings indrivers/gpu/drm/asahi/andrust/kernel/drm/gpuvm/.kunit-vz,pr2530-m8k,CONFIG_KUNIT=y,CONFIG_DRM_ASAHI=y,CONFIG_IIO_AOP_SENSOR_MOTION=n): 90 suites,451/455pass,0fail,4baseline skips;asahi_pgtable_charge3/3,asahi_pgtable_segments3/3,asahi_gpuva_charge3/3,asahi_vm_tableok,asahi_memacct12/12,asahi_bound_object_charge2/2,asahi_timestamp_buffer2/2;0warnings in touched files.tools/asahi/run-host-tests.py,ht-2530m8on baremain72845421def0):560/564pass on both base and series;0of564runs differ.