Re: summarize all information again at bottom//reply: reply: [PATCH] mm: fix a race scenario in folio_isolate_lru

From: Matthew Wilcox
Date: Mon Mar 18 2024 - 23:01:31 EST


On Tue, Mar 19, 2024 at 08:48:42AM +0800, Zhaoyang Huang wrote:
> BTW, damon_pa_pageout is a potential risk over this race

No it isn't.

struct folio *folio = damon_get_folio(PHYS_PFN(addr));

if (!folio)
continue;

if (damos_pa_filter_out(s, folio))
goto put_folio;

folio_clear_referenced(folio);
folio_test_clear_young(folio);
if (!folio_isolate_lru(folio))
goto put_folio;
if (folio_test_unevictable(folio))
folio_putback_lru(folio);
else
list_add(&folio->lru, &folio_list);
put_folio:
folio_put(folio);

It clearly has a folio reference when it calls folio_isolate_lru().