P3L2 Flashcards
Principles of Memory Management Systems
- ) Use intelligently sized containers
- ) Nota ll memory is needed at once
- ) Optimized for performance
Memory Management Goals
Allocate and Arbitrate
Allocate
map pages from virt mem into page frames from physical
Arbitrate
page tables
MMU
- translate virtual to physical accesses
- report faults
What causes faults
illegal access
permission
not present in mm
HW Support Registers
Pointers to page table
base and limit size, number of segments
Cache - TLB
Translation Lookaside Buffer
VPN
Virtual Page Number
PFN
Page Frame Number
Page tables are per
process
Page Table Flags
- Present (valid/invalid)
- Dirty
- Accessed
- R/W (permission bit)
- U/S (permission bit - user / supervisor)
Page Fault when
H/W determines a physical mem access cannot be performed
Page Fault Handler
determines action based on error code and faulting addr
Hierarchical Page Tables
Outer page table == Page Table Directory
Internal page table == only for valid virtual memory regions
Multi-level PT Tradeoffs
Smaller internal page tables / directories
but more memory accesses required for translation
Page Table Cache
Translation Lookaside Buffer
MMU Level address translation cache
Why small number of cached entry = high TLB hit rate
temporal and spacial locality
Example of inverted page tables
Hashing Page Tables
Memory allocator
determines VA to PA mapping
Memory Allocation Challenges
permit coalescing / aggregation of free areas
avoid or limit extend of fragmentation
Allocators in Linux
Buddy
Slab
Buddy
Start with 2^x, split into powers of two until can satisfy request
-Aggregation works well and fast
Slab allocator
-caches for common object type/sizes on top of contiguous memory
Demand paging
virtual memory is much greater than physical memory
virtual memory page is not always in physical memory (swapping)
Freeing up Physical Memory
when memory usage is above threshold (high watermark)
when CPU usage is below threshold (low watermark)
LRU Policy
Least Recently Used
What pages to swap out
- Least recently used (access-bit to track)
- Pages that don’t need to be written out (dirty bit)
- Avoid non-swappable pages
COW
Copy-on-write
Checkpointing
- write-protect and copy everything once
2. copy diffs of “dirtied” pages for incremental checkpoints
Debugging
Rewind-Replay
1. Gradually go back to older checkpoints until problem found
MIgration
Repeated checkpoints in a fast-loop until pause and copy becomes acceptable