[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250702182759.GD904431@ziepe.ca>
Date: Wed, 2 Jul 2025 15:27:59 -0300
From: Jason Gunthorpe <jgg@...pe.ca>
To: lizhe.67@...edance.com
Cc: alex.williamson@...hat.com, david@...hat.com, peterx@...hat.com,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/4] vfio/type1: batch vfio_find_vpfn() in function
vfio_unpin_pages_remote()
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?
Jason
Powered by blists - more mailing lists