Re: [PATCH v3 5/9] mm/gup: limit pagecache folio refcount when grabbing references
From: Pedro Falcato
Date: Thu Nov 12 2026 - 08:21:08 EST
On Tue, Nov 10, 2026 at 09:35:45PM +0100, David Hildenbrand (Arm) wrote:
> Let's add a folio_ref_count_over_limit() check in fast and slow GUP
> before acquiring additional references or pins.
>
> Keep it simple and use the check for all folio types.
>
> Also propagate try_grab_folio() errors when grabbing additional
> references in __get_user_pages() and in memfd_pin_folios(), so hitting
> the limit returns -ENOMEM instead of -EFAULT and -EINVAL, respectively.
>
> Keep the existing invalid-refcount warnings.
>
> Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
> Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
> Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
> Cc: stable@xxxxxxxxxxxxxxx
> Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Same points about funny weird inefficiency applies, in any case:
Reviewed-by: Pedro Falcato <pfalcato@xxxxxxx>
--
Pedro