Re: [PATCH 2/9] mm/gup: break out gup_flush_pages() helper

From: David Hildenbrand (Arm)

Date: Thu Nov 26 2026 - 08:42:09 EST


On 11/23/26 20:56, Rik van Riel wrote:
> __get_user_pages() flushes each page's caches in an open-coded loop
> right after filling the array.
>
> Move it into a gup_flush_pages() helper.
>
> No functional changes intended.
>
> Suggested-by: David Hildenbrand <david@xxxxxxxxxx>
> Signed-off-by: Rik van Riel <riel@xxxxxxxxxxx>
> ---
> mm/gup.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index e0698d2075b4..d35fedbce7e1 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -729,6 +729,24 @@ static void gup_fill_pages(struct page **pages, struct page *page,
> pages[i] = page + i;
> }
>
> +/*
> + * Flush the caches for @nr_pages pages stored in @pages. The caller
> + * already holds folio references on the pages.
> + */

Again, drop all of these function comments.

> +static void gup_flush_pages(struct vm_area_struct *vma, unsigned long address,
> + struct page **pages, unsigned long nr_pages)
> +{
> + unsigned long i;
> +
> + if (!pages)
> + return;


Will this ever be called in this series on !pages?

If not, remove it.

Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>


--
Cheers,

David