Re: [PATCH v2] mm/memfd_luo: don't use memfd_pin_folios()

From: Pasha Tatashin

Date: Tue Nov 03 2026 - 15:55:26 EST


On Tue, 03 Nov 2026 18:22:50 +0100, Pratyush Yadav wrote:
> memfd_luo takes a snapshot of the folios in the file's mapping. To make
> sure the snapshot does not go out of sync, it pins the folios in the
> file via memfd_pin_folios(). The pinning also migrates the folios out of
> MIGRATE_MOVABLE to make sure doesn't land in KHO boot memory or in a CMA
> region.
>
> memfd_pin_folios() does not lock the folios. So it can race with
> shmem_writeout(). A folio returned by memfd_pin_folios() might already
> be in swap cache. This happens to work but is fragile. memfd_luo looks
> at folio flags and index on a folio that isn't in the memfd's page
> cache.
>
> [...]

Applied, thanks!

https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux.git/log/?h=next

[1/1] mm/memfd_luo: don't use memfd_pin_folios()
commit: 9d07522bf59b3eb4b89b3a791a780a30884bfb5a

Best regards,
--
Pasha