Re: [PATCH 1/6] mm/gup: move gup_can_follow_protnone() to gup.c
From: Mike Rapoport
Date: Tue Aug 25 2026 - 06:12:13 EST
On Mon, Aug 24, 2026 at 04:42:56PM +0200, David Hildenbrand (Arm) wrote:
> On 8/23/26 14:17, Mike Rapoport (Microsoft) wrote:
> > gup_can_follow_protnone() is defined in include/linux/mm.h but only used
> > by mm/gup.c.
> >
> > First, there is no reason to have it in already gigantic header.
>
> Once upon a time there was a user in mm/huge_memory.c, in a beautifully named
> function called follow_trans_huge_pmd().
>
> >
> > Next, the upcoming refactoring of userfaultfd flags will make
> > gup_can_follow_protnone() depend on userfaultfd_k.h which would cause a
> > cyclic header dependency.
> >
> > Move gup_can_follow_protnone() to mm/gup.c.
> >
> > No functional change.
> >
> > Assisted-by: copilot:claude-opus-5
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> > ---
>
>
> [...]
>
> > typedef int (*pte_fn_t)(pte_t *pte, unsigned long addr, void *data);
> > extern int apply_to_page_range(struct mm_struct *mm, unsigned long address,
> > unsigned long size, pte_fn_t fn, void *data);
> > diff --git a/mm/gup.c b/mm/gup.c
> > index eb898ea1ee22..500e2aa99e48 100644
> > --- a/mm/gup.c
> > +++ b/mm/gup.c
> > @@ -633,6 +633,44 @@ static struct page *no_page_table(struct vm_area_struct *vma,
> > return NULL;
> > }
> >
> > +/*
> > + * Indicates whether GUP can follow a PROT_NONE mapped page, or whether
> > + * a (NUMA hinting or userfaultfd RWP) fault is required.
> > + */
> > +static inline bool gup_can_follow_protnone(const struct vm_area_struct *vma,
> > + unsigned int flags)
>
> While at it, could switch to double-tab here.
Ok.
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>
> --
> Cheers,
>
> David
--
Sincerely yours,
Mike.