Skip to content

RFC 1GB superpageblock memory allocation

Rik van Riel linux-btrfs linux-mm linux-pm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest45 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/45mm: 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/45mm: page_alloc: per-cpu pageblock buddy allocatorinclude/linux/mmzone.h include/linux/page-flags.h mm/debug.c +1 more+575 -1630 replies
3/45mm: page_alloc: use trylock for PCP lock in free path to avoid lock inversionmm/page_alloc.c+9 -70 replies
4/45mm: mm_init: fix zone assignment for pages in unavailable rangesmm/mm_init.c+19 -10 replies
5/45mm: vmstat: restore per-migratetype free counts in /proc/pagetypeinfomm/vmstat.c+38 -280 replies
6/45mm: page_alloc: remove watermark boost mechanismDocumentation/admin-guide/sysctl/vm.rst Documentation/mm/physical_memory.rst include/linux/mmzone.h +4 more+14 -2270 replies
7/45mm: page_alloc: async evacuation of stolen movable pageblocksinclude/linux/mmzone.h mm/page_alloc.c+227 -00 replies
8/45mm: page_alloc: track actual page contents in pageblock flagsinclude/linux/pageblock-flags.h mm/compaction.c mm/page_alloc.c+98 -210 replies
9/45mm: page_alloc: introduce superpageblock metadata for 1GB anti-fragmentationinclude/linux/mmzone.h mm/mm_init.c mm/page_alloc.c+212 -00 replies
10/45mm: page_alloc: support superpageblock resize for memory hotpluginclude/linux/mmzone.h mm/internal.h mm/memory_hotplug.c +1 more+147 -00 replies
11/45mm: 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
12/45mm: page_alloc: steer pageblock stealing to tainted superpageblocksmm/page_alloc.c+82 -210 replies
13/45mm: page_alloc: steer movable allocations to fullest clean superpageblocksmm/page_alloc.c+86 -30 replies
14/45mm: page_alloc: extract claim_whole_block from try_to_claim_blockmm/page_alloc.c+54 -360 replies
15/45mm: page_alloc: add per-superpageblock free listsinclude/linux/mmzone.h mm/compaction.c mm/internal.h +2 more+756 -1750 replies
16/45mm: page_alloc: add background superpageblock defragmentation workerinclude/linux/mmzone.h mm/internal.h mm/mm_init.c +1 more+301 -1240 replies
17/45mm: page_alloc: add within-superpageblock compaction for clean superpageblocksinclude/linux/mmzone.h mm/compaction.c mm/page_alloc.c+501 -1150 replies
18/45mm: page_alloc: superpageblock-aware contiguous and higher order allocationinclude/linux/mmzone.h mm/mm_init.c mm/page_alloc.c+450 -50 replies
19/45mm: page_alloc: prevent atomic allocations from tainting clean SPBsmm/internal.h mm/page_alloc.c+81 -70 replies
20/45mm: page_alloc: aggressively pack non-movable allocations in tainted SPBs on large systemsmm/page_alloc.c+68 -20 replies
21/45mm: page_alloc: prefer reclaim over tainting clean superpageblocksmm/page_alloc.c+61 -130 replies
22/45mm: page_alloc: adopt partial pageblocks from tainted superpageblocksmm/page_alloc.c+101 -130 replies
23/45mm: page_alloc: add CONFIG_DEBUG_VM sanity checks for SPB countersmm/page_alloc.c+41 -50 replies
24/45mm: page_alloc: targeted evacuation and dynamic reserves for tainted SPBsmm/page_alloc.c+125 -510 replies
25/45mm: page_alloc: skip pageblock compatibility threshold in tainted SPBsmm/page_alloc.c+20 -60 replies
26/45mm: page_alloc: prevent UNMOVABLE/RECLAIMABLE mixing in pageblocksmm/page_alloc.c+85 -260 replies
27/45mm: trigger deferred SPB evacuation when atomic allocs would taint a clean SPBinclude/linux/mmzone.h mm/page_alloc.c+206 -10 replies
28/45mm: page_alloc: keep PCP refill in tainted SPBs across owned pageblocksmm/page_alloc.c+29 -210 replies
29/45mm: 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
30/45mm: page_alloc: drive slab shrink from SPB anti-fragmentation pressureinclude/linux/mmzone.h include/linux/vm_event_item.h mm/page_alloc.c +1 more+151 -30 replies
31/45mm: page_alloc: cross-non-movable buddy borrow within tainted SPBsmm/page_alloc.c+85 -00 replies
32/45mm: page_alloc: proactive high-water trigger for SPB slab shrinkinclude/linux/mmzone.h mm/page_alloc.c+40 -150 replies
33/45mm: page_alloc: refuse to taint clean SPBs for atomic NORETRY callersmm/page_alloc.c+11 -00 replies
34/45mm: page_reporting: walk per-superpageblock free listsmm/page_reporting.c+90 -590 replies
35/45mm: show_mem: collect migratetype letters from per-superpageblock listsmm/show_mem.c+20 -50 replies
36/45mm: page_alloc: add alloc_flags parameter to __rmqueue_smallestmm/page_alloc.c+9 -60 replies
37/45mm/slub: kvmalloc — add __GFP_NORETRY to large-kmalloc attemptmm/slub.c+13 -20 replies
38/45mm: page_alloc: per-(zone, order, mt) PASS_1 hint cacheinclude/linux/mmzone.h mm/internal.h mm/mm_init.c +1 more+201 -00 replies
39/45mm: debug: prevent infinite recursion in dump_page() with CMAmm/debug.c+17 -10 replies
40/45PM: hibernate: walk per-superpageblock free lists in mark_free_pageskernel/power/snapshot.c+25 -100 replies
41/45btrfs: allocate eb-attached btree pages as movablefs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/inode.c +4 more+59 -290 replies
42/45mm: page_alloc: cross-MOV borrow within tainted SPBsmm/page_alloc.c+73 -00 replies
43/45mm: page_alloc: trigger defrag from allocator hot path on tainted-SPB pressuremm/page_alloc.c+53 -200 replies
44/45mm: page_alloc: SPB tracepoint instrumentation [DROP-FOR-UPSTREAM]include/trace/events/kmem.h mm/page_alloc.c+510 -100 replies
45/45mm: page_alloc: enlarge and unify spb_evacuate_for_ordermm/page_alloc.c+84 -570 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [00/45 RFC PATCH] 1GB superpageblock memory allocation

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.

This series is still very much a work in progress, with lots of work left to do, but I am posting it now (ahead of LSF/MM) in the hopes of getting some feedback on whether this looks like the right direction to go in.

This code has been largely written by AI, then nitpicked over by me (with some early feedback from Johannes and Usama), and gone through the cycle of nitpicks several times. I am sure there are places left where the code could, and should be better.

However, it does seem to work. On my 256GB system, I can run syzkaller with AI automatically analyzing crashes, examining git history for potential causes and fixes, etc, using up all of memory. Out of the 238 superpageblocks in the normal zone, normally less than 20 get used for unmovable and reclaimable allocations.

I can allocate 50 1GB huge pages without driving the workload out of memory. Presumably I could allocate a lot more if I shut down the workload.

A number of the patches, especially later in the series, are fixes that should be folded into earlier patches. I hope to do that soon-ish.

In the mean time, these are probably the patches to focus
on when reviewing the ideas behind this series:
- mm: page_alloc: track actual page contents in pageblock flags
- mm: page_alloc: add per-superpageblock free lists
- mm: page_alloc: add background superpageblock defragmentation worker
- mm: page_alloc: add within-superpageblock compaction for clean superpageblocks
- mm: page_alloc: superpageblock-aware contiguous and higher order allocation

Based on 1c9982b49613