lkml.org 
[lkml]   [2022]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] vfio: Use filp instead of fd
Date
Hi,

Why kvm_vfio_group_add use file?

struct file *filp;
......
filp = fget(fd);
......
fput(filp);



>--------
> send: Al Viro <viro@ftp.linux.org.uk> 代表 Al Viro
> 发送时间: 2022年9月27日 3:38
>to: Jason Gunthorpe <jgg@nvidia.com>
> pbonzini@redhat.com; kvm@vger.kernel.org; linux-kernel@vger.kernel.org
> sub: Re: [PATCH] vfio: Use filp instead of fd
>
> On Mon, Sep 26, 2022 at 02:07:43PM -0300, Jason Gunthorpe wrote:
> > On Mon, Sep 26, 2022 at 02:54:07AM -0400, Deming Wang wrote:
> > > The function of kvm_vfio_group_set_spapr_tce and kvm_vfio_group_del
> > > use fd indirectly.But,it only be used for fd.file. So,we can
> > > directly use the struct of file instead.
> > >
> > > Signed-off-by: Deming Wang <wangdeming@inspur.com>
> > > ---
> > > virt/kvm/vfio.c | 24 ++++++++++++------------
> > > 1 file changed, 12 insertions(+), 12 deletions(-)
> >
> > I thought about changing this too when I was looking at this.
> > fdget/fdput includes a tiny micro-optimization that is legal here,
> > however I doubt anyone cares about performance on this path.
>
> Microoptimization or not, I'd rather keep fget() limited to cases where we
> really need it. There are non-trivial cases and having them easy to find
is a
> good thing.
>
> Again, the preferred way to do descriptor lookups is fdget() family, not
fget()
> one.
[unhandled content-type:application/pkcs7-signature]
\
 
 \ /
  Last update: 2022-09-27 03:26    [W:0.030 / U:0.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site