From: Jason Gunthorpe <jgg@nvidia.com>
To: lizhe.67@bytedance.com
Cc: alex.williamson@redhat.com, david@redhat.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
peterx@redhat.com
Subject: Re: [PATCH 2/4] vfio/type1: batch vfio_find_vpfn() in function vfio_unpin_pages_remote()
Date: Thu, 3 Jul 2025 09:27:56 -0300 [thread overview]
Message-ID: <20250703122756.GB1209783@nvidia.com> (raw)
In-Reply-To: <20250703041822.37063-1-lizhe.67@bytedance.com>
On Thu, Jul 03, 2025 at 12:18:22PM +0800, lizhe.67@bytedance.com wrote:
> On Wed, 2 Jul 2025 15:27:59 -0300, jgg@ziepe.ca wrote:
>
> > On Mon, Jun 30, 2025 at 03:25:16PM +0800, lizhe.67@bytedance.com wrote:
> > > From: Li Zhe <lizhe.67@bytedance.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@bytedance.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
Jason
next prev parent reply other threads:[~2025-07-03 12:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 7:25 [PATCH 0/4] vfio/type1: optimize vfio_pin_pages_remote() and vfio_unpin_pages_remote() for large folio lizhe.67
2025-06-30 7:25 ` [PATCH 1/4] vfio/type1: optimize vfio_pin_pages_remote() for large folios lizhe.67
2025-06-30 7:25 ` [PATCH 2/4] vfio/type1: batch vfio_find_vpfn() in function vfio_unpin_pages_remote() lizhe.67
2025-07-02 18:27 ` Jason Gunthorpe
2025-07-03 4:18 ` lizhe.67
2025-07-03 12:27 ` Jason Gunthorpe [this message]
2025-07-04 2:20 ` lizhe.67
2025-06-30 7:25 ` [PATCH 3/4] vfio/type1: introduce a new member has_rsvd for struct vfio_dma lizhe.67
2025-07-01 15:13 ` Dan Carpenter
2025-07-02 3:47 ` lizhe.67
2025-07-02 16:11 ` Dan Carpenter
2025-06-30 7:25 ` [PATCH 4/4] vfio/type1: optimize vfio_unpin_pages_remote() for large folio lizhe.67
2025-07-02 18:28 ` Jason Gunthorpe
2025-07-03 6:12 ` lizhe.67
2025-07-02 8:15 ` [PATCH 0/4] vfio/type1: optimize vfio_pin_pages_remote() and " David Hildenbrand
2025-07-02 9:38 ` lizhe.67
2025-07-02 9:57 ` David Hildenbrand
2025-07-02 12:47 ` Jason Gunthorpe
2025-07-03 4:04 ` lizhe.67
2025-07-03 3:54 ` lizhe.67
2025-07-03 11:06 ` David Hildenbrand
2025-07-03 11:12 ` Jason Gunthorpe
2025-07-03 11:35 ` lizhe.67
2025-07-03 11:34 ` lizhe.67
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250703122756.GB1209783@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=david@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhe.67@bytedance.com \
--cc=peterx@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.