From: Sasha Levin Date: Mon, 9 Sep 2024 12:47:26 +0000 (-0400) Subject: Fixes for 6.6 X-Git-Tag: v4.19.322~44^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=73d9efd8fdf44de940089dd4986e027d0f270842;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.6 Signed-off-by: Sasha Levin --- diff --git a/queue-6.6/mm-vmscan-use-folio_migratetype-instead-of-get_pageb.patch b/queue-6.6/mm-vmscan-use-folio_migratetype-instead-of-get_pageb.patch new file mode 100644 index 00000000000..1dc09aee11a --- /dev/null +++ b/queue-6.6/mm-vmscan-use-folio_migratetype-instead-of-get_pageb.patch @@ -0,0 +1,40 @@ +From c6ad1923534325034b2447609a99f9c07b10294f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 25 Aug 2023 15:57:34 +0800 +Subject: mm/vmscan: use folio_migratetype() instead of + get_pageblock_migratetype() + +From: Vern Hao + +[ Upstream commit 97144ce008f918249fa7275ee1d29f6f27665c34 ] + +In skip_cma(), we can use folio_migratetype() to replace +get_pageblock_migratetype(). + +Link: https://lkml.kernel.org/r/20230825075735.52436-1-user@VERNHAO-MC1 +Signed-off-by: Vern Hao +Reviewed-by: David Hildenbrand +Cc: Zhaoyang Huang +Signed-off-by: Andrew Morton +Stable-dep-of: bfe0857c20c6 ("Revert "mm: skip CMA pages when they are not available"") +Signed-off-by: Sasha Levin +--- + mm/vmscan.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mm/vmscan.c b/mm/vmscan.c +index 83fa8e924f8a..7175ff9b97d9 100644 +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -2271,7 +2271,7 @@ static bool skip_cma(struct folio *folio, struct scan_control *sc) + { + return !current_is_kswapd() && + gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE && +- get_pageblock_migratetype(&folio->page) == MIGRATE_CMA; ++ folio_migratetype(folio) == MIGRATE_CMA; + } + #else + static bool skip_cma(struct folio *folio, struct scan_control *sc) +-- +2.43.0 + diff --git a/queue-6.6/revert-mm-skip-cma-pages-when-they-are-not-available.patch b/queue-6.6/revert-mm-skip-cma-pages-when-they-are-not-available.patch new file mode 100644 index 00000000000..50d209dafc3 --- /dev/null +++ b/queue-6.6/revert-mm-skip-cma-pages-when-they-are-not-available.patch @@ -0,0 +1,102 @@ +From d6a1a1a9b688fbc8a97c1211626acab864e564cd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 21 Aug 2024 20:26:07 +0100 +Subject: Revert "mm: skip CMA pages when they are not available" + +From: Usama Arif + +[ Upstream commit bfe0857c20c663fcc1592fa4e3a61ca12b07dac9 ] + +This reverts commit 5da226dbfce3 ("mm: skip CMA pages when they are not +available") and b7108d66318a ("Multi-gen LRU: skip CMA pages when they are +not eligible"). + +lruvec->lru_lock is highly contended and is held when calling +isolate_lru_folios. If the lru has a large number of CMA folios +consecutively, while the allocation type requested is not MIGRATE_MOVABLE, +isolate_lru_folios can hold the lock for a very long time while it skips +those. For FIO workload, ~150million order=0 folios were skipped to +isolate a few ZONE_DMA folios [1]. This can cause lockups [1] and high +memory pressure for extended periods of time [2]. + +Remove skipping CMA for MGLRU as well, as it was introduced in sort_folio +for the same resaon as 5da226dbfce3a2f44978c2c7cf88166e69a6788b. + +[1] https://lore.kernel.org/all/CAOUHufbkhMZYz20aM_3rHZ3OcK4m2puji2FGpUpn_-DevGk3Kg@mail.gmail.com/ +[2] https://lore.kernel.org/all/ZrssOrcJIDy8hacI@gmail.com/ + +[usamaarif642@gmail.com: also revert b7108d66318a, per Johannes] + Link: https://lkml.kernel.org/r/9060a32d-b2d7-48c0-8626-1db535653c54@gmail.com + Link: https://lkml.kernel.org/r/357ac325-4c61-497a-92a3-bdbd230d5ec9@gmail.com +Link: https://lkml.kernel.org/r/9060a32d-b2d7-48c0-8626-1db535653c54@gmail.com +Fixes: 5da226dbfce3 ("mm: skip CMA pages when they are not available") +Signed-off-by: Usama Arif +Acked-by: Johannes Weiner +Cc: Bharata B Rao +Cc: Breno Leitao +Cc: David Hildenbrand +Cc: Matthew Wilcox +Cc: Rik van Riel +Cc: Vlastimil Babka +Cc: Yu Zhao +Cc: Zhaoyang Huang +Cc: Zhaoyang Huang +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Sasha Levin +--- + mm/vmscan.c | 24 ++---------------------- + 1 file changed, 2 insertions(+), 22 deletions(-) + +diff --git a/mm/vmscan.c b/mm/vmscan.c +index 7175ff9b97d9..81533bed0b46 100644 +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -2261,25 +2261,6 @@ static __always_inline void update_lru_sizes(struct lruvec *lruvec, + + } + +-#ifdef CONFIG_CMA +-/* +- * It is waste of effort to scan and reclaim CMA pages if it is not available +- * for current allocation context. Kswapd can not be enrolled as it can not +- * distinguish this scenario by using sc->gfp_mask = GFP_KERNEL +- */ +-static bool skip_cma(struct folio *folio, struct scan_control *sc) +-{ +- return !current_is_kswapd() && +- gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE && +- folio_migratetype(folio) == MIGRATE_CMA; +-} +-#else +-static bool skip_cma(struct folio *folio, struct scan_control *sc) +-{ +- return false; +-} +-#endif +- + /* + * Isolating page from the lruvec to fill in @dst list by nr_to_scan times. + * +@@ -2326,8 +2307,7 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, + nr_pages = folio_nr_pages(folio); + total_scan += nr_pages; + +- if (folio_zonenum(folio) > sc->reclaim_idx || +- skip_cma(folio, sc)) { ++ if (folio_zonenum(folio) > sc->reclaim_idx) { + nr_skipped[folio_zonenum(folio)] += nr_pages; + move_to = &folios_skipped; + goto move; +@@ -4971,7 +4951,7 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, struct scan_c + } + + /* ineligible */ +- if (zone > sc->reclaim_idx || skip_cma(folio, sc)) { ++ if (zone > sc->reclaim_idx) { + gen = folio_inc_gen(lruvec, folio, false); + list_move_tail(&folio->lru, &lrugen->folios[gen][type][zone]); + return true; +-- +2.43.0 + diff --git a/queue-6.6/series b/queue-6.6/series index eceb23b78fb..4104736b78a 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -202,3 +202,5 @@ cpufreq-amd-pstate-enable-amd-pstate-preferred-core-support.patch cpufreq-amd-pstate-fix-the-highest-frequency-issue-which-limits-performance.patch tcp-process-the-3rd-ack-with-sk_socket-for-tfo-mptcp.patch intel-legacy-partial-revert-of-field-get-conversion.patch +mm-vmscan-use-folio_migratetype-instead-of-get_pageb.patch +revert-mm-skip-cma-pages-when-they-are-not-available.patch