public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"Liu, Yi L" <yi.l.liu@intel.com>
Subject: Re: [PATCH v2] vfio: Remove vfio_group dev_counter
Date: Tue, 23 Aug 2022 21:38:08 -0300	[thread overview]
Message-ID: <20220824003808.GE4090@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB5276323D5F9515E42CDBCDBD8C709@BN9PR11MB5276.namprd11.prod.outlook.com>

On Tue, Aug 23, 2022 at 01:31:11AM +0000, Tian, Kevin wrote:

> > In fact I do recall such discussions.  An IOMMU backed mdev (defunct)
> > or vfio-pci variant driver could gratuitously pin pages in order to
> > limit the dirty page scope.  We don't have anything in-tree that relies
> > on this.  It also seems we're heading more in the direction of device
> > level DMA dirty tracking as Yishai proposes in the series for mlx5.
> > These interfaces are far more efficient for this use case, but perhaps
> > you have another use case in mind where we couldn't use the dma_rw
> > interface?
> 
> One potential scenario is when I/O page fault is supported VFIO can
> enable on-demand paging in stage-2 mappings. In case a device cannot
> tolerate faults in all paths then a variant driver could use this interface
> to pin down structures which don't expect faults.

If this need arises, and I've had discussions about such things in the
past, it makes more sense to have a proper API to inhibit faulting of
a sub-range in what would have otherwise be a faultable iommu_domain.

Inhibiting faulting might be the same underlying code as pinning, but
I would prefer we don't co-mingle these very different concepts at the
device driver level.

> IMHO if functionally this function only works for emulated case then we
> should add code to detect and fail if it's called otherwise.

Today it only works correctly for the emulated case because only the
emulated case will be guarenteed to have a singleton group.

It *might* work for other cases, but not generally. In the general
case a physical device driver may be faced with multi-device groups
and it shouldn't fail.

So, I would prefer to comment it like this and if someone comes with a
driver that wants to use it in some other way they have to address
these problems so it works generally and correctly. I don't want to
write more code to protect against something that auditing tells us
doesn't happen today.

The whole thing should naturally become fixed fairly soon, as once we
have Yishai and Joao's changes there will be no use for the dirty
tracking code in type1 that is causing this problem.

Jason

  reply	other threads:[~2022-08-24  0:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 19:13 [PATCH v2] vfio: Remove vfio_group dev_counter Jason Gunthorpe
2022-08-22  4:39 ` Tian, Kevin
2022-08-22 18:35   ` Alex Williamson
2022-08-23  1:31     ` Tian, Kevin
2022-08-24  0:38       ` Jason Gunthorpe [this message]
2022-08-24 22:02         ` Alex Williamson
2022-08-25  0:43           ` Jason Gunthorpe
2022-09-06  9:21             ` Tian, Kevin
2022-09-06 13:59               ` Jason Gunthorpe
2022-08-29  2:02         ` Tian, Kevin
2022-09-02 18:42 ` Alex Williamson

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=20220824003808.GE4090@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=yi.l.liu@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox