wire / wire-format / virtual-memory-management

Virtual memory management (Linux)

Linux virtual memory: each process has a virtual address space (mm_struct) containing VMAs (Virtual Memory Areas). VMAs describe contiguous regions of virtual memory (code, data, heap, stack, mmap'd files). Page tables map virtual pages to physical frames. Page faults trigger: minor (page in page cache) or major (disk I/O). Swap: anonymous pages can be swapped to disk. OOM killer: kills processes when memory is exhausted.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: Virtual memory management (Linux)

wire format

spec: Linux kernel (mm)

Linux virtual memory: each process has a virtual address space (mm_struct) containing VMAs (Virtual Memory Areas). VMAs describe contiguous regions of virtual memory (code, data, heap, stack, mmap'd files). Page tables map virtual pages to physical frames. Page faults trigger: minor (page in page cache) or major (disk I/O). Swap: anonymous pages can be swapped to disk. OOM killer: kills processes when memory is exhausted.

fieldsizemeaning
mm_structstructMemory descriptor: list of VMAs, page table root (pgd), mmap base, brk (heap end), start/end of code/data/stack, etc.
VMA (vm_area_struct)structVirtual memory area: start/end addresses, flags (read/write/exec/shared), file backing (if mmap'd), operations (fault, page_mkwrite, etc.).
Page faulthandlerMinor fault: page in page cache (fast). Major fault: read from disk (slow). Invalid access: SIGSEGV.
Anonymous pagesmemoryHeap, stack, anonymous mmap. Backed by swap (if configured) or zero page.
File-backed pagesmemorymmap'd files. Backed by page cache (file content in memory). Dirty pages written back to file.
SwapdiskAnonymous pages can be swapped to disk (swap partition/file). LRU-based eviction.
OOM killermechanismWhen memory is exhausted, kills the process with highest 'badness' score (memory usage, runtime, niceness).
mmapsyscallMap files or anonymous memory into address space. Flags: MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS, MAP_FIXED.
mprotectsyscallChange protection (read/write/exec) of a memory region.
brk/sbrksyscallExtend/shrink the heap (program break).

example:

00 00 00 00

Virtual memory (placeholder)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/virtual-memory-management or /wire-format/virtual-memory-management.json