public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Yi Liu <yi.l.liu@intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>, <kvm@vger.kernel.org>
Subject: Re: [PATCH] vfio: Remove vfio_group dev_counter
Date: Tue, 16 Aug 2022 23:12:56 +0800	[thread overview]
Message-ID: <75f8fd2f-c298-b0d7-e2c2-7bee192afaca@intel.com> (raw)
In-Reply-To: <YvuNxRhOynTDJV4D@nvidia.com>

On 2022/8/16 20:29, Jason Gunthorpe wrote:
> On Tue, Aug 16, 2022 at 09:21:05AM +0800, Yi Liu wrote:
>> Hi Jason,
>>
>> On 2022/8/16 00:50, Jason Gunthorpe wrote:
>>> This counts the number of devices attached to a vfio_group, ie the number
>>> of items in the group->device_list.
>>
>> yes. This dev_counter is added to ensure only singleton vfio group supports
>> pin page. Although I don't think it is a good approach as it only counts the
>> registered devices.
> 
> Ah, I missed explaining this, lets try again:
> 
> vfio: Remove vfio_group dev_counter
> 
> This counts the number of devices attached to a vfio_group, ie the number
> of items in the group->device_list.
> 
> It has two purposes
>   - To ensure the vfio_device is opened

hmmm, surely vfio_pin_pages() needs to ensure vfio_device is opened.
But it's not the purpose of adding dev_counter. So I guess this line
can be removed. :)

>   - To assert the group is singleton because the dirty tracking code in the
>     type1 iommu has limitations
> 
> However, vfio_pin_pages() already calls vfio_assert_device_open() so the
> first is taken care of, and all callers of vfio_pin_pages() use now use
> vfio_register_emulated_iommu_dev() which guarentees single groups by
> constrution.
> 
> So delete dev_counter and leave a note that vfio_pin_pages() can only be
> used with vfio_register_emulated_iommu_dev().

oh, yes. The fake group is allocated in vfio_register_emulated_iommu_dev().
So the group is surely singleton. Maybe for simple just say
vfio_register_emulated_iommu_dev() guarantees the group is singleton, and
vfio_pin_pages() can only be used with vfio_register_emulated_iommu_dev().
So no need to use dev_counter in vfio_pin_pages(). Such commit message may
be more accurate and no unnecessary distraction. :-) btw. The change looks
good to me.

Reviewed-by: Yi Liu <yi.l.liu@intel.com>

-- 
Regards,
Yi Liu

  reply	other threads:[~2022-08-16 15:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 16:50 [PATCH] vfio: Remove vfio_group dev_counter Jason Gunthorpe
2022-08-16  1:21 ` Yi Liu
2022-08-16 12:29   ` Jason Gunthorpe
2022-08-16 15:12     ` Yi Liu [this message]
2022-08-18  7:46 ` Tian, Kevin
2022-08-18  8:12   ` Yi Liu
2022-08-18  8:19     ` Tian, Kevin

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=75f8fd2f-c298-b0d7-e2c2-7bee192afaca@intel.com \
    --to=yi.l.liu@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=jgg@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox