Physical Memory Anti-Fragmentation Mechanisms
Student: Bojan Novković (bnovkov@freebsd.org)
- Mentor: Mark Johnston (markj@)
Project description
External physical memory fragmentation in modern operating systems resurfaced as a serious issue once again due to the widespread use of superpages. This project aims to design and implement several anti-fragmentation mechanisms for the FreeBSD kernel. At the time of writing, the FreeBSD kernel has no memory compaction mechanisms or any way of quantifying physical memory fragmentation. The first major goal is implementing several fragmentation metrics for the page allocation code. The second major goal is designing and implementing a runtime physical memory compaction mechanism. The last goal is to introduce various passive anti-fragmentation mechanisms throughout the virtual memory subsystem. The main idea is to enhance the page placement code to use contiguous spans of pages instead of allocating random 0-order pages.
Deliverables
- A patch implementing and exposing relevant physical memory fragmentation metrics,
- A patch implementing a runtime physical memory defragmentation mechanism with at least one way of triggering it, actively or passively,
- A patch implementing contiguity-awareness tweaks for page placement.
The Code
- Proactive compaction
- Fragmentation metrics
- Physical memory compaction
- Contiguity-awareness tweaks in the vm subsystem
- vm_map_wire improvements
- Batched page allocation routines
- Enabling creation of wired userspace superpages
Differential (committed in rGaa3bcaad5107)
Benchmarking results
This section will be updated with new results as I finish testing the patches listed above.
- The vm_map_wire patch was tested by booting bhyve virtual machines of varying guest RAM sizes. The patch results in a 10-12x page wiring speedup per 1GB of guest memory, leading to significantly faster VM boot times.