[PATCH 0/3] mm: make watermark checks honour ALLOC_NOFRAGMENT
From: Kiryl Shutsemau
Date: Wed Oct 28 2026 - 09:28:32 EST
From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>
With defrag_mode, 64K mTHP faults under memory pressure stall in
compaction 18 times as often as without it, and get about a third of the
folios. Dev Jain reported it [1].
The high-order watermark check counts free pages of every migratetype.
With defrag_mode, every slowpath allocation is ALLOC_NOFRAGMENT, and a
request below pageblock_order cannot take free pages from another
migratetype's pageblock. Under pressure, that is where the large free
pages end up. Two callers act on the wrong answer:
- direct compaction's up-front check returns COMPACT_SUCCESS without
compacting, so compaction is never deferred;
- direct reclaim for a costly order stops early, having freed little.
Patches 1-2 give the check the request's migratetype and make it skip
the free lists the request cannot take. Patch 3 tells direct reclaim
that the allocation is ALLOC_NOFRAGMENT.
Dev's benchmark in a 7G VM with only 64K mTHP enabled, medians of 15
runs:
defrag_mode=0 defrag_mode=1 defrag_mode=1
+ series
compact_stall 1690 30669 7366
64K faults allocated 20750 7391 20129
64K faults falling back to 4K 725 13832 1339
defrag_mode=1 still compacts more than defrag_mode=0: by design, it
keeps 64K faults out of unmovable and reclaimable pageblocks [2].
defrag_mode=0 is unchanged: 20698 64K faults allocated with the series.
[1] https://lore.kernel.org/all/4aa14b41-9b89-494c-8825-55fffd5a541c@xxxxxxx/
[2] https://lore.kernel.org/all/auCDnqJc7fsBpUW2@thinkstation/
Kiryl Shutsemau (Meta) (3):
mm: page_alloc: add a watermark check that knows the migratetype
mm: page_alloc: make the high-order watermark check honour
ALLOC_NOFRAGMENT
mm: vmscan: tell direct reclaim the allocation is ALLOC_NOFRAGMENT
include/linux/mmzone.h | 3 --
mm/compaction.c | 16 +++++++----
mm/internal.h | 10 ++++++-
mm/page_alloc.c | 64 +++++++++++++++++++++++++++++++++---------
mm/vmscan.c | 24 ++++++++++++----
5 files changed, 89 insertions(+), 28 deletions(-)
base-commit: d865f2677c44cb2171b833d6775cf692756fa8be
--
2.54.0