fix(syscall): MAP_NORESERVE on aarch64 Linux via raw syscall#11
Merged
Conversation
The existing raw-syscall path with MAP_NORESERVE was gated on target_arch="x86_64" only. aarch64 Linux fell through to the libc::mmap fallback that omits MAP_NORESERVE — fine for macOS (which has no equivalent flag) but broken on Linux: with vm.overcommit_memory=0 (default on Asahi Fedora and many other distros), the kernel rejects the multi-tens-of-GB arena reservation and ensure_region aborts the process before any work runs. Reproduced on Apple Silicon M2 / Asahi Linux Fedora 42 (16 KiB pages, 16 GiB RAM, kernel 6.14.2). Patched build runs cleanly and is +3.4% faster than standard-alloc on the leanMultisig 1550-sig XMSS aggregation workload. Adds a parallel imp module gated on (target_os=linux, target_arch=aarch64) that mirrors the x86_64 raw-syscall path with the correct aarch64 syscall numbers (SYS_mmap=222, SYS_madvise=233) and ABI (svc 0, x8=nr, x0..x5=args). The macOS path is unchanged.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The raw-syscall path that issues
MAP_NORESERVEwas gated ontarget_arch = \"x86_64\"only. aarch64 Linux fell through to thelibc::mmapfallback that omits the flag — fine for macOS (no equivalent flag exists there) but broken on Linux: withvm.overcommit_memory = 0(default on Asahi Fedora and several other distros), the kernel's heuristic check rejects the multi-tens-of-GB arena reservation,mmapreturns null, andensure_regionaborts the process before any allocation work happens.This adds a parallel
impmodule gated on(target_os = \"linux\", target_arch = \"aarch64\")that mirrors the x86_64 raw-syscall path with the correct aarch64 ABI (svc 0,x8 = nr,x0..x5 = args) and syscall numbers (SYS_mmap = 222,SYS_madvise = 233). macOS path is unchanged.Repro / verification
cargo run --release -- xmss --n-signatures 100 --log-inv-rate 1aborts with SIGABRT immediately afterwarming up.... Stack trace ends inzk_alloc::arena_alloc_cold→Once::call_once→std::process::abort(fromensure_regionat lib.rs:166).Test plan
cargo build --releasesucceeds on aarch64 Linuxxmss --n-signatures 1550runs end-to-end with patched zk-alloclibc::mmapfallback (no flag-set change)🤖 Generated with Claude Code