Skip to content

Conversation

francescolavra
Copy link
Member

Since commit 1462526 "Physical heap: switch from id heap to buddy memory allocator", the physical memory heap does not support allocation requests larger than 2 MB; this is done in order to keep the heap implementation efficient in terms of both runtime performance and memory overhead. However, there are rare cases where the kernel needs memory allocations that exceed this limit: for example, when booting images with large filesystems, the tuple staging buffer for the TFS log can grow in size to several MB, and if memory allocation fails, the kernel panics with "assertion buffer_write(tl->tuple_staging, buffer_ref(b, 0), length) failed".
In order to allow the kernel to allocate large chunks of memory while keeping the physical memory allocator efficient, add a new kernel heap that supports arbitrarily large allocations of contiguous virtual memory which is mapped to physical memory that can be non-contiguous. To allow booting images with large filesystems, make the tuple staging buffer for the TFS log use this new heap.

The second commit contains an unrelated change to fix kernel compilation failure with recent clang versions on MAC build hosts.

Closes #2105.

Francesco Lavra added 2 commits September 6, 2025 17:00
Since commit 1462526 "Physical heap: switch from id heap to
buddy memory allocator", the physical memory heap does not support
allocation requests larger than 2 MB; this is done in order to keep
the heap implementation efficient in terms of both runtime
performance and memory overhead. However, there are rare cases
where the kernel needs memory allocations that exceed this limit:
for example, when booting images with large filesystems, the tuple
staging buffer for the TFS log can grow in size to several MB, and
if memory allocation fails, the kernel panics with "assertion
buffer_write(tl->tuple_staging, buffer_ref(b, 0), length) failed".
In order to allow the kernel to allocate large chunks of memory
while keeping the physical memory allocator efficient, add a new
kernel heap that supports arbitrarily large allocations of
contiguous virtual memory which is mapped to physical memory that
can be non-contiguous. To allow booting images with large
filesystems, make the tuple staging buffer for the TFS log use this
new heap.

Closes #2105.
This modifier, when applied to the `-march=armv8-a` compiler flag,
disables floating-point support, and causes kernel compilation
with recent clang versions to fail on MAC build hosts, with error
messages such as below:
```
src/aarch64/crt0.S:291:9: error: instruction requires: fp-armv8
        ldp q30, q31, [x0, #(30 * 16)]
        ^
src/aarch64/crt0.S:294:13: error: expected writable system register or pstate
        msr fpsr, x1
            ^
src/aarch64/crt0.S:297:17: error: expected readable system register
        mrs x2, fpcr
                ^
```
To fix the above errors, remove the `+nofp` modifier from the ARM
compiler flags.
@francescolavra francescolavra merged commit 5779b31 into master Sep 7, 2025
7 checks passed
@francescolavra francescolavra deleted the fix/vmem_heap branch September 7, 2025 13:05
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.

Run pytorch inference on nanoVM unikernel
2 participants