Repository navigation
borealis: report all of RAM as the device-local heap - #1420
Conversation
Without a kernel admission limit, Borealis sized its one UMA heap at half of RAM "to avoid swapping". But VkMemoryHeap::size is the memory a device can address, not a promise of what it can get, and Borealis already reports the live amount in VK_EXT_memory_budget: heapBudget follows the system's free memory. GPU memory is ordinary system memory here. The kernel refuses what the system or the client's memory cgroup cannot back (mayfail allocation and its own reclaim), so a fixed half only hid memory that applications could use. Report all of RAM when the kernel sets no limit. A kernel that reports an admission limit still caps the heap at it, and an explicit heap_memory_percent still applies. The budget scales with the heap's share of RAM, so it becomes 90% of free memory plus what the process already holds. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Keep the all-RAM heap property on unlimited and shorter parameter responses while enforcing the legacy default for individual and cumulative allocations and the budget. Check explicit limits, 0/0, absent fields and the allocation fast-fail path. Signed-off-by: DjDeveloperr <hey@djdev.me>
Keep the current allocation charge as the estimate when the available-memory query fails or rounds to zero. An empty active heap reports one byte. Cover both cases and the unused budget slots in the UMA property test. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
PASS on M4 mini J773g (G16G) at The same rows ran on three kernels. On G16G each one reports both memory-limit fields as 0, so every row here is the no-cap (0/0) configuration:
Both limit fields were returned by the kernel, not left unset. With a 600-byte request, the shorter legacy response leaves both limit fields untouched on every kernel. All arms used the same kernel, case lists and options within each boot, each through its own ICD JSON and library path. Every process mapped the expected library, and each library carried the expected commit. The combination is this head merged with #1416 ( Unit tests (CPU only): Properties and budget on the GPU (visible RAM about 24,794 MB, within 1 MiB on all three kernels; the values below are identical on all three)
Vulkan CTS
Not covered on J773g
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Code approved at e0eba90c75af. The UMA property reports all aligned RAM on 0/0 or absent limits while the default allocation path retains its former ceiling. The single-request, cumulative and final BO checks enforce it. An active heap also keeps a positive budget when the available-memory query fails or rounds below 1 MiB.
The UMA sizing and memory OOM suites passed. The remaining hardware comparison pairs a stock capped boot with a native 0/0 boot and records heap size, usage and budget.
|
The J616s and J773g runs cover the 0/0 case at If a Mac is already running a kernel that reports a limit, could you compare |
|
Merge train status at Still owed:
No lab kernel reports a memory limit, so the capped path stays covered by |
|
J700 (G17P) row: mesa#1420: 0 Kit A payload |
|
Local CI at the merge result: pass. Not merging yet: one approval is still owed. Hosted Actions on this repo hasn't started a run since 00:15 UTC today. Tree: head
The pc timeout was
Rows are complete: J616s and J773g (G16) at this head, plus the J700 (G17P) second-generation row (comment above). The remaining gate is an approval from a maintainer who didn't write |
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE
Blockers: none.
Checked:
src/asahi/vulkan/hk_physical_device.h/hk_physical_device.c: separates reportedhk_memory_heap::size(all of system RAM rounded down to 1 MiB on the uncapped default heuristic path) fromhk_memory_heap::allocation_limit(kept atROUND_DOWN_TO(total_ram_B / 2, 1 MiB)on that path, and equal tosizewhenever capped by kernel limits, explicitheap_memory_percent, orHK_SYSMEM).src/asahi/vulkan/hk_device_memory.c: single-allocation, pre-BO cumulative (used > heap->allocation_limit || aligned_size > heap->allocation_limit - used), and post-BO atomic checks all enforceheap->allocation_limitcleanly without overflow.hk_GetPhysicalDeviceMemoryProperties2:if (budget == 0) budget = allocated; p->heapBudget[i] = MAX2(1, MIN2(budget, heap->allocation_limit));guarantees a positive budget bounded byallocation_limit <= sizeeven whenos_get_available_system_memoryfails or returns less than 1 MiB.- Unit tests (
test-hk-memory-oom.c,test-hk-uma-heap-sizing.c) cover uncapped heuristic sizing, kernel-capped sizing, explicit driconf overrides,HK_SYSMEM, OOM admission, and active-heap budget edge cases. - Clean merge state (
MERGEABLE/CLEAN), exact-heade0eba90c75afhardware PASS rows across J616s, J773g, and J700, plus full fork ARM64 and local x86_64 CI passes at the merge result while hosted Actions is disabled.
Evidence
- Audited full diff at
e0eba90c75af(0e5c983ae397,55626e30ead9,e0eba90c75af). - Verified exact-head hardware receipts on J616s, J773g (with and without cgroup pressure + 10,487 CTS), and J700 (
#issuecomment-7339674184), and merge-result ARM64/x86_64 CI receipts (#issuecomment-7340601369: 384 OK / 0 fail / 1 skipped).
|
Merged as Hosted Actions is still off on this repo, so I ran the
The one skip is Since Receipt: |
What: Without a kernel admission limit, Borealis sized its one device-local heap at half of RAM "to avoid swapping".
VkMemoryHeap::sizeis the memory a device can address, though, not a promise of what it can get. Borealis already reports the live amount inVK_EXT_memory_budget, whereheapBudgetfollows free memory, and the kernel refuses what the system or the client's memory cgroup cannot back. A fixed half only hid memory that applications could use. This reports all of RAM when the kernel sets no limit; a kernel limit andheap_memory_percentstill cap it. DjDeveloperr's 55626e3 keeps the old half-of-RAM ceiling for allocations and the budget on that uncapped path, and e0eba90 keeps every active heap's budget positive.Tested: J616s M4 Pro (G17P), kernel 7.3.0-m4.219 (reports no limit), at head e0eba90: heap 46.52 GiB (all of RAM, base 23.26 GiB), budget 23.26 GiB (the half-of-RAM allocation ceiling); dq-fast
memory.*(4745) andapi.info(10487) 0 differ vs base 89ddabb; meson--suite asahi226/226; 0 GPU recoveries, 0 new kernel error lines. J773g M4 mini (G16G) at e0eba90 on three kernels, alone and merged with #1416: PASS, 0 differences (DjDeveloperr's comment).Risk: two-way door · all Macs Borealis runs on; the heap size changes only where the kernel reports no memory limit (GET_PARAMS limits 0/0), and allocations and the budget stay at half of RAM there
Not yet: the capped path at the head on hardware: no current kernel on our Macs reports a limit. It is covered by
hk_uma_heap_sizingand by the earlier m4.212 row (50% per-client limit, heap unchanged at 23.26 GiB, at 0e5c983).Details
hk_resolve_uma_sysmem_heap(): the no-limit fallback goes fromtotal_ram / 2to all of RAM (1 MiB aligned). Kernel-reported limits (memory_limit,client_memory_limit) and an explicitheap_memory_percentare applied as before.hk_memory_heap::allocation_limitseparates the heap property from admission. With no kernel limit and the default heuristic it stays at half of RAM, so allocations are admitted as before; otherwise it equals the heap.heapBudget = max(1, min(budget, allocation_limit)), and a failed or sub-MiB available-memory estimate reports what the application holds, so every heap keeps a positive budget.test-hk-uma-heap-sizing.c: the legacy/virtio and 0/0 cases expect all of RAM, plus the allocation-limit cases;test-hk-memory-oom.ccovers admission at the ceiling.Evidence
Perf gpu-run 2026-12-02 01:29:18-01:32:05 UTC, J616s M4 Pro on AC, kernel 7.3.0-m4.219, Borealis-only release build of
e0eba90c7viaVK_DRIVER_FILES; base = stored dq-fast baseline of aurora-wip89ddabbf7(kernel m4.212). 0 GPU recoveries.meson
--suite asahiat e0eba90: 226 Ok, 0 Fail. Failed units: speakersafetyd failed at boot (01:20:59 UTC, before the run); nothing new.Earlier row at 0e5c983 (kernel m4.212, which reports a 50% per-client limit): heap 23.26 GiB on base and head, memory.* and api.info 0 differ.