Re: [PATCH] mm/khugepaged: don't map folios that are not uptodate in MADV_COLLAPSE

From: Zach O'Keefe

Date: Thu Nov 05 2026 - 16:25:33 EST


On Thu, Nov 5, 2026 at 12:09 PM Zi Yan <ziy@xxxxxxxxxx> wrote:
>
> On Thu Nov 5, 2026 at 1:16 PM EST, David Hildenbrand (Arm) wrote:
> > madvise(MADV_COLLAPSE) can map PMD-sized pagecache folios that are not
> > uptodate. For example, shmem fallocate() can put such folios into the
> > page cache.
> >
> > collapse_file() already refuses to proceed with folios that are not
> > uptodate. Let's just do the same in try_collapse_pte_mapped_thp() and skip
> > such folios, leaving handling to the page faults.
> >
> > Note that collapse_file() effectively clears shmem folios through
> > shmem_get_folio(); let's keep this fix simple and simply let the page
> > fault path deal with that.
> >
> > Fixes: 34488399fa08 ("mm/madvise: add file and shmem support to MADV_COLLAPSE")
> > Reported-by: Chris Mason <mason@xxxxxxxxxx>
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> > ---
> > Once reviewed, I will pick this up in a timely manner.
> > ---
> > mm/khugepaged.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> Makes sense.
>
> Acked-by: Zi Yan <ziy@xxxxxxxxxx>

Ah, good catch..

Agree with Hugh that the "pte_mapped" naming is a bit of a misnomer,
though it was how I was thinking of things at the time.

Thanks David / Chris.

Reviewed-by: Zach O'Keefe <zokeefe@xxxxxxxxxx>


> --
> Best Regards,
> Yan, Zi
>