[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250704022024.14481-1-lizhe.67@bytedance.com>
Date: Fri, 4 Jul 2025 10:20:24 +0800
From: lizhe.67@...edance.com
To: jgg@...dia.com
Cc: alex.williamson@...hat.com,
david@...hat.com,
kvm@...r.kernel.org,
linux-kernel@...r.kernel.org,
lizhe.67@...edance.com,
peterx@...hat.com
Subject: Re: [PATCH 2/4] vfio/type1: batch vfio_find_vpfn() in function vfio_unpin_pages_remote()
On Thu, 3 Jul 2025 09:27:56 -0300, jgg@...dia.com wrote:
> On Thu, Jul 03, 2025 at 12:18:22PM +0800, lizhe.67@...edance.com wrote:
> > On Wed, 2 Jul 2025 15:27:59 -0300, jgg@...pe.ca wrote:
> >
> > > On Mon, Jun 30, 2025 at 03:25:16PM +0800, lizhe.67@...edance.com wrote:
> > > > From: Li Zhe <lizhe.67@...edance.com>
> > > >
> > > > The function vpfn_pages() can help us determine the number of vpfn
> > > > nodes on the vpfn rb tree within a specified range. This allows us
> > > > to avoid searching for each vpfn individually in the function
> > > > vfio_unpin_pages_remote(). This patch batches the vfio_find_vpfn()
> > > > calls in function vfio_unpin_pages_remote().
> > > >
> > > > Signed-off-by: Li Zhe <lizhe.67@...edance.com>
> > > > ---
> > > > drivers/vfio/vfio_iommu_type1.c | 10 +++-------
> > > > 1 file changed, 3 insertions(+), 7 deletions(-)
> > > >
> > > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> > > > index a2d7abd4f2c2..330fff4fe96d 100644
> > > > --- a/drivers/vfio/vfio_iommu_type1.c
> > > > +++ b/drivers/vfio/vfio_iommu_type1.c
> > > > @@ -804,16 +804,12 @@ static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
> > > > unsigned long pfn, unsigned long npage,
> > > > bool do_accounting)
> > > > {
> > > > - long unlocked = 0, locked = 0;
> > > > + long unlocked = 0, locked = vpfn_pages(dma, iova, npage);
> > > > long i;
> > >
> > > The logic in vpfn_pages?() doesn't seem quite right? Don't we want to
> > > count the number of pages within the range that fall within the rb
> > > tree?
> > >
> > > vpfn_pages() looks like it is only counting the number of RB tree
> > > nodes within the range?
> >
> > As I understand it, a vfio_pfn corresponds to a single page, am I right?
>
> It does look that way, it is not what I was expecting iommufd holds
> ranges for this job..
>
> So this is OK then
Thank you. It seems that we have reached a consensus on all the comments.
I will send out a v2 patchset soon.
Thanks,
Zhe
Powered by blists - more mailing lists