public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Greg KH <gregkh@linuxfoundation.org>, "Christopherson,,
	Sean" <seanjc@google.com>,
	"Bradescu, Roxana" <roxabee@google.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/2] kvm/vfio: avoid bouncing the mutex when adding and deleting groups
Date: Tue, 18 Jul 2023 23:10:39 -0700	[thread overview]
Message-ID: <ZLd+X7Zcnlq52Tp+@google.com> (raw)
In-Reply-To: <BN9PR11MB5276BCE644231C440053AA118C39A@BN9PR11MB5276.namprd11.prod.outlook.com>

On Wed, Jul 19, 2023 at 05:32:27AM +0000, Tian, Kevin wrote:
> > From: Dmitry Torokhov <dmitry.torokhov@gmail.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.

Thanks.

-- 
Dmitry

  reply	other threads:[~2023-07-19  6:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14 22:45 [PATCH v3 1/2] kvm/vfio: ensure kvg instance stays around in kvm_vfio_group_add() Dmitry Torokhov
2023-07-14 22:45 ` [PATCH v3 2/2] kvm/vfio: avoid bouncing the mutex when adding and deleting groups Dmitry Torokhov
2023-07-19  5:32   ` Tian, Kevin
2023-07-19  6:10     ` Dmitry Torokhov [this message]
2023-07-20  2:36       ` Tian, Kevin
2023-07-20 17:10         ` Dmitry Torokhov
2023-07-19  5:33 ` [PATCH v3 1/2] kvm/vfio: ensure kvg instance stays around in kvm_vfio_group_add() Tian, Kevin
2023-07-26 18:11 ` Alex Williamson
2023-08-03 19:38 ` Alex Williamson
2023-08-03 22:36   ` Dmitry Torokhov

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=ZLd+X7Zcnlq52Tp+@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=roxabee@google.com \
    --cc=seanjc@google.com \
    /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