Skip to content

borealis: report all of RAM as the device-local heap - #1420

Merged
DjDeveloperr merged 3 commits into
aurora-silicon:aurora-wipfrom
jgoyvaerts:pr/borealis-heap-all-ram
Dec 2, 2026
Merged

DjDeveloperr merged 3 commits into
aurora-silicon:aurora-wipfrom
jgoyvaerts:pr/borealis-heap-all-ram

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 30, 2026 •

Copy link
Copy Markdown

What: Without a kernel admission limit, Borealis sized its one device-local heap at half of RAM "to avoid swapping". VkMemoryHeap::size is the memory a device can address, though, not a promise of what it can get. Borealis already reports the live amount in VK_EXT_memory_budget, where heapBudget follows 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 and heap_memory_percent still 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) and api.info (10487) 0 differ vs base 89ddabb; meson --suite asahi 226/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_sizing and 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 from total_ram / 2 to all of RAM (1 MiB aligned). Kernel-reported limits (memory_limit, client_memory_limit) and an explicit heap_memory_percent are applied as before.
  • 55626e3 (DjDeveloperr): hk_memory_heap::allocation_limit separates 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.
  • e0eba90 (DjDeveloperr): 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.c covers 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 e0eba90c7 via VK_DRIVER_FILES; base = stored dq-fast baseline of aurora-wip 89ddabbf7 (kernel m4.212). 0 GPU recoveries.

aurora-wip (31b9bb7) head e0eba90
heap 0 size (vulkaninfo) 24977080320 (23.26 GiB) 49955209216 (46.52 GiB)
heap 0 budget, idle 16830693376 (15.67 GiB) 24977080320 (23.26 GiB)
list base 89ddabb head
memory.* (4745) 3082 P / 1663 NS 3082 P / 1663 NS, 0 differ
api.info (10487) 6895 P / 3592 NS 6895 P / 3592 NS, 0 differ

meson --suite asahi at 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.

jgoyvaerts and others added 3 commits November 30, 2026 13:07
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>
@DjDeveloperr

Copy link
Copy Markdown

PASS on M4 mini J773g (G16G) at e0eba90c75af: heap = all RAM, admission and budget held at RAM/2, and no differences from the merge base 89ddabbf72c on three kernels, alone and combined with #1416

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:

Kernel features bit 48 / 49 device / client limit
saved stock 7.3.0-ARCH-m4mainefed1ae3 0x000001026001fc06 0 / 0 0 / 0
main dbfbced70b31 0x000041026001fc07 0 / 0 0 / 0
linux#3685 ba10491f9e0b 0x000041026001fc07 0 / 0 0 / 0

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 (2f4c639e42b), on the same boot.

Unit tests (CPU only): hk_uma_heap_sizing_test and hk_memory_oom_test pass on base and head on all three kernels, and on the combination on main and #3685.

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)

base head (all three kernels) and combination (main, #3685)
Heap size 12,396,265,472 (RAM/2) 24,793,579,520 (all RAM, rounded down to MiB)
Budget, idle about 9.7–10.9 GB, from available memory 12,396,265,472 (the RAM/2 allocation limit)
Budget while holding 1.375 GiB, and after release positive, at most the heap size 12,396,265,472, positive, at most the heap size
Single request of RAM/2 + 1 MiB not run: larger than base's heap (invalid usage) VK_ERROR_OUT_OF_DEVICE_MEMORY
maxMemoryAllocationSize 128 GiB 128 GiB (unchanged)
  • Every sample had a positive budget no larger than the heap, and unused heap entries were zero.
  • Bounded pressure (disposable cgroup, MemoryMax=1536M, no swap) behaved the same on every arm and kernel:
    • 11 × 128 MiB held, then VK_ERROR_OUT_OF_DEVICE_MEMORY, with no cgroup OOM kill;
    • the allocation after releasing half succeeds;
    • a second client stays healthy.

Vulkan CTS

Set Kernel base head combination
api.smoke, memory.allocation, info.device_memory_budget, alloc_callback_fail and the core api.info property groups, 308 cases saved stock, main, #3685 297 P, 7 NS, 4 QualityWarning same same (main, #3685)
dEQP-VK.api.info.*, 10,487 cases saved stock 6894 P, 3593 NS same not run
  • 0 per-case differences in every comparison.
  • No GPU faults, recoveries or new kernel errors in any window.
  • dEQP processes grow memory quickly on both arms. Head and the combination peak higher in the memory CTS (about 3.4 GB per 25-case process against 1.9 GB on base), because those tests size their allocations from the larger reported heap. Nothing was killed, and this is not a finding against the PR.

Not covered on J773g

  • No kernel available on this Mac reports a nonzero device or client limit (main and #3685 both report 0/0 on G16G), so the capped property row cannot be shown here.
  • A kernel that omits the fields entirely was not available. The shorter legacy response was checked, and the unit test covers absent fields.
  • The cumulative admission limit was not driven to exhaustion on hardware, to keep the Mac's memory safe. The single-request check and the unit tests cover it.

@DjDeveloperr DjDeveloperr 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.

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.

@jgoyvaerts
jgoyvaerts marked this pull request as ready for review December 2, 2026 01:33
@jgoyvaerts
jgoyvaerts requested review from a team as code owners December 2, 2026 01:33
@DjDeveloperr

Copy link
Copy Markdown

The J616s and J773g runs cover the 0/0 case at e0eba90c75af. The J616s capped run on m4.212 used 0e5c983ae397. Two later commits changed the single-allocation and cumulative admission checks and the reported heap budget, so that run leaves those behaviors untested with a real nonzero limit.

If a Mac is already running a kernel that reports a limit, could you compare 89ddabbf72c2 and e0eba90c75af on that boot with the two ICDs? The kernel-reported device/client limits and the heap size, usage and budget at idle and while holding a small allocation would complete the comparison. The capped heap should match the baseline and the budget should stay positive and within the cap. The existing uncapped runs cover the other arm.

@DjDeveloperr

Copy link
Copy Markdown

Merge train status at e0eba90c75af. The merge result on aurora-wip bf62a48b5585 (all five PR files unchanged) passed the Arm64 Asahi build and tests.

Still owed:

  • an approval from a maintainer who didn't write 55626e30 or e0eba90c (DjDeveloperr's approval covers those commits, so it doesn't count);
  • a second-generation row at this head (J700: memory.* and api.info A/B, plus the heap size and budget readout).

No lab kernel reports a memory limit, so the capped path stays covered by hk_uma_heap_sizing and the earlier m4.212 run.

@DjDeveloperr

Copy link
Copy Markdown

J700 (G17P) row: mesa#1420: 0

Kit A payload fc52f53a4ef567c0…, target evidence d99abf64ae6cec04… (Mini: work/j700-mesa-batch-a-20261202/evidence/receipt-lkuexOsN). Run 08:26–08:41 UTC, the Neo lease was held for the whole run, and the stock fingerprint and both Apple partners were identical before and after.

@DjDeveloperr

DjDeveloperr commented Dec 2, 2026 •

Copy link
Copy Markdown

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. workflow_dispatch returns HTTP 422 "Actions has been disabled for this repository". Under the 12-02 hosted-CI override, I ran the asahi.yml build-test job myself on the merge result.

Tree: head e0eba90c75af merged onto aurora-wip b62056a4ec41 with git merge-tree --write-tree (clean) gives tree e3f4a919b884df0982d0802c6bd102b8595affee.

Where How Result
arm64, the CI runner type Tree published unchanged as ci/head-1420-6c77093d on DjDeveloperr/mesa (tree SHA checked), running the same asahi workflow on ubuntu-24.04-arm with fedora:44 and clang 22.1.8 run 46844886988: 384 OK, 0 failed, 1 skipped
x86_64 (pc) Image built from .github/ci/Containerfile.mesa (fedora:44 @sha256:297110ca…), then bash .github/ci/mesa-arm64.sh unchanged 384 OK, 0 failed, 1 skipped on the rerun (see below)
x86_64 (pc), aarch64 float and char rules The same script with CFLAGS/CXXFLAGS="-march=x86-64-v3 -funsigned-char" 384 OK, 0 failed, 1 skipped on the rerun (the first run had the same timeout)
Agent policy aurora-agent-policy on the same fork ref pass

The pc timeout was borealis-sync-runner hitting meson's 30 s limit. Both pc runs of this tree ran at the same time as two other full builds and suites, with pc load around 100. The test is unchanged by this PR and normally takes 2–3 s. On its own, it passed in 1.46 s here and 1.47 s at the tip. Rerunning the whole --suite asahi --suite poly step on the same builds gave 384/0/1 both times, with the test passing in 3.96 s and 8.33 s (pc load was still about 90). On arm64 it passed in 1.43 s. The script runs meson setup build -Dgallium-drivers=asahi -Dvulkan-drivers=asahi -Dplatforms=wayland,x11 -Dbuild-tests=true -Dtools=drm-shim, then meson compile -C build and meson test -C build --suite asahi --suite poly --num-processes $(nproc) --print-errorlogs.

aurora-wip has since taken #1508 and #1476. Both are compiler-only and don't touch this PR's five files.

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 55626e30 or e0eba90c. DjDeveloperr wrote both commits, so that approval doesn't count for them.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: MERGE

Blockers: none.

Checked:

  • src/asahi/vulkan/hk_physical_device.h / hk_physical_device.c: separates reported hk_memory_heap::size (all of system RAM rounded down to 1 MiB on the uncapped default heuristic path) from hk_memory_heap::allocation_limit (kept at ROUND_DOWN_TO(total_ram_B / 2, 1 MiB) on that path, and equal to size whenever capped by kernel limits, explicit heap_memory_percent, or HK_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 enforce heap->allocation_limit cleanly without overflow.
  • hk_GetPhysicalDeviceMemoryProperties2: if (budget == 0) budget = allocated; p->heapBudget[i] = MAX2(1, MIN2(budget, heap->allocation_limit)); guarantees a positive budget bounded by allocation_limit <= size even when os_get_available_system_memory fails 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-head e0eba90c75af hardware 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).

@DjDeveloperr
DjDeveloperr merged commit 056b5ef into aurora-silicon:aurora-wip Dec 2, 2026
1 check passed
@DjDeveloperr

Copy link
Copy Markdown

Merged as 056b5efd. Its tree f6d009ce is exactly the tree tested below.

Hosted Actions is still off on this repo, so I ran the asahi.yml build-test job locally on pc, both on the tip and on the merge result.

  • Tip: aurora-wip fd2d9354, tree e43cc31c.
  • Merge: head e0eba90c on fd2d9354 with git merge-tree --write-tree (clean), tree f6d009ce. GitHub's merge commit has the same tree.
  • Image: .github/ci/Containerfile.mesa (fedora:44, clang 22.1.8, amd64). The warm build dirs were reused, and ninja rebuilt everything that includes hk_physical_device.h.
Step Command Tip fd2d9354 Merge f6d009ce
ci bash .github/ci/mesa-arm64.sh (meson setup --reconfigure on the warm dir) 387 OK, 0 failed, 1 skipped 387 OK, 0 failed, 1 skipped
aarch64 rules the same script with CFLAGS/CXXFLAGS="-march=x86-64-v3 -funsigned-char" 387 / 0 / 1 387 / 0 / 1
suites meson test -C build --suite asahi --suite vulkan --suite poly 445 / 0 / 1 445 / 0 / 1
PR tests meson test hk_memory_oom hk_uma_heap_sizing -v on both build dirs 2 / 0 on each 2 / 0 on each

The one skip is hk-g17p-cross-queue, which exits 77 without a GPU in both runs.

Since 89ddabbf, aurora-wip has 7 commits that touch these files, all in hk_physical_device.c: float8, the DRM primary node, the queue-family transfer property, and chip-gate cleanups. None of them changes heap size, memory types, the allocation limit or the budget. hk_device_memory.c and hk_physical_device.h haven't changed since the base. The other "heap" changes in that range are to the geometry heap, not the Vulkan memory heap. The J616s, J773g and J700 rows at e0eba90c still describe this code.

Receipt: .build-host/m1420-lci-20261202/ on pc (run.sh, results.tsv, logs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants