Skip to content

Commit bfe0857

Browse files
uarif1akpm00
authored andcommitted
Revert "mm: skip CMA pages when they are not available"
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]>
1 parent f806de8 commit bfe0857

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

mm/vmscan.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,25 +1604,6 @@ static __always_inline void update_lru_sizes(struct lruvec *lruvec,
16041604

16051605
}
16061606

1607-
#ifdef CONFIG_CMA
1608-
/*
1609-
* It is waste of effort to scan and reclaim CMA pages if it is not available
1610-
* for current allocation context. Kswapd can not be enrolled as it can not
1611-
* distinguish this scenario by using sc->gfp_mask = GFP_KERNEL
1612-
*/
1613-
static bool skip_cma(struct folio *folio, struct scan_control *sc)
1614-
{
1615-
return !current_is_kswapd() &&
1616-
gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE &&
1617-
folio_migratetype(folio) == MIGRATE_CMA;
1618-
}
1619-
#else
1620-
static bool skip_cma(struct folio *folio, struct scan_control *sc)
1621-
{
1622-
return false;
1623-
}
1624-
#endif
1625-
16261607
/*
16271608
* Isolating page from the lruvec to fill in @dst list by nr_to_scan times.
16281609
*
@@ -1669,8 +1650,7 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan,
16691650
nr_pages = folio_nr_pages(folio);
16701651
total_scan += nr_pages;
16711652

1672-
if (folio_zonenum(folio) > sc->reclaim_idx ||
1673-
skip_cma(folio, sc)) {
1653+
if (folio_zonenum(folio) > sc->reclaim_idx) {
16741654
nr_skipped[folio_zonenum(folio)] += nr_pages;
16751655
move_to = &folios_skipped;
16761656
goto move;
@@ -4320,7 +4300,7 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, struct scan_c
43204300
}
43214301

43224302
/* ineligible */
4323-
if (zone > sc->reclaim_idx || skip_cma(folio, sc)) {
4303+
if (zone > sc->reclaim_idx) {
43244304
gen = folio_inc_gen(lruvec, folio, false);
43254305
list_move_tail(&folio->lru, &lrugen->folios[gen][type][zone]);
43264306
return true;

0 commit comments

Comments
 (0)