Optimistic Page Migration in Linux
- Typ der Arbeit: Bachelorarbeit
- Status der Arbeit: reserviert
- Projekte: ParPerOS
- Betreuer: Daniel Lohmann, Lars Wrenger

This bachelor's thesis explores an optimization to page migration in the Linux kernel, aimed at reducing performance stalls during memory compaction. Page migration is a technique used by the operating system to move physical memory pages to different locations, typically to defragment memory and enable larger contiguous allocations (e.g., for 2 MiB huge pages). This is crucial for performance in systems with heavy memory pressure.
Terminology: Virtual memory paging divides a process's address space into fixed-size pages (usually 4 KiB or 2 MiB). The OS maps these virtual pages to physical frames using page tables. The Translation Lookaside Buffer (TLB) is a CPU cache that speeds up address translations. A page fault occurs when a process accesses a page not currently mapped, triggering the OS to handle it (e.g., load from disk or remap).
In Linux today, migrating a page involves:
- Isolate the page from the free list (to prevent other subsystems from changing it).
- Unmap the virtual address and invalidate TLB entries across cores (expensive due to inter-processor interrupts).
- Map the page to its new physical location (without TLB invalidation).
The problem is that any access to the page during migration causes a stall—the process page faults, waits for migration to complete, then resumes. This degrades performance, especially for active workloads.
In this thesis, we want to investigate a new optimistic migration strategy, where we speculatively assume the page won't be dirtied (modified) during migration:
- Reset the dirty bit in the PTE (mark as clean) and invalidate TLB.
- Copy the page content to the new physical location.
- Invalidate TLB again and use CAS (Compare-And-Swap) to atomically check/verify if the page was dirtied during the copy. If the page was changed, retry copying it.
The key benefit here is that no page faults occur on reads or writes during migration—the process continues seamlessly using the old mapping. This minimizes performance degradation for the affected process. However, due to the extra TLB invalidation, we might have to pay additional costs, especially for cross-core TLB invalidations (IPIs). This and the general performance and scalability of this optimization should be evaluated with memory-intensive benchmarks, like C/C++ compilation, databases, and scientific computing.
Documentation
- https://docs.kernel.org/mm/page_migration.html
- https://kernel-internals.org/mm/compaction
Related Work
-
DIMES
Workshop
Best Paper Award
The New Costs of Physical Memory Fragmentation -
Proceedings of the 2nd Workshop on Disruptive Memory Systems (SOSP-DIMES '24)Association for Computing Machinery2024Best Paper Award.
PDF Details 10.1145/3698783.3699378 []
Enhancing Energy Efficiency with Advanced DRAM Management in Linux
- Typ
- Masterarbeit
- Status
- abgeschlossen
- Supervisors
- Alexander Halbuer
Christian Dietrich
Daniel Lohmann - Projects
- ParPerOS
DRAMaOS - Bearbeiter
- Illia Ostapyshyn (abgegeben: 01. Nov 2024)
