mm-switch-deferred-split-shrinker-to-list_lru.patch removed from -mm tree
The quilt patch titled
Subject: mm: switch deferred split shrinker to list_lru
has been removed from the -mm tree. Its filename was
mm-switch-deferred-split-shrinker-to-list_lru.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Johannes Weiner <[email protected]>
Subject: mm: switch deferred split shrinker to list_lru
Date: Wed, 27 May 2026 16:45:16 -0400
The deferred split queue handles cgroups in a suboptimal fashion. The queue is per-NUMA node or per-cgroup, not the intersection. That means on a cgrouped system, a node-restricted allocation entering reclaim can end up splitting large pages on other nodes:
alloc/unmap
deferred_split_folio()
list_add_tail(memcg->split_queue) set_shrinker_bit(memcg, node, deferred_shrinker_id)
for_each_zone_zonelist_nodemask(restricted_nodes)
mem_cgroup_iter()
shrink_slab(node, memcg)
shrink_slab_memcg(node, memcg)
if test_shrinker_bit(memcg, node, deferred_shrinker_id)
deferred_split_scan()
walks memcg->split_queue
The shrinker bit adds an imperfect guard rail. As soon as the cgroup has a single large page on the node of interest, all large pages owned by that memcg, including those on other nodes, will be split.
list_lru properly sets up per-node, per-cgroup lists. As a bonus, it streamlines a lot of the list operations and reclaim walks. It's used widely by other major shrinkers already. Convert the deferred split queue as well.
The list_lru per-memcg heads are instantiated on demand when the first object of interest is allocated for a cgroup, by calling folio_memcg_alloc_deferred(). Add calls to where splittable pages are
created: anon faults, swapin faults, khugepaged collapse.
These calls create all possible node heads for the cgroup at once, so the migration code (between nodes) doesn't need any special care.
---
include/linux/huge_mm.h | 17 + include/linux/memcontrol.h | 4 include/linux/mmzone.h | 12 - mm/huge_memory.c | 367 +++++++++++------------------------ mm/internal.h | 2 mm/khugepaged.c | 5 mm/memcontrol.c | 12 - mm/memory.c | 4 mm/mm_init.c | 15 - mm/swap_state.c | 10 10 files changed, 160 insertions(+), 288 deletions(-)
include/linux/huge_mm.h renamed from include/linux/huge_mm.h~mm-switch-deferred-split-shrinker-to-list_lru +12 -5
@@ -439,10 +439,10 @@ static inline int split_huge_page(struct {return split_huge_page_to_list_to_order (page,NULL ,0 ); } + +int folio_memcg_alloc_deferred (struct folio *folio); +void deferred_split_folio (struct folio *folio,bool partially_mapped); -#ifdef CONFIG_MEMCG -void reparent_deferred_split_queue (struct mem_cgroup *memcg); -#endif void __split_huge_pmd (struct vm_area_struct *vma,pmd_t *pmd,unsigned long address,bool freeze);
@@ -679,8 +679,15 @@ static inline int try_folio_split_to_ordreturn -EINVAL ; } -static inline void deferred_split_folio (struct folio *folio,bool partially_mapped) {} -static inline void reparent_deferred_split_queue (struct mem_cgroup *memcg) {} +static inline int folio_memcg_alloc_deferred (struct folio *folio) +{ +return 0 ; +} + +static inline void deferred_split_folio (struct folio *folio,bool partially_mapped) +{ +} +#define split_huge_pmd (__vma, __pmd, __address) \ do { } while (0)
include/linux/memcontrol.h renamed from include/linux/memcontrol.h~mm-switch-deferred-split-shrinker-to-list_lru +0 -4
@@ -278,10 +278,6 @@ struct mem_cgroup {struct memcg_cgwb_frn cgwb_frn[MEMCG_CGWB_FRN_CNT ];#endif -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -struct deferred_split deferred_split_queue; -#endif -#ifdef CONFIG_LRU_GEN_WALKS_MMU /* per-memcg mm_struct list */ struct lru_gen_mm_list mm_list;
include/linux/mmzone.h renamed from include/linux/mmzone.h~mm-switch-deferred-split-shrinker-to-list_lru +0 -12
@@ -1431,14 +1431,6 @@ struct zonelist {*/ extern struct page *mem_map; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -struct deferred_split { -spinlock_t split_queue_lock; -struct list_head split_queue; -unsigned long split_queue_len; -}; -#endif -#ifdef CONFIG_MEMORY_FAILURE /* * Per NUMA node memory failure handling statistics.
@@ -1564,10 +1556,6 @@ typedef struct pglist_data {unsigned long first_deferred_pfn;#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -struct deferred_split deferred_split_queue; -#endif -#ifdef CONFIG_NUMA_BALANCING /* start time in ms of current promote rate limit period */ unsigned int nbp_rl_start;
mm/huge_memory.c renamed from mm/huge_memory.c~mm-switch-deferred-split-shrinker-to-list_lru +125 -242
521 lines not on this page · raw message
mm/internal.h renamed from mm/internal.h~mm-switch-deferred-split-shrinker-to-list_lru +1 -1
@@ -852,7 +852,7 @@ static inline bool folio_unqueue_deferre/* * At this point, there is no one trying to add the folio to * deferred_list. If folio is not in deferred_list, it's safe -* to check without acquiring the split_queue_lock. +* to check without acquiring the list_lru lock. */ if (data_race (list_empty (&folio->_deferred_list)))return false;
mm/khugepaged.c renamed from mm/khugepaged.c~mm-switch-deferred-split-shrinker-to-list_lru +5 -0
@@ -1123,6 +1123,11 @@ static enum scan_result collapse_huge_paif (result !=SCAN_SUCCEED ) goto out_nolock; +if (folio_memcg_alloc_deferred (folio)) { + result =SCAN_ALLOC_HUGE_PAGE_FAIL ; + goto out_nolock; + } +mmap_read_lock (mm); result =hugepage_vma_revalidate (mm, address, true, &vma, cc);if (result !=SCAN_SUCCEED ) {
mm/memcontrol.c renamed from mm/memcontrol.c~mm-switch-deferred-split-shrinker-to-list_lru +3 -9
@@ -4144,11 +4144,6 @@ static struct mem_cgroup *mem_cgroup_all memcg->cgwb_frn[i].done =__WB_COMPLETION_INIT (&memcg_cgwb_frn_waitq);#endif -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -spin_lock_init (&memcg->deferred_split_queue.split_queue_lock); -INIT_LIST_HEAD (&memcg->deferred_split_queue.split_queue); - memcg->deferred_split_queue.split_queue_len =0 ; -#endif lru_gen_init_memcg (memcg);return memcg; fail:
@@ -4299,11 +4294,10 @@ static void mem_cgroup_css_offline(struczswap_memcg_offline_cleanup (memcg);memcg_offline_kmem (memcg); -reparent_deferred_split_queue (memcg);/* -* The reparenting of objcg must be after the reparenting of the -* list_lru and deferred_split_queue above, which ensures that they will -* not mistakenly get the parent list_lru and deferred_split_queue. +* The reparenting of objcg must be after the reparenting of +* the list_lru in memcg_offline_kmem(), which ensures that +* they will not mistakenly get the parent list_lru. */ memcg_reparent_objcgs (memcg);reparent_shrinker_deferred (memcg);
mm/memory.c renamed from mm/memory.c~mm-switch-deferred-split-shrinker-to-list_lru +4 -0
@@ -5222,6 +5222,10 @@ static struct folio *alloc_anon_folio(stfolio_put (folio); goto next; } +if (order >1 &&folio_memcg_alloc_deferred (folio)) { +folio_put (folio); + goto fallback; + }folio_throttle_swaprate (folio, gfp);/* * When a folio is not zeroed during allocation
mm/mm_init.c renamed from mm/mm_init.c~mm-switch-deferred-split-shrinker-to-list_lru +0 -15
@@ -1373,19 +1373,6 @@ static void __init calculate_node_totalppr_debug ("On node %d totalpages: %lu\n" , pgdat->node_id, realtotalpages); } -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -static void pgdat_init_split_queue (struct pglist_data *pgdat) -{ -struct deferred_split *ds_queue = &pgdat->deferred_split_queue; - -spin_lock_init (&ds_queue->split_queue_lock); -INIT_LIST_HEAD (&ds_queue->split_queue); - ds_queue->split_queue_len =0 ; -} -#else -static void pgdat_init_split_queue (struct pglist_data *pgdat) {} -#endif -#ifdef CONFIG_COMPACTION static void pgdat_init_kcompactd (struct pglist_data *pgdat) {
@@ -1401,8 +1388,6 @@ static void __meminit pgdat_init_internapgdat_resize_init (pgdat);pgdat_kswapd_lock_init (pgdat); - -pgdat_init_split_queue (pgdat);pgdat_init_kcompactd (pgdat);init_waitqueue_head (&pgdat->kswapd_wait);
mm/swap_state.c renamed from mm/swap_state.c~mm-switch-deferred-split-shrinker-to-list_lru +10 -0
@@ -465,6 +465,16 @@ static struct folio *__swap_cache_alloc(return ERR_PTR (-ENOMEM ); } +if (order >1 &&folio_memcg_alloc_deferred (folio)) { +spin_lock (&ci->lock); +__swap_cache_do_del_folio (ci, folio, entry, shadow); +spin_unlock (&ci->lock); +folio_unlock (folio); +/* nr_pages refs from swap cache, 1 from allocation */ +folio_put_refs (folio, nr_pages +1 ); +return ERR_PTR (-ENOMEM ); + } +/* memsw uncharges swap when folio is added to swap cache */ memcg1_swapin (folio);if (shadow)
_
Patches currently in -mm which might be from [email protected] are