Repository navigation
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) |
DjDeveloperr
left a comment
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.
Assisted-by: LLM (Gemini 4 Neon)
|
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.
DjDeveloperr
left a comment
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.
Assisted-by: LLM (Gemini 4 Neon)
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 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 map, including kernel maps into a client VM, 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. 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>
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) |
Problem
A client VM's page tables, and the GPUVA nodes that record its mappings, were not counted by the GPU memory limits, not shown in the client's fdinfo and not charged to any memory cgroup, and the number of VMs one file could create was not limited. Sparse and single-page binds map a small object over a large range, so the table memory a client causes was not bounded by the memory it holds.
Why this shape
Page-table memory was outside every limit the driver keeps: client buffers are admitted against the client and device ledgers (
memacct), shown in fdinfo and charged to the memory cgroup, while the tables a bind creates were none of these. A narrower change would cap table pages or the bound range per VM with a new constant, which bounds nothing a client can't get around with more VMs and says nothing in fdinfo or the cgroup. Here the tables go through the ledger buffers already use, admitted like a held buffer of the same size and allocated withGFP_KERNEL_ACCOUNT, so the existing limits, fdinfo and the cgroup see them. The GPUVA nodes are charged to the cgroup the same way. The one new number is the per-file VM cap, a policy bound like the memory limits; it is asked about below. Every GPU family takes the same accounting.Change
Three commits in
drivers/gpu/drm/asahi: page tables are charged to the client that created the VM (admitted against its limits once allocated, after every other step that can fail, refusals fail the bind with ENOMEM, allocated withGFP_KERNEL_ACCOUNT); GPUVA nodes are allocated withGFP_KERNEL_ACCOUNT; and VM_CREATE past 64 VMs in one file fails with EBUSY. Mesa creates one VM per file, and Borealis's sparse space on M5 needs 8 MiB of tables (16 MiB with its read-only shadow).It applies to the client VMs of every GPU family; there is no chip, board or firmware condition. The 64-VM cap is a new per-file limit, like the existing memory limits, a policy bound rather than a hardware value (see the questions below).
Since RyanTheTide's review: a table is now charged only after the last step that can fail, so a failed table leaves no charge behind. The first commit has a new KUnit case for the refusal on a root that records its own tables. The third commit's message says the cap is per file.
Testing
On the J775D (Mac Studio, M5 Ultra), on this PR's own base: integration/aurora b21dcc6 plus #1973, which the J775D needs for its GPU node and G17D binding, and nothing else. Kit
pr2530-1is that base with this PR at 6386898; kitpr2530-1bis the same base without it. One read-only one-shot boot of each through the 27.0 firmware stub, default command line, 0 GPU client failures at boot on both. Aura was main 82ee5d6fdbdf with the commits of aura#262 and aura#264, both merged since.pr2530-1b)pr2530-1)SPARSE_TILEasahi_pgtable_charge3 of 3 andasahi_memacct12 of 12 (11 of 11 on the base), every other suite the same.Regression run (ALARM has no SELinux, so there is no AVC count): 0 new failed units (iwd.service and systemd-networkd-persistent-storage.service fail on the read-only test root on both kits) and 0 new kernel error lines: both boots log the same 7 error lines once timestamps and numbers are removed.
Extra evidence, not this PR's own row: the earlier run on integration/aurora cc14570 with #1973, our three other open drm/asahi PRs and a local appledrm fix gave the same charge, release and cap. dj's review asked for the run above in its place.
Still to run
dEQP-VK.sparse_resources.*and the render CTS subset with the same results as the base, fdinfo showing the sparse table charge and its release, 0 new kernel errors and 0 failed units. Rows from RyanTheTide's lab or an M1/M2 owner welcome.Full description of the three commits
GFP_KERNEL_ACCOUNT. The charge is released when the VM is destroyed. Kernel VMs are not charged.GFP_KERNEL_ACCOUNT.Legitimate use stays far below the limits: Borealis'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 every GPU family. On non-M5 parts Borealis advertises a 512 GiB sparse space, which with its shadow would be charged up to 512 MiB of tables if filled completely.
Full test results
On the Mac Studio (M5 Ultra), 27.0 firmware, read-only test root, kits
pr2530-1(integration/aurora b21dcc6 + #1973 + this PR) andpr2530-1b(the same without this PR):SPARSE_TILE: +512.2, +512.2 and +512.0 MiB, then -0.1, -0.1 and +0.1 MiB. Without it: fdinfo and the GPU memory counters +0.0 MiB for both binds, and the cgroup -1.2 and +0.0 MiB after them (no charge), while free memory fell 486 and 515 MiB.apple_g17_rx_util_min_test, which needs CONFIG_UCLAMP_TASK, andj713_accepts_all_loaded_images). Counted per case from the KTAP lines.asahi_pgtable_charge3 of 3, includinga_refused_table_is_neither_charged_nor_recorded;asahi_memacct12 of 12 (11 of 11 on the base).tools/asahi/run-host-tests.pyin the build VM: 461 of 461 on integration/aurora b21dcc6 and on that base with arm64: dts: apple: t6050-j775d: Give the Mac Studio (M5 Ultra) a working GPU, and its M and P core capacities (754/1024) to the scheduler #1973 and this PR; 0 of 461 runs differ.Questions
Thanks to ewb, who reported the uncharged page-table memory and suggested the charge, and to RyanTheTide for the review.
Assisted-by: LLM (Claude:Opus 5.5)