Re: [PATCH v2 19/37] mm/gup: remove record_subpages()

David Hildenbrand
2025-09-06T07:03:12Z

> pmdp = pmd_offset_lockless(pudp, pud, addr);
> @@ -3046,23 +3041,21 @@ static int gup_fast_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr,
>
> next = pmd_addr_end(addr, end);
> if (!pmd_present(pmd))
> - return 0;
> + break;
>
> - if (unlikely(pmd_leaf(pmd))) {
> - /* See gup_fast_pte_range() */
> - if (pmd_protnone(pmd))
> - return 0;
> + if (unlikely(pmd_leaf(pmd)))
> + cur_nr_pages = gup_fast_pmd_leaf(pmd, pmdp, addr, next, flags, pages);
> + else
> + cur_nr_pages = gup_fast_pte_range(pmd, pmdp, addr, next, flags, pages);
>
> - if (!gup_fast_pmd_leaf(pmd, pmdp, addr, next, flags,
> - pages, nr))
> - return 0;
> + nr_pages += cur_nr_pages;
> + pages += cur_nr_pages;
>
> - } else if (!gup_fast_pte_range(pmd, pmdp, addr, next, flags,
> - pages, nr))
> - return 0;
> + if (nr_pages != (next - addr) >> PAGE_SIZE)
> + break;

^ cur_nr_pages. Open for suggestions on how to make that thing here even
better.

--
Cheers

David / dhildenb