Repository navigation
drm/asahi: g17: scale the tiler heap's normal maximum with memory - #2724
Conversation
|
Good writeup. The sizing comes from a memory share measured on the machine, not a per-model table, and the 15k-40k triangle numbers make the case. An adversarial read of 0a2a5c2:
Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial review of head 0a2a5c2b8f6543f30ab09bf035d9f621f0581b16 against the pre-PR checklist. Holding approval and requesting changes on the memory-accounting/VA-exhaustion implications and missing hardware evidence on this head.
Code & resource-limit findings
-
Per-heap RAM multiplication is unattributed to clients and bypasses GPU memory admission limits.
Following up on Ryan's point #1 directly fromgem.rsandmemacct.rs:Tvb::prepare_growth()allocates each extension viaKernelObject::backing()->gem::new_kernel_object_wc()->memacct::Charge::kernel(&memacct::LEDGER, size)(gem.rs:324). In this driver:- Kernel objects are not charged to any client (
Client) or processmm(MM_SHMEMPAGES), so the OOM killer does not score the offending client for them. - Kernel objects bypass both
LEDGER.limitandLEDGER.client_limit(memacct.rs:215: "Kernel objects share the device limit but are never refused"), while increasingkernel_residentand shrinking the budget left for other clients' user BOs. set_mapping_held(&gem, true)pins the shmem pages asAS_INACCESSIBLE | AS_UNEVICTABLE(unswappable, unmigratable), and off-lock growth runs in scheduler/workqueue context rather than reliably under the submitting task's memcg.
BecauseLayout::neo(memory_bytes()?)applies per physical render pair (RENDER_SLOTS = 64, and one logical queue can hold 2 pairs), raising the cap from 140 MiB to 256 MiB (16 GiB Mac), 384 MiB (24 GiB), or 419 MiB (≥26.2 GiB) multiplies per active heavy pair — e.g., 4–8 heavy pairs on a 16 GiB Mac can pin 1–2 GiB of unswappable, unattributed, limit-bypassing kernel memory.
- Kernel objects are not charged to any client (
-
Whole-extension shrink interacts poorly with the larger 3× growth steps.
Inbuffer.rs:1012-1050, 1266-1285:- While a client stays active on light frames (
now - last_busy < 10s),shrink_target()earnsSHRINK_STEP_BLOCKS = 4(512 KiB/s) and only shrinks oncecredit >= last(the entire last extension), resettingcredit = 0on any period above 1/4 capacity. A single 3× growth jump from e.g. 900 -> 2,700 blocks creates a 1,800-block (225 MiB) extension that takes 7.5 minutes of uninterrupted low load to release while active. - Because
Manager::shrink()can only drop whole trailingKernelObjectextensions (kept - size < target), ifshrink_floor()sits anywhere above the pre-jump size (e.g. 950 blocks after a 900 -> 2,700 jump), that 225 MiB extension cannot be shrunk even after 10 s idle untilbusy_peakdrops below 450 blocks.
Raisingnormal_blocksup to 3× makes both the peak footprint and this coarse-granularity retention substantially heavier. Please either bound/attribute TVB growth (or cap individual extension chunk size so shrink can reclaim incrementally) or demonstrate multi-client pressure behavior on a 16 GiB Mac.
- While a client stays active on light frames (
-
Multi-pair compact-VA spillover into
TARGETSwithin a single VM (hw/t8140.rs:346-355).
compact_ranges()providesTVB_MAX_BLOCKSslots inTVB_GROWTH(pair 0) andTVB_MAX_BLOCKSinsecond(pair 1), and then falls back toTARGETS(320 MiB, shared with render targets). Previously at 1,118 blocks/pair, up to 6 render pairs in one VM fit in the two TVB arenas without touchingTARGETS. At 3,353 blocks/pair (≥26.2 GiB Macs), just 2 heavy pairs in one VM fill both TVB arenas completely, so a 3rd growing render pair in the same VM spills TVB blocks intoTARGETSand then fails withENOSPC. -
Minor cleanups:
buffer::memory_bytes()(buffer.rs:319) duplicatesmemacct::total_ram_bytes()(memacct.rs:104).GraphArgs.normal_blocksis populated for both NEO and M5 (buffer.rs:819), validated/used byfw::Graph::init(), and silently ignored byLayout::initialize()(which readsself.normal_blocksinstead).
Evidence & checklist blockers
- No hardware boot or regression run on current head
0a2a5c2b(Checklist §5): the J616s numbers in the PR body are from an older superseded revision (#2186) onm4.166(which also carried#1902and#1986), and no regression run (0 SELinux denials, 0 failed units, 0 new kernel errors) is reported for this head. - No conformance run for a performance change (Checklist §5): checklist requires a same-machine A/B with conformance unchanged on every GPU generation the change applies to.
- Untested scaled range (9–26 GiB) & A18 Pro: as noted by Ryan and in the PR body, no 16 GiB / 24 GiB Mac has exercised the non-clamped formula (
BM+0x80= 2,048 / 3,072), and the J700 (A18 Pro) readback/no-regression row is still pending. - CI:
host-testspassed on0a2a5c2b. - Checklist §1–§4 & §6: Pass on code (RAM-scaled policy with no chip/board/firmware gates, default cmdline, human-only
Signed-off-byin commit, clean-room live measurements). Minor attribution nit: PR body ends withAssisted-by: LLM (Claude:Opus 5.5)instead ofAnthropic:Claude Opus 5.5.
Assisted-by: LLM (Google:Gemini 4 Neon)
A growth of the tiler heap is one backing object, and a shrink can only give back whole trailing growth objects. A heap that grew from 900 to 2,700 blocks in one step holds a single 1,800-block (225 MiB) extension: the active shrink returns it only after 450 periods of shrink credit, and the idle shrink cannot return it at all while its floor sits above 900 blocks. Build each growth from extensions of at most 64 blocks (8 MiB). The active shrink then gives back 8 MiB every 16 periods of credit, and the idle shrink stops within 8 MiB of its floor. A full block table is 53 extensions. Signed-off-by: Jonathan Goyvaerts <[email protected]>
… they go Tiler-heap blocks are placed in the first of the compact client arenas with room: the render-alias window, the two tiler-heap growth arenas (3,321 and 3,353 blocks), then the target-record window. Growth that fills both growth arenas, for instance three pairs of one VM at 3,353 blocks, then takes target-record space, and the next target record or growth of that VM fails with ENOSPC, and the render with it. Place growth only in the two growth arenas. A growth that runs out of them or of memory keeps the whole extensions it made, and the tiling pass partial-renders within that heap, as it does when a firmware grow request is refused. An idle growth still fails if the heap would stay below the blocks the render's layout requires. After a growth stopped short, the host grows the heap beyond those blocks again only a shrink period later, as the busy growth already does after a refusal: every attempt allocates and maps afresh. Signed-off-by: Jonathan Goyvaerts <[email protected]>
Tiler-heap growth is allocated as kernel objects: they count towards the device total, but are charged to no client, are never refused by the device or the per-client limit, and are pinned. The client sizes this growth through its renders, and every render pair of every client can hold its own, so many heavy pairs can pin a lot of memory that no limit bounds and no client is accountable for. Admit each growth extension of a client VM's pair against that client's and the device's limits, and count it as the client's held memory, as the M5 pools are. A refused extension ends the growth there: the tiling pass partial-renders within the heap it has, and an idle growth fails with ENOMEM only if the heap would stay below what the render's layout requires. Kernel pairs keep kernel objects. Signed-off-by: Jonathan Goyvaerts <[email protected]>
The tiler heap of a 25G83 render grows on the host only: before a render the host grows it to three times the last high-water, capped at the heap's normal maximum, which also goes to the firmware in BM+0x80. A scene larger than that cap partial-renders on every frame. The cap is the fixed 0x45e (1,118 blocks, 140 MiB) on every NEO-layout heap, whatever the memory. Make the cap a 64th of the memory si_meminfo() reports (memacct's total_ram_bytes(), which also sizes the memory limits), clamped to NORMAL_MAX_BLOCKS..=TVB_MAX_BLOCKS (the block table). BM+0x7c, the heap's capacity, is unchanged. The cap holds for each render pair; the growth up to it is charged to the pair's client and bounded by its and the device's memory limits, and by the VM's growth arenas. Both graph layouts take the normal maximum from GraphArgs. The share comes from three measurements: - On the 48 GiB J616s, macOS 26.6.2 runs the GPU with BM+0x80 = 6,579 blocks (read live), 1/60 of the memory. The fixed 1,118 is 1/59 of 8 GiB. A 64th stays below both, so above the floor the cap is never a larger share of memory than the firmware is known to run with. - At 8.7 GiB and below the clamp keeps 1,118: BM+0x80 stays 0x45e * 4 pages, and the 8 GiB A18 Pro (and its mesh floor) is unchanged. - On the J616s (46.6 GiB usable) a 64th is 5,959 blocks, clamped to the table's 3,353. An off-screen GLES test draws N screen-spanning triangles into a stored 3456x2234 RGBA8 + D24S8 target and waits for each frame. With 1,118, a triangle costs 3.0 us up to N = 14,500 and 9.7 us from N = 15,000. With 3,353, 3.0 us holds up to N = 40,000: N = 20,000 takes 55 ms a frame instead of 193 ms, N = 30,000 83 ms instead of 281 ms. At N = 45,000 the scene passes 3,353 blocks and partial-renders as before. A 16 GiB Mac gets 2,048 blocks, a 24 GiB Mac 3,072; from about 26.2 GiB the table's 3,353 is the limit. Signed-off-by: Jonathan Goyvaerts <[email protected]>
0a2a5c2 to
001d783
Compare
|
Thanks both. New head
Cleanups: Tests on this head: each commit compile-checked with arm64 defconfig + asahi.config, @RyanTheTide, we have no 16 GiB M4 or J700. Could you run the 16 GiB tiler test with |
|
Thanks, this answers the earlier review. At 001d783:
No new code issues found. Assisted-by: LLM (Claude:Opus 5.5) |
|
@jgoyvaerts status against integration/aurora daa9e2d: the four commits merge cleanly, nothing in the files they touch has changed on the tip since 606d37e, and nothing equivalent has landed. The g17 host tests pass on the merged tree (90/90). What is still open is hardware evidence at 001d783: the J616s rows 1-5 from the description (row 4, a growth stopped by the client limit, is the only test of the stop-short path) and a J700 run with a heavy GLES scene that grows the heap, with the BM+0x80 readback. The change request on file is against 0a2a5c2, so it also needs a re-review at this head. |
Main made the NEO tiler heap's normal maximum a firmware-variant value (Variant::tvb_normal_blocks, 492ea7e): the full table, 3,353 blocks, on the 32-core M4 Max where all four clusters tile, the fixed 1,118 elsewhere. This branch scales it with memory (a 64th of RAM, clamped to 1,118..=3,353). Conflicts in g17/buffer.rs Manager::new() and g17/fw/buffer.rs. Kept both: main's check of the variant value stays, and the heap's normal maximum is the larger of the variant value and the memory-scaled one, so neither lowers the other (J616s 48 GiB: 3,353; 32-core M4 Max: 3,353; 8 GiB A18 Pro: 1,118). The mesh-shading floor (aurora.g17_mesh_tvb_floor) stays main's variant value and is not raised by memory: this branch had pinned it to 1,118, which would have lowered it on the 32-core M4 Max. Signed-off-by: Jonathan Goyvaerts <[email protected]>
|
Merged main Main's 492ea7e made the NEO heap's normal maximum a firmware-variant value,
Checks at the new head: asahi/SEP/ISP KUnit 797/798 (1 skip), and all 93 g17 host tests pass. Some host tests fail on this machine on plain main too: g15/DCP/M3-uAPI/SEP want a rustup 1.93.1 toolchain it doesn't have, and Still open, as before: the J616s rows 1-5 at the head, the J700 heavy-GLES run with the |
Main's aurora-silicon#2501 charges an M5 render pair's parameter buffer to its client through KernelObject::client_backing(), and checks the M5 compact window for room before allocating blocks. This branch charges tiler-heap growth to the client per extension and keeps the extensions made so far when a growth stops short. Conflicts in g17/buffer.rs and g17/object.rs, resolved as the union: - the primary blocks use main's Tvb::allocate(): M5 checked for room and charged to the client, NEO kernel memory, as before; - an M5 block is mapped with main's PairObject::ParameterBlock.map(); - each growth extension of an M5 heap checks the compact window for room for its own blocks before it is allocated, so a window without room ends the growth with ENOSPC there, as a full growth arena does on NEO; - growth keeps this branch's charging (Tvb::extension()), so it is counted once. Signed-off-by: Jonathan Goyvaerts <[email protected]>
…_backing() Since the merge of main, a tiler heap's growth has two ways to charge its client for the same thing. Tvb::extension() admits each extension against the client's and the device's limits, allocates it with KernelObject::backing_user_charged() and keeps the charge beside it in an Extension. Main's KernelObject::client_backing(), which M5 primary blocks use, does the same and keeps the charge in the object. It also admits the page-rounded size of the object, which is what it allocates and what the ledger later releases. Allocate every growth extension with Tvb::allocate() and the pair's client instead, so all parameter-buffer backing comes from one place: a client's growth through client_backing(), on M5 after checking the compact window for room for that extension's blocks, which the merge did inline. Extension, Tvb::extension() and backing_user_charged() go. A heap's primary blocks are unchanged: charged on M5, kernel memory on NEO. No change in behaviour: the same extensions are admitted, checked for room on M5, allocated and released in the same order. An extension is a whole number of 16 KiB pages (128 KiB NEO blocks, 512 KiB M5 blocks), so its admitted size is unchanged. Signed-off-by: Jonathan Goyvaerts <[email protected]>
|
Merged main #2501 and this series both charged tiler-heap growth to the client, by two routes: #2501 through Resolution.
Behaviour changes against main, please look at these:
Unchanged from the 11-25 merge: Nothing in the series is redundant after the merge except the charging helpers, which Checks at |
|
@jgoyvaerts checking open drafts today. To come out of draft, this still needs:
If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done. |
|
J616s (M4 Pro, 48 GiB, GPU firmware 25G83) at head Kernel 7.3.0-m4.195: main
Not covered yet
|
… growth arenas A NEO tiler heap grows only into the two growth arenas, which hold one heap at TVB_MAX_BLOCKS each (3,321 and 3,353 blocks). Compact allocations search the render-alias window, then both growth arenas, and the target window only last. So once the 2 MiB render-alias window is full, every render pair's primary heap blocks, page-list alias, scratch, discard, deflake and fragment views, target records and TPC land in the first growth arena, and the heaps of that VM lose that room. On a 3456x2234 target that is about 17 MiB of VA per pair (64 primary blocks, 32 generations' views, 32 records and a 3.3 MiB TPC), about 108 block slots. Now that a heap's normal maximum fills a whole arena on a 48 GiB M4 Pro, a VM with three pairs cannot hold its second heap at the normal maximum: on the J616s the second heap stopped at 3,072 blocks and the third at 64; by the count above, compact objects of the three pairs took about 310 slots of the arenas. Search the target window before the growth arenas. It is 320 MiB, holds the compact objects of about eighteen such pairs, and is reserved from user binds like the arenas, so nothing user-visible moves. An object that does not fit there still falls back to the growth arenas as before. Growth itself is placed as before. Signed-off-by: Jonathan Goyvaerts <[email protected]>
…hare A VM's NEO tiler heaps grow into two growth arenas of 3,321 and 3,353 block slots: room for the heaps of two render pairs at the normal maximum of a 48 GiB M4 Pro. A VM can have any number of render pairs, and the host grows a heap ahead of need as far as its automatic target, so the heaps that grow first take all of the arenas. With three render queues in one process on the J616s, the first heap reached 3,353 blocks, the second stopped short, and the third stayed at 64 and partial-rendered every frame. Cap the host's growth beyond what a render requires at the heap's fair share of the arenas: its primary backing plus the room the VM's heaps can use, divided by the number of heaps. That room is the free slots of both arenas, measured from the VM's address space, plus the growth the VM's heaps hold, which the VM's render pool cache now counts as the blocks each pool grew by after it was installed. Nothing in the share is tuned to a chip or a board: it follows from the arena layout and the heaps the VM has. One heap can still grow to the full normal maximum (3,353 blocks), as can two; three get 2,288 blocks each (64 + 6,674 / 3). Required blocks are never capped: a render that needs more than its share still gets it if it fits, and the busy path passes its required blocks through for this, still without failing the render. Firmware grow requests serve a render that has run out and are not capped. Growth that stops short and shrink work as before. A growth the share cuts to nothing is retried a shrink period later, as a refused one is, which also bounds how often the arenas are walked. A share recomputed as heaps come and go cannot make heaps grow and shrink in turn: - A heap's growth or shrink moves slots between the free and the held part of the room and leaves the share unchanged. Only a heap coming or going, or another object taking or leaving arena room, changes it. - The share only lowers a growth target. No shrink depends on it: a heap above a share that fell keeps its blocks until the existing, usage-driven policy gives them back, and that policy's floor already keeps a heap above the size its automatic growth would grow back to. - A heap that shrank regrows only when its usage asks for it, and then at most to its share. A heap made after the others grew beyond the new share gets only the free room until their usage-driven shrinks give room back. The cap is computed after the pair is taken, outside the device lock, where the growth itself is allocated and mapped into the VM. Signed-off-by: Jonathan Goyvaerts <[email protected]>
A host growth whose first extension already finds no room or memory stops short at 0 blocks. Manager::prepare_growth then returns no growth, and nothing reaches the HEAP trace: in a VM with three render queues on the J616s, the third heap's attempts did not show at all. A growth the heap's arena share cuts to nothing looks the same. Emit a HEAP event of the host source, idle or busy, without growth and with the heap's unchanged size, where the render preparation knows the source. Manager does not know it, and the firmware path already traces its refusals as HEAP_FIRMWARE_REFUSED, so tracing there would emit those twice. Signed-off-by: Jonathan Goyvaerts <[email protected]>
|
Three commits on top of
Behaviour changes: three or more heavy render queues in one VM now split the growth arenas instead of the first one taking them. Fewer than three see no change. Small objects no longer take room in the growth arenas. Tested: at Not yet: the J616s rows at this head: |
|
J616s row 4 (client limit) at Kernel: the same m4.195 test kernel (aurora main Run: one process (one VM, three render queues), with a 700 MiB renderbuffer ballast first, then 20 frames at N = 30,000 and 10 at N = 45,000. 20:53:09-20:53:15 UTC.
This completes rows 1-5 on the J616s. Not yet: the J700 (A18 Pro) heavy-GLES run, and an M5 run of a growth that stops short. |
|
J616s rows at Kernel: our m4.197 test kernel, on its second boot (2026-11-27 04:20:56 UTC, after an unrelated firmware-crash test on the first boot ended in a guard reboot): aurora main
0 GPU recoveries, 0 AVC lines, 0 failed units and no GPU kernel lines in any row window (the only kernel lines were two firewall messages). 0 GL errors. Not covered: the heap trace doesn't show which window the big target's records and TPC landed in, so the fbo row shows that the reordered compact search still fits or falls back cleanly at the largest target, not which of the two happened. Not yet: the J700 (A18 Pro) heavy-GLES run, and an M5 run of a growth that stops short. |
|
@DjDeveloperr this is ready for re-review at
J616s rows 1-5 pass at Still open, and they need other Macs: the J700 (A18 Pro) heavy-GLES run with the |
There was a problem hiding this comment.
Verdict: MERGE at 5cf1361c (once the superseded 0a2a5c2b changes-requested review is cleared and re-triggered pr-text/readiness complete)
Blockers: none
Checked:
- Audited all 9 files (
g17/buffer.rs,g17/buffer/layout.rs,g17/fw/buffer.rs,g17/queue/render.rs,g17/runtime/render/{grow,prepare}.rs,hw/t8140.rs,memacct.rs,mmu/lifetime.rs) against all prior findings from0a2a5c2b:- Client accounting & admission:
Tvb::prepare_growth()allocates every extension viaKernelObject::client_backing(..., vm.memory_client()), honoring per-client and device limits. PartialENOMEM/ENOSPCdrops only the failed chunk (mappings before backing via declaration order), recordsstopped, defers speculative retries bySHRINK_PERIOD_NS, and fails only iftarget < required. - Incremental shrink granularity:
EXTENSION_BLOCKS = 64(8 MiB max per extension) allowsManager::shrink()to reclaim in 8 MiB steps;extensions.reserve(count)andcommit_growthcapacity checks match the multi-extension vector cleanly. - Arena isolation & single-VM fair share:
tvb_growth_ranges()confines NEO growth strictly to the two growth arenas (TVB_GROWTH+second), whilecompact_ranges()putsRENDER_ALIASESandTARGETSahead of them (compact_objects_reach_the_growth_arenas_last).Manager::host_target()+growth_target()cap speculative growth beyondrequiredtoprimary + (free + grown) / heaps.max(1)usingVm::render_pool_growth(), never cappingrequiredor firmware grow requests, and emittingHEAP_HOST_IDLE/HEAP_HOST_BUSYwhen no block is added. - Cleanups & invariants: uses
crate::memacct::total_ram_bytes()directly;Layout::initialize()usesargs.normal_blocks;fw::Graph::init()validatesNORMAL_MAX_BLOCKS..=TVB_MAX_BLOCKSand usesTVB_PAGES_PER_BLOCK;mesh_floor()retainsvariant_normal_blocks(not raised by RAM).
- Client accounting & admission:
- Verified CI & hardware at
5cf1361ccc52: all build/host/KUnit CI checks green (asahi_g17_tvb_limits2/2,asahi_g17_tvb_share5/5,220/220g17 host tests); J616s (M4 Pro, 48 GiB, 25G83) rows PASS at5cf1361c(3-queue VM fair share2,288blocks each, 2-queue VM3,353each,dEQP-GLES31.functional.fbo.no_attachments.maximums.*5/5, 0 recoveries/AVCs/failed units) plus prior client-limit (952 MiB) and shrink rows ata64f33ae.
Evidence
Risk:two-way door · G17 GPUspresent.- Note: J700 (
A18 Pro)BM+0x80readback and M5 stop-short run remain listed in**Not yet:**as follow-up coverage (below 8.7 GiBneo_normal_blocks()clamps to the existing 1,118 blocks).
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
On the 27.2 question from #2186 (#2186 (comment)): the J616s (M4 Pro, 48 GiB) now runs macOS 27.2.1 (26B131, iBoot1
0 GPU recoveries. The values are unchanged, so the upper bound in "Why a 64th" holds on 27.2 too: macOS gives the normal maximum 1/60 of memory there; this PR gives a 64th. The Linux half of the ask still can't run here. Main admits 26B123 only for the T6041; |
|
J700 (Neo, A18 Pro, 7.3 GiB): tiler heap with this change What was tested: this PR's diff (head Heavy render with the heap trace:
All runs completed.
Render CTS against stock: Health: 0 GPU faults, 0 WARN, 0 AVC, 0 failed units. The only flagged boot line is "loading out-of-tree module taints kernel", from building aurora.ko with Not covered: a heavy GLES run and a direct |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approved at 5cf1361. The earlier accounting and placement findings are resolved. Growth allocations charge the VM client, stop at an admission failure and release incomplete mappings before their backing. The 64-block extensions can shrink in 8 MiB steps. Growth uses the two tiler arenas, and speculative growth accounts for the other heaps in the VM. The new J616s runs cover arena placement and multi-queue sharing. The J700 or K114s shared-path smoke and framebuffer-maximums row still gates merge.
What: The NEO tiler heap's normal maximum (
BM+0x80) scales with memory (a 64th of RAM, 1,118..=3,353 blocks) instead of a fixed 1,118 blocks, so big scenes stop partial-rendering every frame on large-memory Macs. To keep that bounded, heap growth is made in 8 MiB extensions, placed only in the growth arenas, and charged to the client through main'sKernelObject::client_backing()(#2501). A growth that runs out of memory or room keeps the extensions it made. Supersedes #2186. New sincea64f33ae2157:010c1e0d94e0: compact objects (primary blocks, page lists, views, records, TPC) go to the target window before the growth arenas, so they no longer take heap room there.b004eb6f131c: host growth ahead of need is capped at a fair share of the VM's growth arenas, so three or more heavy render queues in one VM split them instead of the first taking all.5cf1361ccc52: a host growth that adds no block emits a HEAP event (HEAP_HOST_IDLE/HEAP_HOST_BUSY, no growth).Tested: J616s (M4 Pro, 48 GiB, 25G83) at head
a64f33ae2157on 7.3.0-m4.195: rows 1-5 below pass (normal maximum 3,353 blocks from the heap trace, the sweep at 27/41/55/82/109-117/412 ms, four heavy clients and three queues in one VM, shrink in 8 MiB steps and to the floor after 10 s idle, and on one boot with a 952 MiB client limit the growth stopping at 2,744 blocks with frames still rendering), 0 GPU recoveries/AVC/failed units, no kernel messages (results). KUnit (arm64 qemu) ata64f33ae2157: 853/854 passed, 1 skipped. g17 host tests ata64f33ae2157: all 220 runs pass. At head5cf1361ccc52: KUnit (arm64 qemu) 860 tests, 859 passed, 1 skipped, with the newasahi_g17_tvb_share(one, two and three heavy heaps, required blocks above the share); g17 host tests all 220 pass; the asahi module compiles with 0 Rust errors atb004eb6f131cand at the head. The J616s rows above ran ata64f33ae2157, before the three new commits. At head5cf1361ccc52on 7.3.0-m4.197, J616s: one VM with three render queues, each heap grows to its fair share of 2,288 blocks and every queue renders (82-109 ms at 30k, 413-425 ms at 45k); with two queues both reach 3,353;dEQP-GLES31.functional.fbo.no_attachments.maximums.*5/5 Pass, including 16384x16384 at 0x and 4x MSAA; 0 GPU recoveries/AVC/failed units (results).Risk: two-way door · G17 GPUs: M4 Pro and M4 Max (
t6040,t6041), A18 Pro (t8140), M5 (the 8 MiB extensions, the per-extension charging and compact-window room check, and stop-short growth). Below 8.7 GiB the normal maximum stays 1,118 blocks. Fair share (b004eb6f131c): one or two heavy render queues per VM still reach the normal maximum; three or more each get their primary plus (free arena slots + growth the VM's heaps hold) / heaps, 2,288 blocks with three. Required blocks and firmware grow requests are not capped. A heap made after the others grew past the new share gets only the free room until their usage-driven shrinks return it.Not yet: a J700 (A18 Pro) heavy-GLES run with the
BM+0x80readback; an M5 run of a heap growth that stops short.Details
On 25G83 the tiler heap grows on the host only. Before a render, the host grows it to 3x the last high-water, capped at the heap's normal maximum, and also writes that cap to the firmware in
BM+0x80. A scene bigger than the cap partial-renders on every frame. On main the cap isVariant::tvb_normal_blocks: the full table (3,353 blocks) on the 32-core M4 Max, a fixed0x45e(1,118 blocks, 140 MiB) on every other NEO heap.Series
cfg::tvb_growth_ranges()). A growth that runs out of arena space, M5 compact-window room or memory keeps the whole extensions it made, and the pass partial-renders within that heap, as it does after a refused firmware grow request. An idle growth still fails if the heap would stay below what the render's layout requires. After a growth stops short, the host grows beyond the required blocks again only a shrink period later (defer_growth).memacct::LEDGER.admit()against the client's and the device's limits (defaults 50% and 67% of RAM) before it is allocated, and counted as the client's held memory (fdinfodrm-resident-system,gpu_memory). A refusal ends the growth there, as in 2. Pages are not added to a process'sMM_SHMEMPAGES, as for the M5 pools, because growth also runs from the firmware grow worker. The NEO heap's primary backing, sized by the render target, stays a kernel object.KernelObject::client_backing(). Main's drm/asahi: g17: M5: render large passes instead of losing the device after 26 s, refuse those that cannot fit, and account their memory to the client #2501 charges an M5 pair's parameter buffer (primary and growth) throughclient_backing()and checks the compact window for room before allocating. Growth now uses that one path for both geometries:Tvb::allocate()with the pair's client. On M5 each extension checks the window for room for its own blocks before it is allocated. The series' ownExtensionwrapper andKernelObject::backing_user_charged()are gone. See the merge comment for the behaviour changes this has on M5.HEAP_FIRMWARE_REFUSED).Policy
The normal maximum is a 64th of
si_meminfo()memory, clamped tofw::NORMAL_MAX_BLOCKS..=cfg::TVB_MAX_BLOCKS(1,118..=3,353 blocks), and never below the firmware variant's value (max(variant, scaled)). There is no rounding. The cap is per render pair; 1-3 bound what all pairs of a client and of the device hold together.BM+0x7c(the heap capacity, 3,354 slots) is unchanged. The memory ismemacct::total_ram_bytes(), which also sizes the memory limits.si_meminfo)BM+0x80stays0x45e * 4pages)The A18 Pro (8 GiB) keeps 1,118. The mesh-shading floor (
mesh_floor(),aurora.g17_mesh_tvb_floor) stays the variant value and is not raised by memory. An M4 Max gets 3,353 from either rule.Why a 64th
All three reasons come from our own measurements:
BM+0x7c= 19,737 andBM+0x80= 6,579 blocks (read live). That is 1/60 of the memory. The fixed 1,118 is 1/59 of 8 GiB. A 64th stays below both.Cleanups:
memacct::total_ram_bytes()replaces a duplicate memory helper, andLayout::initialize()(M5 graph) readsGraphArgs::normal_blocks, asfw::Graph::init()does.J616s rows at this head
Rows 1, 2, 3 and 5 ran on 7.3.0-m4.195 at
a64f33ae2157(results in the comment linked above). All GPU runs go through our GPU queue. 0 GPU recoveries, 0 AVC, 0 failed units and no new kernel warnings in every row.BM+0x7c/BM+0x80of a live NEO heap: 13,416 / 13,412 pages (3,354 slots, 3,353 blocks).gpu_memoryand each client's fdinfodrm-resident-systemshow the tiler growth per client. In the one-VM case, the third queue's growth stops at the arena edge, and its frames keep rendering (slower) without ENOSPC.asahi.client_mem_limit_pct=2(952 MiB per client), one client with a 700 MiB renderbuffer, then N = 30,000 and 45,000. The heap grew once, 1,400 -> 2,744 blocks,refusedwent 0 -> 5, the client ended at 970,400 KiB, and every frame rendered (82-89 ms, 413-421 ms), with no kernel messages. The runtimegpu_mem_limit_pctfile sets the device limit too, which bites first.HEAP_SHRINK), and to its floor after 10 s idle.HW rows wanted on machines we don't have
BM+0x80read back as 4,472 pages (1,118 blocks),drm-resident-systemrising with the growth, and 0 GPU recoveries / AVC / failed units.BM+0x80about 12,000 pages.Not done
Evidence
At head
5cf1361ccc52asahi_g17_tvb_limits(2) andasahi_g17_tvb_share(5) pass.tools/asahi/run-host-tests.py: all 220 g17 runs pass; the same 29 non-g17 runs fail as ata64f33ae2157.b004eb6f131calone and at the head: 0 Rust errors, no warnings in the changed files.At head
a64f33ae2157(maina851ca0edfc9merged)280009109649and on the head: 854 tests, 853 passed, 1 skipped, each.asahi_g17_tvb_limitspasses.tools/asahi/run-host-tests.py: every g17 run passes (220). The 29 failing runs are g15, DCP, M3 uAPI and SEP tests that fail on plain main on this build host too (no rustup 1.93.1 toolchain; a git ref the checkout lacks).001d7834eb78was compile-checked commit by commit with arm64defconfig+asahi.config,LLVM=1,W=1.J616s (M4 Pro, 48 GiB, GPU firmware 25G83), earlier revision #2186
Off-screen GLES: N screen-spanning triangles into a stored 3456x2234 RGBA8 + D24S8 target, waiting for each frame (
glFinish). 0 GPU recoveries. "Before" is a 1,118-block cap and "after" a 3,353-block cap, both on our m4.166 test kernel with #2186, which wrote the same 3,353 on this Mac. m4.166 also carries #1902 and #1986, which only affect pairs that never go idle.