Virtual memory¶
FreeBSD’s virtual memory system connects a process’s address space to the
objects that supply its data and the physical pages that currently hold it.
The machine-independent implementation lives primarily in sys/vm;
architecture-specific pmap implementations manage hardware translations.
An address-space mapping, a VM object, and a resident page have different lifetimes. Understanding those lifetimes is the starting point for following faults, copy-on-write, file mappings, and memory pressure.
Finding the implementation¶
Source |
Responsibility |
|---|---|
|
Address ranges, protections, mapping changes, and lookup. |
|
Backing objects, resident-page indexing, and object lifetimes. |
|
Physical-page metadata, allocation, busy state, and wiring. |
|
Resolving a virtual address to a page and installing a translation. |
|
Dispatch to the object type’s backing-store operations. |
|
File-backed and swap-backed object behavior. |
|
Page aging, reclamation, and laundry processing. |
|
Physical allocation, NUMA policy, and page reservations. |
|
The kernel’s Universal Memory Allocator for object-sized allocations. |
All paths in this table are relative to sys/vm. sys/vm/pmap.h declares
the common translation interface; its implementations are in the architecture
directories under sys.
Connections to other topics¶
File-backed objects connect VM to Virtual file system through the vnode pager. Waiting for a busy page or memory allocation can block a thread, connecting VM to Scheduling. UMA allocates many kernel structures, but its zones and caches are a separate layer from user address-space mappings.