Re: [PATCH v2] hugetlb: simplify hugetlb handling in follow_page_mask

Mike Kravetz
2022-09-06T17:13:24Z

On 09/05/22 06:34, Christophe Leroy wrote:
>
>
> Le 02/09/2022 à 21:03, Mike Kravetz a écrit :
> > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> > index fe4944f89d34..275e554dd365 100644
> > --- a/include/linux/hugetlb.h
> > +++ b/include/linux/hugetlb.h
> > @@ -264,6 +255,13 @@ static inline void adjust_range_if_pmd_sharing_possible(
> > {
> > }
> >
> > +static inline struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma,
> > + unsigned long address, unsigned int flags)
> > +{
> > + WARN_ON_ONCE(1); /* should never be called if !CONFIG_HUGETLB_PAGE*/
> > + return ERR_PTR(-EINVAL);
>
> This function is called only when is_vm_hugetlb_page() is true.
>
> When !CONFIG_HUGETLB_PAGE is_vm_hugetlb_page() always returns false, so
> the call to hugetlb_follow_page_mask() should never be compiled in.
>
> Use BUILD_BUG() to catch it at buildtime.
>

Yes. My bad as David suggested this previously.
How about we just leave out the function in the !CONFIG_HUGETLB_PAGE case?
We will get build errors without the need for a BUILD_BUG().

> > +}
> > +
> > static inline long follow_hugetlb_page(struct mm_struct *mm,
> > struct vm_area_struct *vma, struct page **pages,
> > struct vm_area_struct **vmas, unsigned long *position,

--
Mike Kravetz