Optimistic Page Migration in Linux

image

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:

  1. Isolate the page from the free list (to prevent other subsystems from changing it).
  2. Unmap the virtual address and invalidate TLB entries across cores (expensive due to inter-processor interrupts).
  3. 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:

  1. Reset the dirty bit in the PTE (mark as clean) and invalidate TLB.
  2. Copy the page content to the new physical location.
  3. 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

DIMES Workshop Best Paper Award
The New Costs of Physical Memory Fragmentation
Alexander Halbuer, Illia Ostapyshyn, Lukas Steiner, Lars Wrenger, Matthias Jung, Christian Dietrich, Daniel LohmannProceedings 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

Modern computer systems face a significant challenge in managing physical memory efficiently, especially in the context of energy consumption. Specifically, the DRAM (Dynamic Random-Access Memory) components in these systems consume a considerable amount of energy due to their constant refresh requirements. [PDF]

 
Typ
Masterarbeit

 
Status
abgeschlossen

 
Supervisors
Alexander Halbuer
Christian Dietrich
Daniel Lohmann

 
Projects
ParPerOS
DRAMaOS

 
Bearbeiter
Illia Ostapyshyn (abgegeben: 01. Nov 2024)