Skip to content

drm/asahi: g16: share the live VMs between processes and charge VM arenas to their client - #2895

Merged
RyanTheTide merged 5 commits into
mainfrom
pr/g16-vm-share-arena-charge
Nov 28, 2026
Merged

RyanTheTide merged 5 commits into
mainfrom
pr/g16-vm-share-arena-charge

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On G16 (M4), every user VM holds one of the device's 63 TTBAT slots for its lifetime, and the live-VM limit is counted per open file only. A process can open the render node any number of times, so that limit doesn't bound how many slots one process holds. Separately, a VM's private arena (about 0.7 GiB for a rendering VM) is made of kernel objects that count only towards the device's kernel total. The client's memory limit and fdinfo never see them.

Change

  • Share the live VMs between processes. VMs are now also counted against the creating process, by the rule queue_share already applies to queues: a process may always hold half of the VMs, and more only while a reserve stays free for the others or while it is the only process holding any. The 8-per-file limit stays. queue_share gains Shares, the same per-process count under the owner's lock.
  • Charge the arenas to the client. new_vm_for_file() now receives the file's memacct client, and G16 sets it on the VM before the registry and the arenas see it. A client VM's private objects are admitted against that client's limit (ENOMEM past it) and held as its user memory instead of kernel memory, so they are counted once.

No new parameters, no chip or board gates. Other backends ignore the new new_vm_for_file() argument, as before.

Testing

  • New host test tools/asahi/g16-vm-share-tests.py, registered in run-host-tests.py. It compiles the production Registry::reserve/release and the queue_share rule against mocks. It checks that VMs stay available to a new process and to the compositor while one process holds many, that a VM given back can be created again, and that a process alone can still use every VM. --mutations: the previous reservation and a share that is never given back both fail (2/2).
  • aurora.o builds with the fleet release config (all backends), with no new warnings.

Still to run

  • J773g (M4 Mac mini) row on the default cmdline, same checks as the J713 row below.
  • On both: VM exhaustion with several clients beside the compositor, two-client VA isolation and fault attribution, the 8 GiB per-client limit, and multi-context dEQP plus the regression check (0 SELinux denials, 0 failed units, 0 new kernel errors).
  • J713 (M4) row on the default cmdline: the desktop and two GPU clients still work. Before and after this series, check fdinfo drm-total-system around a client's first render: it should grow by the arena size with the series and not without it. Also check gpu_memory.
Notes for review
  • The process key is the creator's mm, as in queue_share; a reference to the mm keeps the key from being reused while VMs count against it. VMs created without a process context (new_vm, file id 0) count under key 0, as they counted under file 0 before.
  • The registry takes the processes lock inside files; release() drops the returned process (and its mm reference) after both locks.
  • Arena charges use Charge::user(commit, None) + set_held(true), as the G17 shared pools do (lower_user_charged), with new_kernel_object_wc_user_charged so the device total does not count them twice. The charge lives in the arena's Objects and is released with its backing.
  • A refused arena (ENOMEM) fails the submission that needed it; the VM and its other work are unaffected.

…iles

Every G16 user VM holds one of the device's 63 TTBAT slots for its
lifetime. The live-VM limit was counted per open file only, so it did
not bound how many of the slots one process holds, and VM creation by
other clients could fail with ENOSPC until that process exits.

Count the live VMs against the process that created them as well, by
the rule the queues already use (queue_share): a process may always
hold half of the VMs, and more only while a reserve stays free for the
others, or while it is the only process holding any. The count follows
the VM's live token, so a VM whose handle is closed but whose binding
is still deferred keeps counting. The eight-per-file limit stays.

queue_share gains Shares, the same per-process count kept under its
owner's lock, so the registry can apply the rule to its own resource.

Add a host test that runs the production reservation and release
against mocks: VMs stay available to a new process and the compositor
beside a process holding many, a VM given back can be created again,
and a process alone may still use every VM. The previous reservation
and a share that is never given back are mutants.

Signed-off-by: Ryan Murray <[email protected]>
A G16 VM's first render or compute submission builds its private arena
(the two PB heaps, TPC, tilemap, pools and slot storage: about 0.7 GiB
for a rendering VM) from kernel objects. They were counted only in the
device's kernel total, never against the client, so neither the
per-client limit nor fdinfo saw them.

Hand the client's memory accounting to the backend when the VM is
created (new_vm_for_file() gets the file's memacct client) and set it
on the VM before the registry and the arenas see it. Private objects
of a client VM are then admitted against that client's limit (ENOMEM
past it, failing the submission that needed the arena) and held as its
user memory instead of kernel memory, so they are counted once. The
session's own objects and VMs without a client are unchanged.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 4915f4b.

Read through at 4915f4b. Isolation is unchanged. Each user VM still binds its own TTBAT slot for its whole life (LiveToken.bind, g16/vm.rs), and Registry::live still caps the total at MAX_VMS. The series only changes who is allowed to reserve a slot and who pays for the arena. Nothing new shares an address space or reuses a slot. "Share" in the title reads like address-space sharing; "divide the live VMs between processes" would say what it does.

  1. queue_share.rs:55, held == total: a process that is the only VM holder can take all 63 slots. A queue can be given back, but a VM holds its slot until the process closes it. So a GPU client that starts before anything else holds a VM (a headless or compute daemon at boot, before the compositor) keeps the desktop's VM_CREATE at ENOSPC until it exits. That is the case the reserve exists for. Please either keep reserve(max) free even for a lone holder, or explain why the escape is acceptable for slots that are never reclaimed.
  2. The key is the mm, so fork() gets past the rule: each child may take up to max/2 (held < 31), and three children exhaust the slots. That is an improvement on the per-file count, but the "VMs stay available to a new process and to the compositor" claim only holds for one mm. Please say so in the commit message.
  3. g16/vm.rs:240-249: a GFP_NOWAIT failure of the Shares push is reported as ENOSPC (Err(_)), so a transient allocation failure looks like "no VM slots". Propagate ENOMEM and keep ENOSPC for the EBUSY refusal. The lock is a mutex, so GFP_KERNEL would also work here.
  4. g16/object.rs:426-441: arenas now go through LEDGER.admit, so the device limit also refuses them, where kernel objects never were. Once another client fills the device limit, a newcomer's first render fails with ENOMEM. On 8 GB machines (client limit 4 GiB, about 0.7 GiB per rendering VM) a single file with 8 rendering VMs passes the per-client limit. Both are reasonable, but neither has been run. One small fix: the charge is pushed before registration_guard(), vmap and the map calls, so if any of them fails the charge stays held until the whole Objects is dropped. Push it after the last fallible step, or note why the early hold is safe.
  5. file.rs:713 still calls .with_memory_client(...) after G16 has already set it in new_vm. It is harmless, but please add a comment or drop it for G16.
  6. The arena charge has no test. The host test covers only the registry and share rule. A kunit test or host test that checks admit/refuse/release around alloc_private_in (and the leftover charge from 4) would cover it.
  7. Hardware rows needed at this head before merge: J713 and J773g on the default cmdline:
    (a) the desktop plus two clients, where one opens the render node about 40 times and creates VMs until refused, and the compositor and a third process can still create VMs;
    (b) a two-client isolation check: client B binds and submits against a VA it never mapped, or one inside A's range, and must fault, with the fault attributed to B only;
    (c) fdinfo drm-total-system and sysfs gpu_memory before and after the first render, with and without the series;
    (d) dEQP multi-context (dEQP-EGL.functional.multicontext.* / multithread.*) and the gpubench delta.
    On drm/asahi: g16 + shared SUBMIT: Wave 6 R2 — demand-grown 32 render slots / 18 compute units, fast SUBMIT path, stamp-only barriers, and batched render release #2826 and drm/asahi: g16: Wave 7 — barrier elision, timestamp-free render microsequences, and 48 render pass slots #2852: git merge-tree reports no textual conflict with either. The drm/asahi: g16 + shared SUBMIT: Wave 6 R2 — demand-grown 32 render slots / 18 compute units, fast SUBMIT path, stamp-only barriers, and batched render release #2826 extension tiers (RenderExtArena, PoolExtArena, ComputeArena ext) are allocated through alloc_private_in, so they are charged too. They are best effort (.ok()), so a client at its limit keeps its base slots. It does retry admit on every submission, though, and that bumps refused each time.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 4915f4b (non-author). Changes requested on the first commit. The second reads right but has no evidence yet.

29e6583 (share VMs per process)

  • This breaks two registered host tests in tools/testing/selftests/drivers/gpu/asahi-m4. test-vm-registry.py and test-resources.py extract Registry/reserve/release/LiveToken from g16/vm.rs, and they no longer compile (new processes field, third Reservation field, release(file_id, process)). run-host-tests.py --only asahi-m4 passes 23/23 with the base driver sources and 21/23 at this commit and at the head (suite exit 1 here). Please update both mocks in this commit.
  • The count is keyed on the creator's mm, and a process below half is granted without regard to the reserve. The reserve is therefore only kept against one process: a second one (a child, or the same program after exec) can take what is left. The commit message and description say a reserve stays free for the others. Please state this limit, or count on a key that survives fork/exec.
  • The "only process holding any" clause lets the process that starts first hold all 63, so a compositor that starts or restarts later gets none. Is that clause needed for VMs? Without it, a single process still reaches 56.
  • reserve() maps every take_current() error to ENOSPC, including an allocation failure of the NOWAIT push. Please keep ENOMEM.
  • Shares records tgid/comm, but nothing prints them; the capacity snapshot only shows the queue share. Either print the VM share there or drop the fields.
  • The new test mocks current_key(), so the process identity itself is not exercised. A case with two processes filling the device would document the intended bound.

4915f4b (charge arenas)

  • The code reads right to me: one user charge per private object, the GEM object uncounted, the charge dropped with the arena, and ENOMEM leaves the VM intact. new_vm_for_file has one override and one caller.
  • There is no test, and the J713 row is still open, so nothing shows the charge yet. Please add the fdinfo before/after row (the first render grows drm-total-system by the arena size, and closing the VM returns it). Also add a row at the client limit showing how the submission failure reaches userspace.
  • The charge also covers the per-render-command page-list/record objects (PbEpoch), not only the arenas. Please say so in the message.
  • with_memory_client is now applied twice (backend and file.rs); one can go.
  • Small: the charge is pushed as held before prepare_new_object/vmap/map can fail. A failure there keeps it until the Objects is dropped. That is fine with today's callers, but worth a comment.

Slot release on every path (including release from another process), key reuse (the entry holds an mm reference), the lock order (files then processes, never nested with vms or memacct) and the arithmetic at 63 (half 31, reserve 7) all check out. No gates or new constants.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formal §1–§6 pre-PR checklist review at live head 4915f4b23ac42feaa7065fb6dc1493c7e2cf0117.

Live CI Status

  • host-tests: FAILED (462/463 passed; run 45084522436). While the new g16-vm-share-tests (control + --mutations) passed, the existing asahi-m4 selftest tools/testing/selftests/drivers/gpu/asahi-m4/test-vm-registry.py failed to compile with 4 rustc errors (E0061, E0063, E0433, E0609, including missing processes field in Registry initializer) because g16/vm.rs changed Registry, Reservation, and release() without updating test-vm-registry.py.

Blockers

  1. CI failure (tools/testing/selftests/drivers/gpu/asahi-m4/test-vm-registry.py): Update the existing asahi-m4 registry selftest harness to match the updated Registry (processes: Mutex<Shares>), Reservation, and release(file_id, process) signatures so host-tests is green.
  2. Lone-holder DoS gap for non-reclaimable TTBAT slots (drivers/gpu/drm/asahi/queue_share.rs:55, g16/vm.rs:240): queue_share::may_take allows held == total, so a single GPU client starting before the compositor (e.g., a headless/compute daemon at boot) can claim all 63 exclusive TTBAT slots (MAX_VMS). Unlike queues, G16 VMs pin their TTBAT slot until closed (and deferred/failed VMs retain it longer), locking out the compositor and any subsequent process with ENOSPC. Either preserve reserve(max) even for a lone holder for non-reclaimable VM slots, or justify why the escape is safe (while still ensuring robust_isolation with limit == 1 works). Also clarify in the commit message that keying by mm means fork()ed children each get a fresh mm and 3 children can still exhaust all 63 slots.
  3. GFP_NOWAIT allocation errors masked as ENOSPC (drivers/gpu/drm/asahi/g16/vm.rs:206,236,240-250): Shares::new() is not preallocated (unlike files at L200), yet take_current(limit, GFP_NOWAIT) allocates inside a sleepable Mutex, and L245-249 collapses every Err(_) (including ENOMEM) into ENOSPC. Preallocate Shares with MAX_VMS capacity or allocate with GFP_KERNEL, and map only EBUSY to ENOSPC while propagating ENOMEM.
  4. Early Charge push before fallible steps (drivers/gpu/drm/asahi/g16/object.rs:426-445): charge.set_held(true) and self.charges.push(charge, GFP_KERNEL)? happen before registration_guard(), prepare_new_object(), vmap(), the 3 map_in_range/map_at calls, and Arc::new(). If any of those fail on an Objects container that is not immediately dropped, backing is freed while charge remains held as phantom resident/committed bytes. Since self.charges.reserve(1, GFP_KERNEL)? already ran at L428, defer charge.set_held(true) and self.charges.push(...) until right before self.retained.push(...) at L537.
  5. Missing arena-charge test coverage: tools/asahi/g16-vm-share-tests.py covers only Registry::reserve/release + queue_share; there is no host or KUnit test verifying alloc_private_in admit/refuse/release and rollback accounting.
  6. §5 Evidence (zero hardware runs): No hardware rows have been run yet. Before merge, provide J713 (M4) and J773g (M4 Mac mini) default-cmdline rows covering: (a) multi-client VM exhaustion beside compositor + third client, (b) two-client VA isolation / fault attribution, (c) before/after fdinfo (drm-total-system) and sysfs gpu_memory around first render (plus 8 GiB client-limit sanity check), (d) multi-context dEQP + standard regression run (0 SELinux denials, 0 failed units, 0 new kernel errors).

Checked & Clean + djdev/g16-* Stack Overlap Notes

  • Locking & refcounts (g16/vm.rs:231-270): Lock ordering (files → processes) is consistent across reserve() and release(), and release() drops Option<Process> (and its Option<ARef<Mm>>) outside both locks. Objects field drop order (retained, mappings before charges) releases backing before uncharging.
  • §1/§2/§3/§4/§6: Pass (no model gating, default cmdline, no hardcoded safety limits; both commits carry human Signed-off-by only with zero AI trailers and Assisted-by in PR body; clean naming). Minor nit: file.rs:713 calls .with_memory_client(...) after G16 already set it in g16::vm::new_vm (needed for non-G16 backends; a short comment avoids confusion).
  • Overlap with djdev/g16-* stack (#2787, #2826, #2852):
    • File overlap: drivers/gpu/drm/asahi/file.rs overlaps with #2826 (Wave 6: SyncItem/Object cmdbuf reuse & SUBMIT path; disjoint from #2895 L712 vm_create). drivers/gpu/drm/asahi/g16/mod.rs overlaps with #2787 (Wave 2–5) and #2826 (Wave 6) in Shared/Driver/FAST_POLL_WORK (disjoint from #2895 L619–629 new_vm/new_vm_for_file). Zero file overlap with #2852 (Wave 7). No textual merge conflicts expected.
    • Symbol/semantic interaction with #2826: #2826's demand-grown extension tiers (RenderExtArena, PoolExtArena, ComputeArena ext) allocate through factory.objects(vm) → Objects::alloc_private_in(), so they automatically inherit client charging via LEDGER.admit. Best-effort .ok() growth preserves base slots at the limit, though note repeated submissions at the limit will re-hit admit and increment LEDGER.refused.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 2606f52b: not ready yet

Check Detail
CI at head ok 19 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes no requested by DjDeveloperr
Hardware row at head ok comment at 2606f52b
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 4915f4b23ac4

Blockers:

  1. CI is red: tools/testing/selftests/drivers/gpu/asahi-m4/test-vm-registry.py still uses the old Registry signatures. Update it for processes: Mutex<Shares>, Reservation and release(file_id, process).
  2. drivers/gpu/drm/asahi/queue_share.rs:55 with g16/vm.rs:240: may_take allows held == total, and G16 VMs keep their TTBAT slot until closed. So one client that starts before the compositor can take all 63 slots, and later clients, the compositor included, get none. Fix: hold back a share for other processes, as the queue share does.
  3. drivers/gpu/drm/asahi/g16/object.rs:426-445: the charge is marked held and pushed before the fallible steps (registration_guard(), prepare_new_object(), vmap(), the map calls). If one fails on a container that lives on, the backing is freed while the charge stays held. Fix: push the charge after the last fallible step.
  4. Missing rows: one M4 (J713 or the J773g) at the head with several clients beside the compositor and fdinfo memory checked around the first render, and, since file.rs and queue_share.rs are shared, one run on another generation showing no change.

Checked: no Apple material, no gates. Lock order (files → processes) is consistent, and release() drops the process outside the locks. Nit: GFP_NOWAIT failures are reported as ENOSPC (g16/vm.rs:245-249).

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 23:38

Superseded by the review at 4915f4b

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
…e they live

Review follow-up.

The live-VM share took the queues' rule, which lets a process alone take
every slot. Queues come and go, but a G16 VM keeps its TTBAT slot until
it is closed, so one client started before the compositor could hold
all 63 and leave none for anything started later. VMs now take
may_take_held(): a process alone still leaves the reserve (7 of 63) for
the others. Queues keep their rule.

The arena charge was marked held and pushed before the fallible steps
(registration_guard(), prepare_new_object(), vmap(), the mappings). If
one failed on a container that lives on, the backing was freed and the
charge stayed held. Hold and push it once the object is retained.

A refused share is ENOSPC, as before; an allocation failure under the
registry lock now stays ENOMEM instead of reading as ENOSPC.

Update the host tests: test-vm-registry.py for the new Registry,
Reservation and release() signatures (CI was red), with the VM share by
queue_share.rs's own rule and a case for the reserve a lone process
leaves; g16-vm-share-tests.py for the same, with a mutant for the old
rule. Both pass; all three mutants fail.

Signed-off-by: Ryan Murray <[email protected]>
# Conflicts:
#	drivers/gpu/drm/asahi/g16/object.rs
#	tools/asahi/run-host-tests.py
#	tools/testing/selftests/drivers/gpu/asahi-m4/test-vm-registry.py
@RyanTheTide
RyanTheTide requested review from a team as code owners November 27, 2026 06:54
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Fixed at ed937d4 (fix commit 1533415 plus a merge of main, normal push).

  1. CI red: test-vm-registry.py is updated for processes: Mutex<Shares>, the three-field Reservation and release(file_id, process). Its mock Shares uses reserve()/may_take_held() copied from queue_share.rs. It now has a case for a lone process (56 of 63, then the compositor still gets a slot) and keeps main's new prune/cache case: 5/5 pass.
  2. A lone client takes all 63 VM slots: VMs now take may_take_held(), under which a process alone still leaves the reserve (7 of 63). Queues keep may_take(), since a queue doesn't hold a slot until close. KUnit case a_lone_vm_holder_still_leaves_the_reserve. g16-vm-share-tests.py has a lone-takes-all mutant: 3/3 mutants killed.
  3. Charge held before the fallible steps: the charge is held and pushed only after the object is retained, with room reserved up front, so an earlier error leaves no held charge. In the merge with main's object.rs rework (FwCoherent, probe-time objects) the charge path is woven into main's flow (FwCoherent keeps its cacheable backing, which never has a client VM), and main's two new constructors get charges.
  • Nit: an allocation failure under the registry lock now stays ENOMEM. Only the share's refusal is ENOSPC.
    Testing: builds in the fleet-config kernel 7.3.0-aurora-fixa2 (this PR's files byte-identical to its head).
    Still to run (4): M4 rows (J713 or J773g) with several clients beside the compositor and fdinfo memory checked around the first render, plus one other generation for no change. Queued with the fixa2 kernel.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Row at ed937d44b956 (this PR's files byte-identical in the combined test kernel 7.3.0-aurora-fixa2): M1 Pro (J316s, T6000/G13S): PASS, M2 Air (J413, T8112/G14G): PASS.

This is the 'one run on another generation showing no change' for the shared file.rs/queue_share.rs. The M4 multi-client fdinfo row is still owed.

Detail

Both rows ran on the default cmdline with the kernel booted once as a non-default entry, then back to fleet89, which was verified afterwards (saved entry, empty next_entry, kernel removed, 0 failed, Enforcing). Per Mac: SELinux Enforcing, 0 failed units, 0 AVC, 0 err-level kernel lines, 0 oops; Wi-Fi ping OK; s2idle (rtc1, 15 s) rc=0 with ping and a 64 MiB direct NVMe read after the wake; Apple SoC watchdog armed with time left counting (44 s and 58 s of systemd's 60 s); dEQP-VK api.smoke 8/8 pass. J413 also: glmark2 off-screen (FBO) score 7672, 2 audio sinks. On the M1 Pro, glmark2-wayland never starts rendering: its internal panel is dead and there is no Wayland output, the same on fleet89 (traced), so no GL FBO number there. Silent, no playback. Logs: traces/kernel/20261127-fixa2-rows/ (store).
Kernel kit: kits/test/20261127-fixa2 = main 0a4f97d + forward-merged heads of #2919 #2886 #2302 #2475 #2393 #2384 #2895.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) labels Nov 27, 2026
The main merge brought test-resources.py fixtures that build the
production LiveToken from vm.rs. With this branch the token carries the
creating process and Registry::release() takes it, so the fixtures no
longer compiled (E0063/E0061, asahi-m4 host test red).

Give the mock tokens process 0 and the mock Registry::release() the
process argument.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

CI fix at 2606f52: the asahi-m4 host test was red because main's test-resources.py fixtures build the production LiveToken from vm.rs. On this branch the token carries the creating process and Registry::release() takes it. The fixtures now pass process: 0 and the two-argument mock release(). Test-only change; the driver code is unchanged since ed937d4.

Tested: run-host-tests.py --only asahi-m4 1/1 (was not ok 16 - test-resources.py, E0063/E0061).
Risk: none to the driver. The rows at ed937d4 still apply, since only selftests changed.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

M4 Pro (T6040, J616s) multi-client row at this head (2606f52). The kernel was the combined fixa5 test kernel, linux main fca33ed plus the heads of #2887 #2959 #3384 #2919 #2393 #2895. Eight of the ten files this PR changes are byte-identical to this head. The other two:

  • drivers/gpu/drm/asahi/file.rs: main changed it after this PR's base (64-VMs-per-file cap and mapping-record charging).
  • tools/asahi/run-host-tests.py: carries the other PRs' test registrations.

In both, the combined file is this head plus only main's or the other PRs' lines, with none of this PR's lines missing. One-shot BLS entry, default command line.

Scope: the J616s runs the G17 backend, so the G16 arena charge itself is not exercised here. This row covers the shared paths this PR changes on every backend: the per-process queue_share VM accounting and the new new_vm_for_file() argument. The G16 rows (J713 / J773g: drm-total-system around a client's first render, VM exhaustion) are still owed.

Concurrent clients for 70 s beside gnome-shell. Each client's DRM fdinfo and the G17 capacity sharing lines were read every 5 s.

  • glmark2-es2-wayland off-screen (GL): rc=0, score 9382.
  • gpubench-vk compute.heavy, 12 x 2.5 s: rc=0, median 430.6 us/submit, 0 errors.
  • dEQP-VK draw.renderpass.simple_draw.* in a loop: 883 runs, all 4/4, 0 failed.
  • 3 x qpair, 300 render+compute submits each, results checked on the host: 3/3 rc=0, 0 errors.

For 0-60 s at least three clients (glmark2, gpubench, dEQP) ran beside gnome-shell. queue_share showed up to held=5 processes=4.

fdinfo looked sane:

  • Each client reported drm-total-system / drm-resident-system and its engine time.
  • glmark2 ranged 24.3-29.0 MB, dEQP 0.87-20.8 MB, gpubench 0.87-6.5 MB. gpubench's compute engine time grew while it ran.
  • 16 distinct client ids.

Counters before vs after were identical:

  • queue_share held=2 processes=1 (gnome-shell only).
  • logical_queues used=2, render_slots used=1, execution_contexts used=1.
  • client_private_bytes high_water unchanged.
  • No new refusals: the LogicalQueues count of 6 came from the earlier pool-churn run on the same boot.

Same boot:

  • 0 failed units, Enforcing, 0 AVC denials, 0 oopses, 0 err-level kernel lines.
  • dEQP-VK api.smoke.* 8/8, glmark2 22375 run alone. s2idle x1 rc=0.
  • The only kernel noise was the Thunderbolt ACIO firmware's "at_rt command response expired" syslog lines. They're pre-existing: 283 and 778 of them on the two previous fleet89 boots.

The J616s was restored to fleet89 and verified: saved entry unchanged, next_entry empty, test kernel removed, Enforcing, 0 failed units.

Evidence (lab store): traces/kernel/20261128-fixa5-rows/j616s/ (B-multi.txt, B-out/multi/ with samples.txt fdinfo per 5 s, capacity before/after, kmsg). Script: kits/test/20261128-fixa5/multi.sh.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

G16 row at 2606f52b, on the J713 (M4 Air, G16G), combined test kernel 7.3.0-aurora-fixa6 (main fca33ed6 + this head + #2887 #2959 #3384 #2919 #2393 #2632). This PR's files are identical to 2606f52b apart from file.rs and run-host-tests.py. In those two the only extra lines come from main or the other PRs. Default cmdline, one-shot non-default entry. Control: the saved default fleet85 (no #2895, no 990b848a), same script, same session.

Clients. The compositor plus 6 concurrent GPU clients for about 70 s:

  • gpubench-gl render.heavy (GL) and gpubench-vk compute.heavy (VK compute)
  • a dEQP-VK draw.renderpass.simple_draw loop
  • 3 qpair processes (VK render+compute, every result checked on the host)
  • one qpair probe client

Up to 19 DRM fds in one sample, 34 distinct DRM client ids over the run.

  • fixa6: every client exits 0. gpubench-gl 2/2 and gpubench-vk 2/2 results. dEQP 605 iterations, 0 failures. qpair 3×301 + 51 submits, 0 errors. A second pass gives the same results (611 dEQP iterations).
  • G16 stats: health failed 0, recoveries 0, hang_kills 0. gpu_memory refused 0. Enforcing, 0 failed units, 0 AVC.
  • Control: same clients, all pass (589 dEQP iterations, 0 qpair errors).

Arena charge around a client's first render. The probe creates its device, VM, buffers and pipelines, then holds before submitting. fdinfo is read there and again right after its first render:

before first render after growth
fleet85 (control) 2160 KiB 3056 KiB +0.9 MiB
fixa6 2.46 MB 257.5 MB +255 MB (the arena)

The device ledger moves the same way. At peak load, fleet85 counts the arenas as kernel memory (kernel_resident 393 MB idle, 1343 MB loaded, user_committed flat at 222 MB). fixa6 counts them as user memory (user_committed 2357 MB, kernel_resident 8.7 MB). Per client, drm-total-system is about 257 MB for qpair and dEQP, 287 MB for gpubench-gl and 821 MB for gpubench-vk. Nothing is counted twice.

Back to baseline: not exactly, because of main's 990b848a, not this PR.

  • fleet85: back to its pre-run values (user 221.8 MB, kernel 393 MB, vm_bindings live 2).
  • fixa6 after pass 1: vm_bindings live 1 → 18 and user_committed 382 → 768 MB, with only the compositor left as a client. The stats show pb: ... kept 18. Main's 990b848a (11-24) keeps a VM's last PB epoch, and its owner arena, until the next render retires on that allocator slot. With this PR, those retained arenas now show in user_committed after their client has closed.
  • It is bounded. Pass 2 starts at live 17 / 492 MB and ends at live 18 / 565 MB. It doesn't grow with more clients.
  • Is a closed client's retained arena meant to stay in the user total, or to move back to kernel memory once its file closes? Worth a line in the PR's notes either way.

Unrelated to this PR, under GPU load on fixa6: about 280 apple-pmp-thermal: sensor error -61; CPU minimum caps retained lines (main's PMP thermal driver). G16 stats show sensor_errors 0. None on fleet85.

Not covered here: the J773g row, VM exhaustion, two-client VA isolation/fault attribution and the 8 GiB per-client limit. The clients ran as the greeter user on the fixa6 boot (no auto-login after the reboot) and as the desktop user on the control.

Evidence (lab store): traces/usb/20261128-fixa6-rows/j713/ (A-multi.txt, B-multi.txt, B-multi2.txt, out/ with per-client fdinfo samples). Script: kits/test/20261128-fixa6/multi16.sh.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 2606f52b

Blockers: none (20/20 CI green and exact-head G16/T6040 multi-client hardware rows PASS; ready to merge).

Checked:

  • Prior CI & ownership blockers resolved cleanly (2606f52b updates tools/testing/selftests/drivers/gpu/asahi-m4/test-vm-registry.py for LiveToken process ownership; 15334152 bounds per-process VM slots and charges private arenas once across shared VMs).
  • Hardware rows & CI: 20/20 CI checks green (SUCCESS), MERGEABLE on main, and exact-head multi-client rows PASS on both J616s (M4 Pro / T6040, fixa5) and J713 (M4 Air / G16G, fixa6).
  • Checked for Apple material, tool attribution, private serials, and gating: clean; human Signed-off-by present.
Evidence
  • Head: 2606f52b8c95 (base: main, mergeable: MERGEABLE, +476/-43 across 10 files).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at 2606f52b. The review App approved this head (NEON-PR-REVIEW2's adversarial pass). Rows: J616s+J713. This merges under the 6-point rule 1 h from now, once hosted CI is green, unless you object.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging under the 6-point rule (Ryan 09:29, permanent), at 2606f52b. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J616s+J713. (5) There's no blocking review. (6) Dj was pinged here 118 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 3ad22d4 into main Nov 28, 2026
21 checks passed
@RyanTheTide
RyanTheTide deleted the pr/g16-vm-share-arena-charge branch November 28, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants