Skip to content

RFC mm: reliable 1GB page allocation

Rik van Riel linux-btrfs linux-cxl linux-doc linux-mm linux-pm linux-trace-kernel lkml oe-kbuild-all syzbot 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest40 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/40mm: page_alloc: replace pageblock_flags bitmap with struct pageblock_datainclude/linux/mmzone.h mm/internal.h mm/mm_init.c +2 more+50 -940 replies
2/40mm: page_alloc: per-cpu pageblock buddy allocatorinclude/linux/mmzone.h include/linux/page-flags.h mm/debug.c +1 more+576 -1250 replies
3/40mm: page_alloc: split-path PCP free with local-trylock + remote-llistinclude/linux/mmzone.h mm/page_alloc.c+193 -650 replies
4/40mm: mm_init: fix zone assignment for pages in unavailable rangesmm/mm_init.c+19 -10 replies
5/40mm: page_alloc: remove watermark boost mechanismDocumentation/admin-guide/sysctl/vm.rst Documentation/mm/physical_memory.rst include/linux/mmzone.h +4 more+14 -2272 replies
6/40mm: page_alloc: async evacuation of stolen movable pageblocksinclude/linux/mmzone.h mm/page_alloc.c+227 -00 replies
7/40mm: page_alloc: track actual page contents in pageblock flagsinclude/linux/pageblock-flags.h mm/compaction.c mm/page_alloc.c+98 -210 replies
8/40mm: page_alloc: superpageblock metadata for 1GB anti-fragmentationinclude/linux/mmzone.h mm/mm_init.c mm/page_alloc.c+212 -00 replies
9/40mm: page_alloc: support superpageblock resize for memory hotpluginclude/linux/mmzone.h mm/internal.h mm/memory_hotplug.c +1 more+147 -00 replies
10/40mm: page_alloc: add superpageblock fullness lists for allocation steeringinclude/linux/mmzone.h include/linux/pageblock-flags.h mm/mm_init.c +1 more+339 -50 replies
11/40mm: page_alloc: steer pageblock stealing to tainted superpageblocksmm/page_alloc.c+79 -210 replies
12/40mm: page_alloc: steer movable allocations to fullest clean superpageblocksmm/page_alloc.c+86 -30 replies
13/40mm: page_alloc: extract claim_whole_block from try_to_claim_blockmm/page_alloc.c+55 -340 replies
14/40mm: page_alloc: add per-superpageblock free listsinclude/linux/mmzone.h mm/compaction.c mm/internal.h +3 more+883 -2380 replies
15/40mm: page_alloc: add background superpageblock defragmentation workerinclude/linux/mmzone.h mm/internal.h mm/mm_init.c +1 more+259 -980 replies
16/40mm: compaction: walk per-superpageblock free lists for migration targetsinclude/linux/mmzone.h mm/compaction.c mm/page_alloc.c+330 -1430 replies
17/40mm: page_alloc: superpageblock-aware contiguous and higher order allocationinclude/linux/mmzone.h mm/page_alloc.c+479 -70 replies
18/40mm: page_alloc: prevent atomic allocations from tainting clean SPBsmm/internal.h mm/page_alloc.c+110 -110 replies
19/40mm: page_alloc: aggressively pack non-movable allocs in tainted SPBs on large systemsmm/page_alloc.c+68 -20 replies
20/40mm: page_alloc: prefer reclaim over tainting clean superpageblocksmm/page_alloc.c+61 -130 replies
21/40mm: page_alloc: adopt partial pageblocks from tainted superpageblocksmm/page_alloc.c+117 -140 replies
22/40mm: page_alloc: add CONFIG_DEBUG_VM sanity checks for SPB countersmm/page_alloc.c+38 -30 replies
23/40mm: page_alloc: targeted evacuation and dynamic reserves for tainted SPBsmm/page_alloc.c+219 -1150 replies
24/40mm: page_alloc: prevent UNMOVABLE/RECLAIMABLE mixing in pageblocksmm/page_alloc.c+83 -250 replies
25/40mm: trigger deferred SPB evac when atomic allocs would taint a clean SPBinclude/linux/mmzone.h mm/page_alloc.c+215 -10 replies
26/40mm: page_alloc: refuse fragmenting fallback for callers with cheap fallbackinclude/linux/vm_event_item.h mm/internal.h mm/page_alloc.c +1 more+116 -60 replies
27/40mm: page_alloc: cross-migratetype buddy borrow within tainted SPBsmm/page_alloc.c+156 -00 replies
28/40mm: page_alloc: drive slab shrink from SPB anti-fragmentation pressureinclude/linux/mmzone.h include/linux/vm_event_item.h mm/internal.h +3 more+290 -200 replies
29/40mm: page_reporting: walk per-superpageblock free listsmm/page_reporting.c+90 -590 replies
30/40mm: show_mem: collect migratetype letters from per-superpageblock listsmm/show_mem.c+20 -50 replies
31/40mm: page_alloc: per-(zone, order, mt) PASS_1 hint cacheinclude/linux/mmzone.h mm/internal.h mm/mm_init.c +1 more+194 -00 replies
32/40mm: debug: prevent infinite recursion in dump_page() with CMAmm/debug.c+17 -10 replies
33/40PM: hibernate: walk per-superpageblock free lists in mark_free_pageskernel/power/snapshot.c+25 -101 reply
34/40btrfs: allocate eb-attached btree pages as movablefs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/inode.c +4 more+59 -295 replies
35/40mm: page_alloc: refuse best-effort high-order allocs servable at lower ordersmm/page_alloc.c+122 -00 replies
36/40mm: page_alloc: set ALLOC_NOFRAGMENT on alloc_frozen_pages_nolock_noprofmm/page_alloc.c+17 -10 replies
37/40mm: page_alloc: move spb_get_category and spb_tainted_reserve to mmzone.hinclude/linux/mmzone.h mm/page_alloc.c+35 -220 replies
38/40mm: compaction: skip empty tainted superpageblocks as migration sourcemm/compaction.c+21 -00 replies
39/40mm: compaction: respect tainted SPB reserve in destination selectionmm/compaction.c+15 -00 replies
40/40mm: page_alloc: SPB tracepoint instrumentation [DO-NOT-MERGE]include/trace/events/kmem.h mm/page_alloc.c+514 -130 replies

Reviews trailers per patch

1 of 40 patches has a Reviewed-by or Acked-by.

PatchBoris Burkov
1/40
2/40
3/40
4/40
5/40
6/40
7/40
8/40
9/40
10/40
11/40
12/40
13/40
14/40
15/40
16/40
17/40
18/40
19/40
20/40
21/40
22/40
23/40
24/40
25/40
26/40
27/40
28/40
29/40
30/40
31/40
32/40
33/40
34/40R-b
35/40
36/40
37/40
38/40
39/40
40/40

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH 00/40] mm: reliable 1GB page allocation

Some workloads see real performance benefits from using 1GB pages, but allocating 1GB pages has often been limited to hugetlb pages that were set aside at boot time, or using CMA to keep a fixed amount of system memory off limits to the kernel.

Neither of those are great solutions, given that modern servers tend to be large, often run multiple workloads simultaneously, and each workload wants something else.

To address that issue, this patch series divides memory not just into 2MB page blocks, but into PUD sized superpageblocks, and aggressively tries to steer unmovable, reclaimable, and highatomic allocations into those superpageblocks that have already been "tainted" by such allocations.

The goal is to leave as many 1GB superpageblocks as possible used by only movable allocations, so they can be easily defragmented for either regular PMD sized huge pages, or for PUD sized huge pages.

Various strategies are used to accomplish this goal:
- unmovable and reclaimable allocations are preferentially done from 1GB blocks that have already been "tainted" by these allocations
- kernel allocations that can be done as one higher order allocation, or a number of smaller allocations (eg. kvmalloc) will fall back to small pages, rather than taint a new 1GB block
- movable allocations are preferentially done from clean 1GB blocks, which have only free and movable memory inside, starting with the fullest of these 1GB blocks
- 2MB allocations follow the same strategy
- 1GB allocations start with the emptiest clean 1GB block
- if a 1GB block is mixed, with some movable pageblocks, some free pageblocks, and some unmovable/reclaimable pageblocks, the system has a free threshold below which only unmovable and reclaimable allocations can be done from that 1GB block
- below that threshold, no new movable allocations are allowed in that 1GB block, while new unmovable/reclaimable allocations are still allowed
- when a 1GB block is below that threshold, use the migration code to evacuate enough movable memory from the 1GB block to bring free memory in that 1GB block back to the threshold

These strategies together serve to concentrate unmovable and reclaimable allocations in as few 1GB blocks as possible, leaving as many 1GB blocks as possible available for movable allocations.

That enables both more extensive use of 2MB THPs and mTHPs, as well as reliable allocation of 1GB pages.

The above strategies also make the core page allocator more complicated, and slower. In order to avoid that issue, the series is built on top of Johannes's PCPBuddy series, which has the goal of reducing how often CPUs need to get pages from the zone free lists, instead relying on CPUs giving back pages to each other, based on page block ownership.

TODO:
- compaction "always" succeeds, with a success rate of 99.96% seen in traces; this sounds great, but it also results in compaction never being throttled, and compaction blowing out everybody's PCP through lru_add_drain() calls. This needs some sort of solution.
- replace the superpageblock name with something Matthew and David both like
- find more corner cases, and fix them

Based on e1914add2799