Re: [PATCH 0/4] vfio/type1: optimize vfio_pin_pages_remote() and vfio_unpin_pages_remote() for large folio

From: Jason Gunthorpe
Date: Thu Jul 03 2025 - 07:12:28 EST


On Thu, Jul 03, 2025 at 01:06:26PM +0200, David Hildenbrand wrote:
> > +{
> > + struct page *first_page = pages[0];
> > + unsigned long i;
> > +
> > + for (i = 1; i < size; i++)
> > + if (pages[i] != nth_page(first_page, i))
> > + break;
> > + return i;
> > +}
>
> LGTM.
>
> I wonder if we can find a better function name, especially when moving this
> to some header where it can be reused.

It should be a common function:

unsigned long num_pages_contiguous(struct page *list, size_t nelms);

Jason