From: Jason Gunthorpe <jgg@nvidia.com>
To: Tony Krowiak <akrowiak@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
borntraeger@de.ibm.com, cohuck@redhat.com,
pasic@linux.vnet.ibm.com, jjherne@linux.ibm.com,
alex.williamson@redhat.com, kwankhede@nvidia.com,
frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com,
hca@linux.ibm.com
Subject: Re: [PATCH] s390/vfio-ap: do not use open locks during VFIO_GROUP_NOTIFY_SET_KVM notification
Date: Mon, 28 Jun 2021 15:22:48 -0300 [thread overview]
Message-ID: <20210628182248.GH4459@nvidia.com> (raw)
In-Reply-To: <cc14f238-ba11-e388-06ec-027912fc313c@linux.ibm.com>
On Mon, Jun 28, 2021 at 02:20:55PM -0400, Tony Krowiak wrote:
>
>
> On 6/28/21 1:34 PM, Jason Gunthorpe wrote:
> > On Fri, Jun 25, 2021 at 06:07:58PM -0400, Tony Krowiak wrote:
> > > static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev)
> > > {
> > > + mutex_lock(&matrix_dev->lock);
> > > + if ((matrix_mdev->kvm) && (matrix_mdev->kvm->arch.crypto.crycbd)) {
> > > mutex_unlock(&matrix_dev->lock);
> > > + down_write(&matrix_mdev->kvm->arch.crypto.pqap_hook_rwsem);
> > > + matrix_mdev->kvm->arch.crypto.pqap_hook = NULL;
> > > + up_write(&matrix_mdev->kvm->arch.crypto.pqap_hook_rwsem);
> > > + kvm_arch_crypto_clear_masks(matrix_mdev->kvm);
> > > mutex_lock(&matrix_dev->lock);
> > > vfio_ap_mdev_reset_queues(matrix_mdev->mdev);
> > > kvm_put_kvm(matrix_mdev->kvm);
> > > matrix_mdev->kvm = NULL;
> > > + mutex_unlock(&matrix_dev->lock);
> > > }
> > Doesn't a flow exit the function with matrix_dev->lock held he
>
> How can that happen? What flow?
When the if isn't taken
> > Write it with 'success oriented flow'
>
> I'm not sure what you mean, can you clarify this statement?
Basically, don't write the bulk of the function under an if statement
mutex_lock(&matrix_dev->lock);
if (!matrix_mdev->kvm || !matrix_mdev->kvm->arch.crypto.crycbd) {
mutex_unlock(&matrix_dev->lock);
return;
}
Jason
next prev parent reply other threads:[~2021-06-28 18:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 22:07 [PATCH] s390/vfio-ap: do not use open locks during VFIO_GROUP_NOTIFY_SET_KVM notification Tony Krowiak
2021-06-28 17:34 ` Jason Gunthorpe
2021-06-28 18:20 ` Tony Krowiak
2021-06-28 18:22 ` Jason Gunthorpe [this message]
2021-06-28 18:27 ` Tony Krowiak
2021-06-28 20:29 ` Halil Pasic
2021-06-30 14:31 ` Tony Krowiak
2021-06-30 22:39 ` Halil Pasic
2021-07-01 14:28 ` Tony Krowiak
2021-07-05 14:13 ` Jason Gunthorpe
2021-07-06 13:39 ` Tony Krowiak
2021-07-06 13:49 ` Jason Gunthorpe
2021-07-06 22:43 ` Tony Krowiak
2021-06-29 13:21 ` Jason J. Herne
2021-06-30 11:55 ` Jason Gunthorpe
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=20210628182248.GH4459@nvidia.com \
--to=jgg@nvidia.com \
--cc=akrowiak@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=kwankhede@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.vnet.ibm.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