This new heap is a caching heap that allows allocating single memory pages, while avoiding complete exhaustion of physical memory and minimizing memory fragmentation. It is used by both the pagecache code (instead of a pagecache-specific caching heap) and the mmap code (instead of the page_backed heap), which now avoid accessing directly the physical heap. The page heap is drained by the MM service when the kernel is running out of memory.
This change fixes a memory fragmentation issue that occurs when the user process makes heavy use of map() and unmap() system calls and may cause failure to allocate 2MB chunks of memory (https://github.com/nanovms/ops/issues/1570#issuecomment-1895947857).
The first 2 commits refactor the mmap code to remove code duplication, the third commit fixes a bug in the mmap code.
This new heap is a caching heap that allows allocating single memory pages, while avoiding complete exhaustion of physical memory and minimizing memory fragmentation. It is used by both the pagecache code (instead of a pagecache-specific caching heap) and the mmap code (instead of the page_backed heap), which now avoid accessing directly the physical heap. The page heap is drained by the MM service when the kernel is running out of memory. This change fixes a memory fragmentation issue that occurs when the user process makes heavy use of map() and unmap() system calls and may cause failure to allocate 2MB chunks of memory (https://github.com/nanovms/ops/issues/1570#issuecomment-1895947857).
The first 2 commits refactor the mmap code to remove code duplication, the third commit fixes a bug in the mmap code.