Re: [PATCH] s390/vfio-ap: do not use open locks during VFIO_GROUP_NOTIFY_SET_KVM notification

From: Jason Gunthorpe
Date: Wed Jun 30 2021 - 07:55:14 EST


On Tue, Jun 29, 2021 at 09:21:31AM -0400, Jason J. Herne wrote:

> > + mutex_lock(&matrix_dev->lock);
> > - if (matrix_mdev->kvm) {
> > - matrix_mdev->kvm_busy = true;
> > + if ((matrix_mdev->kvm) && (matrix_mdev->kvm->arch.crypto.crycbd)) {
> > mutex_unlock(&matrix_dev->lock);
>
>
> If this function cannot be entered concurrently on separate threads then I
> think we can remove this mutex_unlock of matrix_dev->lock,

Don't remove locking around data. If the data is written under a mutex
it should be read under a mutex too.

Jason