[PATCH 1/3] mm/memfd_luo: don't use memfd_pin_folios()
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Oct 28 10:31:17 PDT 2026
> From: "Pratyush Yadav (Google)" <pratyush at kernel.org>
>
> 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.
>
> In addition, memfd_pin_folios() needs the caller to allocate an array of
> [ ... ]
> | THP, 32 GiB | 4.83 ms | 5.21 ms | +8% |
> | sparse, 32 GiB | 8695 ms | 7269 ms | -16% |
> |------------------+----------+------------+-------|
>
> Signed-off-by: Pratyush Yadav (Google) <pratyush at kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027173031.763213-1-pratyush@kernel.org?part=1
More information about the kexec
mailing list