From: Jason Gunthorpe <jgg@nvidia.com>
To: David Matlack <dmatlack@google.com>
Cc: Aaron Lewis <aaronlewis@google.com>,
kvm@vger.kernel.org, alex@shazbot.org
Subject: Re: [PATCH 1/2] vfio/type1: Periodically try rescheduling when unmapping
Date: Wed, 15 Jul 2026 15:12:20 -0300 [thread overview]
Message-ID: <20260715181220.GF3775915@nvidia.com> (raw)
In-Reply-To: <CALzav=ckyqekeXkhzyBc9tOEU-_Ukmgh30dcye-BWbaMnNa6vw@mail.gmail.com>
On Wed, Jul 15, 2026 at 10:39:01AM -0700, David Matlack wrote:
> On Tue, Jul 14, 2026 at 2:03 PM Aaron Lewis <aaronlewis@google.com> wrote:
>
> > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> > index c8151ba54de3..e78bc07d9b6e 100644
> > --- a/drivers/vfio/vfio_iommu_type1.c
> > +++ b/drivers/vfio/vfio_iommu_type1.c
> > @@ -1153,6 +1153,7 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,
> > int unmapped_region_cnt = 0;
> > long unlocked = 0;
> > size_t pos = 0;
> > + int i = 0;
> >
> > if (!dma->size)
> > return 0;
> > @@ -1196,6 +1197,8 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,
> > next = iommu_iova_to_phys(domain->domain, iova + len);
> > if (next != phys + len)
> > break;
> > + if ((++i % BIT(PUD_ORDER)) == 0)
> > + cond_resched();
> > }
>
> What is the performance impact on unmap if cond_resched() is called on
> every iteration of the loop? It would be nice to not have a magic
> heuristic (which is brittle as Sashiko points out).
Calling every loop is definately not a good idea.. Some magic number
is a pretty typical pattern for these CPU bound loops.
Jason
next prev parent reply other threads:[~2026-07-15 18:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 21:03 [PATCH 0/2] vfio/iommufd: Prevent scheduler warnings when unmapping large regions Aaron Lewis
2026-07-14 21:03 ` [PATCH 1/2] vfio/type1: Periodically try rescheduling when unmapping Aaron Lewis
2026-07-14 21:15 ` sashiko-bot
2026-07-15 17:39 ` David Matlack
2026-07-15 18:12 ` Jason Gunthorpe [this message]
2026-07-14 21:03 ` [PATCH 2/2] iommufd: Periodically reschedule " Aaron Lewis
2026-07-14 21:34 ` sashiko-bot
2026-07-15 18:11 ` [PATCH 0/2] vfio/iommufd: Prevent scheduler warnings when unmapping large regions Jason Gunthorpe
2026-07-15 22:07 ` Aaron Lewis
2026-07-16 13:20 ` Jason Gunthorpe
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=20260715181220.GF3775915@nvidia.com \
--to=jgg@nvidia.com \
--cc=aaronlewis@google.com \
--cc=alex@shazbot.org \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
/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.