[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZLlqb8Hk0S3AkEsf@google.com>
Date: Thu, 20 Jul 2023 10:10:07 -0700
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: "Tian, Kevin" <kevin.tian@...el.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Alex Williamson <alex.williamson@...hat.com>,
Greg KH <gregkh@...uxfoundation.org>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"Bradescu, Roxana" <roxabee@...gle.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 2/2] kvm/vfio: avoid bouncing the mutex when adding
and deleting groups
On Thu, Jul 20, 2023 at 02:36:16AM +0000, Tian, Kevin wrote:
> > From: Dmitry Torokhov <dmitry.torokhov@...il.com>
> > Sent: Wednesday, July 19, 2023 2:11 PM
> >
> > On Wed, Jul 19, 2023 at 05:32:27AM +0000, Tian, Kevin wrote:
> > > > From: Dmitry Torokhov <dmitry.torokhov@...il.com>
> > > > Sent: Saturday, July 15, 2023 6:46 AM
> > > >
> > > > @@ -165,30 +161,26 @@ static int kvm_vfio_group_add(struct
> > kvm_device
> > > > *dev, unsigned int fd)
> > > > list_for_each_entry(kvg, &kv->group_list, node) {
> > > > if (kvg->file == filp) {
> > > > ret = -EEXIST;
> > > > - goto err_unlock;
> > > > + goto out_unlock;
> > > > }
> > > > }
> > > >
> > > > kvg = kzalloc(sizeof(*kvg), GFP_KERNEL_ACCOUNT);
> > > > if (!kvg) {
> > > > ret = -ENOMEM;
> > > > - goto err_unlock;
> > > > + goto out_unlock;
> > > > }
> > > >
> > > > - kvg->file = filp;
> > > > + kvg->file = get_file(filp);
> > >
> > > Why is another reference required here?
> >
> > Because the function now has a single exit point and the original
> > reference is dropped unconditionally on exit. It looks cleaner than
> > checking for non-zero "ret" and deciding whether the reference should be
> > dropped or kept.
> >
>
> A comment is appreciated. otherwise,
>
> Reviewed-by: Kevin Tian <kevin.tian@...el.com>
Thank you for the review! However I do not think any comment is needed,
if one is looking at the final source and not the patch form, the reason
for taking another reference is plain to see.
Thanks!
--
Dmitry
Powered by blists - more mailing lists