mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] mm/page_alloc: keep non-movable pages out of movable pageblocks for THP
@ 2026-10-07  2:12 Rik van Riel
  2026-10-07  2:12 ` [RFC PATCH 1/5] mm/page_alloc: count guard pages as free again when their buddy merges Rik van Riel
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Rik van Riel @ 2026-10-07  2:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan, Kairui Song, Qi Zheng,
	Shakeel Butt, Barry Song, Axel Rasmussen, Yuanchu Xie, Wei Xu,
	Baoquan He, Baolin Wang, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Mike Rapoport, linux-mm

Last week I posted the first prototype of the reworked gigablock
page allocation code, which uses the per-migrate_type free lists
in the zone as its fast path:

https://lore.kernel.org/lkml/20261004013657.03a63c4c@fangorn/

Zi Yan took a look, and pointed out that the first patches in
the series might help with THP allocation. Testing showed he
is right.

Having this code be useful by itself changes the gigablock
merge plan. It can now be done in stages:
1) Pageblock claiming fixes & improvements, which show a
   modest improvement in THP allocation. This is the only
   code in the fast path.
2) Page compaction, evacuation, and free list threshold changes,
   which can really help concentrate non-movable allocations in
   non-movable typed pageblocks, hopefully making compaction and
   THP allocation noticeably more reliable.
3) The actual gigablock targeting. This is also a slow path,
   like compaction and evacuation.

This first series addresses pageblock claiming and stealing
policies. Current page allocation policies cause the THP allocation
success rate to collapse under sustained non-movable demand.

A single non-movable page in a movable-type page block prevents
that page block from being used for a THP, but it does not
prevent kcompactd from spending time on that block.

Three paths mix unmovable pages into movable-typed blocks.
try_to_claim_block() converts a movable block for a non-movable
allocation only when half its pages are free or compatible.
__rmqueue_steal() takes pages without converting at all, and a
bulk batch that steals once never reaches the claim path again.

compaction_capture() hands a merged movable block to a
non-movable request with no type change.

Patches 1-2 are standalone accounting fixes: guard pages return
to the counts when their buddy merges, and a merged buddy's
pages move to the merged type in the free page accounting.

Patches 3-5 make the pageblock migrate type follow the content:
convert any movable block on a non-movable claim, skip movable
blocks on non-movable steals, and claim movable blocks fully taken
by non-movable compaction capture.

Pageblocks that straddle zones cannot safely change type,
since the allocator may have locked the "wrong" zone. Those
blocks are left alone.

The series is preventive: it keeps new placements to their own
type and stops polluting movable block. The next step, for
another series, will be to evacuate movable content from
pageblocks stolen by non-movable allocations, in order to
concentrate kernel allocations in fewer pageblocks.

Measured on 64GB 8-vCPU KVM guests, THP=always, defrag=always,
khugepaged collapse off, 8GB virtio swap. The guest boots into
a fragmented base: a 10GB mlocked block flood, 36GB of aged
anonymous memory, and background unmovable allocations.

Then 8 rounds of type-pressure buildup. Each round drains
high-order free memory with a large NOHUGEPAGE touch, adds 550
pagetable-heavy processes plus 200000 slab files as unmovable
demand, and ends with a fixed 2GB 8-thread THP probe that stays
mapped while success is measured. The bursts persist across
rounds while the drain shrinks by ~2.75GB each round, so each
round's demand faces less free memory.

Measured is the thp_fault_alloc success rate, across
4 runs of 8 rounds each.

                                   patched        base
rounds with <50% success            7/31         16/31
THP alloc success rate @r4       74% (47-98)  42% (25-67)
blocks with unmovable pages @r8     43-154     1674-2131

Two rounds died due to swap exhaustion, and are not counted.

Pageblocks with unmovable pages were counted by checking
/proc/kpageflags after each round. The total amount of
unmovable pages is similar with and without the series,
they just get packed into fewer pageblocks.

Converting taken blocks and refusing fallback steals packs
unmovable pages into converted blocks, leaving clean movable
victims for the scanners: a round-2 probe on the series
kernel compacts 690 of 697 attempts at 92.6% THP where the
base compacts 47 of 376 at 4.7%.

This series is broken out of the 1GB gigablock prototype work:

 include/linux/mmzone.h |  13 +++++
 mm/page_alloc.c        | 117 +++++++++++++++++++++++++++++++------------------
 2 files changed, 88 insertions(+), 42 deletions(-)

base-commit: 67f0943b394d9

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-07  2:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07  2:12 [RFC PATCH 0/5] mm/page_alloc: keep non-movable pages out of movable pageblocks for THP Rik van Riel
2026-10-07  2:12 ` [RFC PATCH 1/5] mm/page_alloc: count guard pages as free again when their buddy merges Rik van Riel
2026-10-07  2:12 ` [RFC PATCH 2/5] mm/page_alloc: count a merged buddy's pages under the merged type Rik van Riel
2026-10-07  2:12 ` [RFC PATCH 3/5] mm/page_alloc: convert any movable pageblock on a non-movable allocation Rik van Riel
2026-10-07  2:12 ` [RFC PATCH 4/5] mm/page_alloc: skip movable blocks during non-movable steals Rik van Riel
2026-10-07  2:12 ` [RFC PATCH 5/5] mm/page_alloc: claim blocks captured for non-movable use Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®