Skip to content

Commit 0eceaa9

Browse files
uarif1gregkh
authored andcommitted
Revert "mm: skip CMA pages when they are not available"
[ Upstream commit bfe0857c20c663fcc1592fa4e3a61ca12b07dac9 ] This reverts commit 5da226d ("mm: skip CMA pages when they are not available") and b7108d6 ("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 5da226d. [1] https://lore.kernel.org/all/CAOUHufbkhMZYz20aM_3rHZ3OcK4m2puji2FGpUpn_-DevGk3Kg@mail.gmail.com/ [2] https://lore.kernel.org/all/[email protected]/ [[email protected]: also revert b7108d6, per Johannes] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 5da226d ("mm: skip CMA pages when they are not available") Signed-off-by: Usama Arif <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Bharata B Rao <[email protected]> Cc: Breno Leitao <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Yu Zhao <[email protected]> Cc: Zhaoyang Huang <[email protected]> Cc: Zhaoyang Huang <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 9a99747 commit 0eceaa9

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

mm/vmscan.c

+2-22
Original file line numberDiff line numberDiff line change
@@ -2261,25 +2261,6 @@ static __always_inline void update_lru_sizes(struct lruvec *lruvec,
22612261

22622262
}
22632263

2264-
#ifdef CONFIG_CMA
2265-
/*
2266-
* It is waste of effort to scan and reclaim CMA pages if it is not available
2267-
* for current allocation context. Kswapd can not be enrolled as it can not
2268-
* distinguish this scenario by using sc->gfp_mask = GFP_KERNEL
2269-
*/
2270-
static bool skip_cma(struct folio *folio, struct scan_control *sc)
2271-
{
2272-
return !current_is_kswapd() &&
2273-
gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE &&
2274-
folio_migratetype(folio) == MIGRATE_CMA;
2275-
}
2276-
#else
2277-
static bool skip_cma(struct folio *folio, struct scan_control *sc)
2278-
{
2279-
return false;
2280-
}
2281-
#endif
2282-
22832264
/*
22842265
* Isolating page from the lruvec to fill in @dst list by nr_to_scan times.
22852266
*
@@ -2326,8 +2307,7 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan,
23262307
nr_pages = folio_nr_pages(folio);
23272308
total_scan += nr_pages;
23282309

2329-
if (folio_zonenum(folio) > sc->reclaim_idx ||
2330-
skip_cma(folio, sc)) {
2310+
if (folio_zonenum(folio) > sc->reclaim_idx) {
23312311
nr_skipped[folio_zonenum(folio)] += nr_pages;
23322312
move_to = &folios_skipped;
23332313
goto move;
@@ -4971,7 +4951,7 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, struct scan_c
49714951
}
49724952

49734953
/* ineligible */
4974-
if (zone > sc->reclaim_idx || skip_cma(folio, sc)) {
4954+
if (zone > sc->reclaim_idx) {
49754955
gen = folio_inc_gen(lruvec, folio, false);
49764956
list_move_tail(&folio->lru, &lrugen->folios[gen][type][zone]);
49774957
return true;

0 commit comments

Comments
 (0)