Filesystem Heap
Filesystem Heap
CONFIG_FS_HEAPSIZE reserves an independent heap for filesystem
allocations. Its default value of zero uses the kernel heap directly.
The independent heap has a fixed capacity and does not fall back to the
kernel heap when an allocation fails.
CONFIG_FS_HEAPLARGE_ONLY selects which allocations use that capacity.
It defaults to disabled, preserving the common heap for all fs_heap_*
allocations. When enabled, the independent heap holds:
- TMPFS file data and directory entry arrays, including mmap growth.
- Pseudo-file contents.
- SHM data buffers in flat builds.
Other fs_heap_* allocations use the kernel heap, including file objects,
file descriptor tables, filesystem object metadata and names. Static file
object pools remain static; their dynamic expansion uses the kernel heap.
This selects by purpose, regardless of the requested allocation size.
Separating these allocations can preserve independent heap capacity for file data. It also lets metadata allocations proceed when that heap is full, provided the kernel heap has room. A new file can still fail if it needs a TMPFS directory array expansion. Size both heaps for the intended workload; this option neither reduces the reserved FS heap nor guarantees lower total RAM use.
Protected builds continue to allocate SHM buffers from the user heap.
Kernel builds continue to allocate SHM pages from the page allocator.
Their SHM metadata follows the fs_heap_* policy above. This option
changes allocator selection, not mapping permissions or address-space
visibility.
Internal Allocation Interfaces
fs_large_* in fs/fs_heap.h always selects the independent heap when
one is configured, or the kernel heap otherwise. fs_heap_* selects the
ordinary allocation policy described above. Allocation, reallocation,
size queries and freeing must use the same family for each buffer.
The membership checks follow their respective allocator families.
fs_heap_mallinfo_task() continues to report the independent heap when
configured, even when ordinary allocations use the kernel heap.