wire / wire-format / virtual-memory-management
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.
aka: Virtual memory management (Linux)
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.
| field | size | meaning |
|---|---|---|
| mm_struct | struct | Memory descriptor: list of VMAs, page table root (pgd), mmap base, brk (heap end), start/end of code/data/stack, etc. |
| VMA (vm_area_struct) | struct | Virtual memory area: start/end addresses, flags (read/write/exec/shared), file backing (if mmap'd), operations (fault, page_mkwrite, etc.). |
| Page fault | handler | Minor fault: page in page cache (fast). Major fault: read from disk (slow). Invalid access: SIGSEGV. |
| Anonymous pages | memory | Heap, stack, anonymous mmap. Backed by swap (if configured) or zero page. |
| File-backed pages | memory | mmap'd files. Backed by page cache (file content in memory). Dirty pages written back to file. |
| Swap | disk | Anonymous pages can be swapped to disk (swap partition/file). LRU-based eviction. |
| OOM killer | mechanism | When memory is exhausted, kills the process with highest 'badness' score (memory usage, runtime, niceness). |
| mmap | syscall | Map files or anonymous memory into address space. Flags: MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS, MAP_FIXED. |
| mprotect | syscall | Change protection (read/write/exec) of a memory region. |
| brk/sbrk | syscall | Extend/shrink the heap (program break). |
example:
00 00 00 00
Virtual memory (placeholder)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/virtual-memory-management
or /wire-format/virtual-memory-management.json