Re: [RFC 05/12] kvm/vfio: Accept vfio device file from userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 06, 2023 at 10:46:56PM +0800, Yi Liu wrote:
> On 2023/1/6 22:32, Jason Gunthorpe wrote:
> > On Mon, Dec 19, 2022 at 12:47:11AM -0800, Yi Liu wrote:
> > > This defines KVM_DEV_VFIO_FILE* and make alias with KVM_DEV_VFIO_GROUP*.
> > > Old userspace uses KVM_DEV_VFIO_GROUP* works as well.
> > 
> > Do we have a circular refcount problem with this plan?
> > 
> > The kvm will hold a ref on the vfio device struct file
> > 
> > Once the vfio device struct file reaches open_device we will hold a
> > ref on the kvm
> > 
> > At this point if both kvm and vfio device FDs are closed will the
> > kernel clean it up or does it leak because they both ref each other?
> 
> looks to be a circular. In my past test, seems no apparent issue. But
> I'll do a test to confirm it. If this is a problem, it should be an
> existing issue. right? Should have same issue with group file.

The group is probably fine since the device struct file will not have
any reference it will close which will release the kvm and then the
group.

> > Please test to confirm..
> 
> will do.

Probably kvm needs to put back the VFIO file reference when its own
struct file closes, not when when the kvm->users_count reaches 0.

This will allow the VFIO device file to close and drop the users_count

Jason



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux