Re: [PATCH 3/7] mm/hugetlb: Add page_mask for hugetlb_follow_page_mask()

From: Peter Xu
Date: Tue Jun 20 2023 - 10:42:00 EST


On Tue, Jun 20, 2023 at 09:01:23AM +0200, David Hildenbrand wrote:
> On 19.06.23 23:43, Peter Xu wrote:
> > On Tue, Jun 13, 2023 at 05:53:42PM -0400, Peter Xu wrote:
> > > @@ -6506,6 +6507,7 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma,
> > > * because we hold the ptl lock and have verified pte_present().
> > > */
> > > WARN_ON_ONCE(try_grab_page(page, flags));
> > > + *page_mask = huge_page_mask(h);
> >
> > Sorry, I was wrong this line. It should be:
> >
> > *page_mask = ~huge_page_mask(h) >> PAGE_SHIFT;
> >
>
> That's ... surprising. It feels like either page_mask or huge_page_mask()
> has a misleading name ....
>
> h->mask = ~(huge_page_size(h) - 1);
>
>
> For PMDs, we do
>
> ctx->page_mask = HPAGE_PMD_NR - 1;
>
>
> Maybe
>
> *page_mask = PHYS_PFN(huge_page_size(h)) - 1;
>
> Would be clearer.

Since I just posted a new version.. I'll see whether I should get that
cleaned up in a new one.

>
> I guess "page_mask" should actually be "pfn_mask" ... but the meaning
> regarding PAGE_MASK are still inverted ...

Yes, pfn_mask can be at least slightly better. I can add a patch to rename
it, or we can also do it on top as cleanups.

Thanks,

--
Peter Xu