[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250704082130.11804-1-lizhe.67@bytedance.com>
Date: Fri, 4 Jul 2025 16:21:30 +0800
From: lizhe.67@...edance.com
To: david@...hat.com
Cc: akpm@...ux-foundation.org,
alex.williamson@...hat.com,
jgg@...pe.ca,
kvm@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
lizhe.67@...edance.com,
peterx@...hat.com
Subject: Re: [PATCH v2 1/5] mm: introduce num_pages_contiguous()
On Fri, 4 Jul 2025 09:56:23 +0200, david@...hat.com wrote:
> On 04.07.25 08:25, lizhe.67@...edance.com wrote:
> > From: Li Zhe <lizhe.67@...edance.com>
> >
> > Function num_pages_contiguous() determine the number of contiguous
> > pages starting from the first page in the given array of page pointers.
> > VFIO will utilize this interface to accelerate the VFIO DMA map process.
> >
> > Suggested-by: David Hildenbrand <david@...hat.com>
>
> I think Jason suggested having this as a helper as well.
Yes, thank you for the reminder. Jason needs to be added here.
Suggested-by: Jason Gunthorpe <jgg@...pe.ca>
> > Signed-off-by: Li Zhe <lizhe.67@...edance.com>
> > ---
> > include/linux/mm.h | 20 ++++++++++++++++++++
> > 1 file changed, 20 insertions(+)
> >
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index 0ef2ba0c667a..1d26203d1ced 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -205,6 +205,26 @@ extern unsigned long sysctl_admin_reserve_kbytes;
> > #define folio_page_idx(folio, p) ((p) - &(folio)->page)
> > #endif
> >
> > +/*
> > + * num_pages_contiguous() - determine the number of contiguous pages
> > + * starting from the first page.
>
> Maybe clarify here here:
>
> "Pages are contiguous if they represent contiguous PFNs. Depending on
> the memory model, this can mean that the addresses of the "struct page"s
> are not contiguous."
Thank you. I will include this clarification in the comment.
> > + *
> > + * @pages: an array of page pointers
> > + * @nr_pages: length of the array
> > + */
> > +static inline unsigned long num_pages_contiguous(struct page **pages,
> > + unsigned long nr_pages)
> > +{
> > + struct page *first_page = pages[0];
> > + unsigned long i;
> > +
> > + for (i = 1; i < nr_pages; i++)
> > + if (pages[i] != nth_page(first_page, i))
>
> if (pages[i] != nth_page(pages[0], i))
>
> Should be clear as well, so no need for the temporary "first_page" variable.
Thank you. Doing so makes the function appear much clearer.
> Apart from that LGTM.
Thank you for your review!
Thanks,
Zhe
Powered by blists - more mailing lists