Re: [PATCH -next 4/8] mm: damon: add temporary damon_get_folio()

From: Matthew Wilcox
Date: Tue Dec 13 2022 - 09:40:52 EST


On Tue, Dec 13, 2022 at 05:27:31PM +0800, Kefeng Wang wrote:
> -struct page *damon_get_page(unsigned long pfn)
> +struct folio *damon_get_folio(unsigned long pfn)
> {
> - struct page *page = pfn_to_online_page(pfn);
> + struct folio *folio = pfn_to_online_folio(pfn);
>
> - if (!page || !PageLRU(page) || !get_page_unless_zero(page))
> + if (!folio || !folio_test_lru(folio) || !folio_try_get(folio))
> return NULL;

Well, this is awkward. I asked Vishal to think about exactly this problem
and we were going to talk about it after we're both back from vacation
in January. But I guess we're going to do this in public instead ...

Specifically, what should the semantics be for a putative
damon_get_folio() when it encounters a tail page? Should it return
the containing folio, or should it return NULL? And if the semantics
change here to return the containing folio, what adjustments need to
be made to the callers?