Re: [PATCH v2 1/3] mm: khugepaged: fix swap entry value to folio_pfn()
From: Lorenzo Stoakes (ARM)
Date: Mon Aug 17 2026 - 12:25:46 EST
On Mon, Aug 17, 2026 at 06:19:16PM +0200, David Hildenbrand (Arm) wrote:
>
> > I mean maybe better to just reduce this to something like:
> >
> > /* folio is NULL unless exited early. */
> > trace_mm_khugepaged_scan_file(mm,
> > (!folio || xa_is_value(folio)) ? -1 : folio_pfn(folio),
> > file, present, swap, result);
> >
> > As the least invasive way of fixing the trace + limiting the contageon?
>
> I raised that using a folio after dropping relevant refs+locks is in general an
> anti-pattern (IOW wrong if folios can just get split afterwards and are suddenly
> no longer folios).
>
> I'd like us to avoid that where possible (and suspect Willy will thank us later ;) )
>
> Isn't there some minimal way to just calculate the pfn once we obtain a folio? I
> was assuming that there should be an easier way to do that.
See my reply-to-self. My initial reply was wrong because parisc + mips do
actually do classic sparsemem (sigh).
I suggest what you're saying here basically.
(Moving folio_put()'s for the break cases out of the loop is nasty)
>
> --
> Cheers,
>
> David
--
Cheers, Lorenzo