Kernel heaps: add vmem heap #2108
Merged
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.
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.