Re: [PATCH 03/10] kvm/vfio: Store the struct file in the kvm_vfio_group

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

 



On Fri, Apr 15, 2022 at 03:44:56AM +0000, Tian, Kevin wrote:
> > @@ -304,10 +309,10 @@ static int kvm_vfio_group_set_spapr_tce(struct
> > kvm_device *dev,
> >  		return -EBADF;
> > 
> >  	vfio_group = kvm_vfio_group_get_external_user(f.file);
> > -	fdput(f);
> > -
> > -	if (IS_ERR(vfio_group))
> > -		return PTR_ERR(vfio_group);
> > +	if (IS_ERR(vfio_group)) {
> > +		ret = PTR_ERR(vfio_group);
> > +		goto err_fdput;
> > +	}
> > 
> >  	grp = kvm_vfio_group_get_iommu_group(vfio_group);
> >  	if (WARN_ON_ONCE(!grp)) {
> 
> move above two external calls into below loop after file is
> matched...

Actually we can delete the kvm_vfio_group_get_external_user() since it
is the same as kvg->vfio_group and we no longer need the group to
match the kvg.

> > @@ -320,7 +325,7 @@ static int kvm_vfio_group_set_spapr_tce(struct
> > kvm_device *dev,
> >  	mutex_lock(&kv->lock);
> > 
> >  	list_for_each_entry(kvg, &kv->group_list, node) {
> > -		if (kvg->vfio_group != vfio_group)
> > +		if (kvg->filp != f.file)
> >  			continue;
> 
> ... here. Though they will be removed in later patch doing so at
> this patch is slightly more reasonable.

Sure, it is nicer

Thanks,
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