Contributor
Bojan Novković

Physical memory anti-fragmentation mechanisms


Mentors
Mark Johnston
Organization
The FreeBSD Project
Technologies
c
Topics
Defragmentation, Virtual memory, Superpages
The use of superpages in modern hardware and operating system yielded important performance benefits. Unfortunately, allocating superpages can often fail due to a high rate of external fragmentation in physical memory. Thus external physical memory fragmentation in modern operating systems has once again become a serious issue. 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. When invoked, this mechanism would identify sparsely populated and fragmented physical memory regions and rearrange the pages to eliminate any "holes" in the region. Aside from explicit invocation, a background daemon would monitor the relevant fragmentation metric and trigger the memory compaction mechanism should the value drop below a certain threshold. The last goal will introduce a passive anti-fragmentation mechanism for the demand paging mechanism. The key idea is to enhance the page placement code to use contiguous spans of pages instead of allocating random pages.