Re: [PATCH 03/32] mm/shmem: reject userfaultfd fills during hole punch
From: Jose A. Perez de Azpillaga
Date: Sun Nov 29 2026 - 14:47:17 EST
On 11/29/26 11:06 AM, David Hildenbrand (Arm) wrote:
> While punching a shmem/tmpfs hole, regular page faults in the range wait
> for the hole punch to finish, but UFFDIO_COPY, UFFDIO_ZEROPAGE and
> UFFDIO_CONTINUE keep mapping pages into it. The hole punch must then
> repeatedly walk the file's VMAs to unmap these pages, while holding
> i_rwsem.
>
> Consequently, punching a hole can become very slow if userfaultfd keeps
> filling the range, blocking other writers. Any user that can read the
> file can trigger that through a MAP_PRIVATE mapping and UFFDIO_CONTINUE.
>
> Let's fix it by making UFFDIO_COPY, UFFDIO_ZEROPAGE and UFFDIO_CONTINUE
> return -EAGAIN when faults in the range are blocked, so user space can
> retry, instead of waiting in the uffd code.
>
the -EAGAIN approach looks good to me.
[snip]
> +/* Disallow placing folios while hole-punch or a pin scan is in progress. */
> +static bool __shmem_faults_blocked(struct inode *inode, pgoff_t pgoff)
to me this reads weird. I would drop the pin scan part, since only the
hole punch sets ->waitq.
otherwise LGTM:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
--
cheers,
jose a. p-a