What is to be done about MGLRU?
7 hours ago
- #Linux Kernel
- #Memory Management
- #Page Reclaim
- Memory reclaim in the Linux kernel is fragmented with two separate algorithms (traditional LRU and MGLRU) in mm/vmscan.c, causing duplication and maintenance issues.
- Developers propose unifying the two reclaim subsystems by separating code into files, defining benchmarking workloads, identifying common features, and comparing implementations.
- Kairui Song has pending MGLRU improvements, and debate exists over whether to split code first or integrate changes, with concerns about Git history and regression risks.
- MGLRU shows benefits like lower locking contention and efficient lazy promotion but has issues with page-cache performance, jumpy metrics, and excessive page-flag usage on 32-bit systems.
- On Android, MGLRU is used on millions of devices but causes problems like aggressive file-backed page reclaim and difficulty controlling reclaim timing, requiring vendor-specific hooks.
- Future plans include unifying refault distance calculations, adding BPF hooks for customizable reclaim policies, and exposing MGLRU parameters via sysfs for better system awareness.