Re: [PATCH -next 2/8] mm: page_idle: Convert page idle to use folios

From: Matthew Wilcox
Date: Tue Dec 13 2022 - 09:35:04 EST


On Tue, Dec 13, 2022 at 05:27:29PM +0800, Kefeng Wang wrote:
> -static struct page *page_idle_get_page(unsigned long pfn)
> +static struct folio *folio_idle_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;

You've changed the semantics here, and I suspect will cause breakage
as a result. Before if you called page_idle_get_page() on a tail page,
you got a NULL pointer returned. Now you get the folio that contains
that tail page.

I think you have to continue to call pfn_to_online_page() and do
the conversion to folio manually in this function. By all means
convert this function to return the folio, but you need to take a
little more care.