freenode
Kernel & Low-Level

Kernel fix stops reclaim storms under vm.defrag_mode

Non-movable allocations no longer thrash swap when defrag_mode cannot claim free pages from movable blocks.

A Meta production rollout of the kernel's vm.defrag_mode exposed a sharp regression: recurring memory pressure spikes, swap storms, and userspace OOM kills on some workloads. Johannes Weiner traced the failure to non-movable allocation requests spinning unproductively in direct reclaim once background reclaim and compaction fell behind.

Under defrag_mode, the allocator insists on whole pageblocks rather than fragmenting existing free space. Direct reclaim mostly frees individual pages inside movable blocks. Movable requests can use that space and make progress; non-movable ones cannot, so they retry reclaim over and over, driving excess swap and tripping pressure-based OOM guards.

Weiner's fix has those non-movable requests join pageblock-order reclaim and compaction in the allocator slowpath, so they help produce the unfragmented blocks the mode requires. Supporting changes let whole-block compaction scan other migratetypes (CMA excepted) and keep capture logic tied to the original allocation order rather than the promoted compaction order.

The series has run for weeks against an affected Meta workload and restored OOM rates to the pre-defrag_mode baseline. It is marked for stable. Longer term, Weiner still wants every allocation type to share block-production cost, but compaction scaling limits make promoting only non-movables the minimal fix for now.