Re: [RFC v1] io_uring/rsrc: add fast path huge page handling in buffer registration
From: David Hildenbrand (Arm)
Date: Tue Jun 09 2026 - 14:37:32 EST
> +struct page **io_pin_pages_fast_path(unsigned long uaddr, unsigned long len, int *npages)
> +{
> + unsigned long nr_pages;
> + struct page **pages;
> + int ret;
> +
> + pages = io_pin_pages_alloc(uaddr, len, &nr_pages);
> + if (IS_ERR(pages))
> + return pages;
> +
> + ret = pin_user_pages_fast(uaddr, nr_pages, FOLL_WRITE | FOLL_LONGTERM,
> + pages);
> + /* success, mapped all pages */
> + if (ret == nr_pages) {
> + struct folio *folio = page_folio(pages[0]);
> +
> + if (nr_pages > 1 && folio_test_hugetlb(folio) &&
> + page_folio(pages[nr_pages - 1]) == folio) {
I really don't like arbitrary GUP users to starting to special case hugetlb
folios, and making assumptions of how other pages they pinned look like (IOW,
how the page table mappings actually looked like).
Ideally, we'd have a pin_user_pages_fast() variant that would give you a list of
folio ranges instead of individual pages.
Seeing GUP users open-coded that (and special-casing on hugetlb) is a warning sign.
Assume we have a PMD-mapped (or even pte-mapped) THP, we would want the exact
same performance speedup. GUP knows that stuff belongs to the same folio, just
needs to communicate that information back in a better way.
So a no from my side.
--
Cheers,
David