mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tony Krowiak <akrowiak@linux.ibm.com>
To: Halil Pasic <pasic@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, jgg@nvidia.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: Wed, 30 Jun 2021 10:31:22 -0400	[thread overview]
Message-ID: <25edecce-0795-3b00-a155-bfcc8499f1be@linux.ibm.com> (raw)
In-Reply-To: <20210628222923.21a257c8.pasic@linux.ibm.com>



On 6/28/21 4:29 PM, Halil Pasic wrote:
> On Fri, 25 Jun 2021 18:07:58 -0400
> Tony Krowiak <akrowiak@linux.ibm.com> wrote:
>
> What is a suitable base for this patch. I've tried the usual suspects,
> but none of them worked.

I discovered what the problem is here. The patch is based on our
master branch along with the two pre-requisite patches that were
recently reviewed and are currently being merged. The two patches
of which I speak are:
* [PATCH v6 1/2] s390/vfio-ap: clean up mdev resources when remove 
callback invoked
    Message ID: <20210621155714.1198545-2-akrowiak@linux.ibm.com>

* [PATCH v6 2/2] s390/vfio-ap: r/w lock for PQAP interception handler 
function pointer
    <20210621155714.1198545-3-akrowiak@linux.ibm.com>

I probably should have included those along with this one.

>
>> The fix to resolve a lockdep splat while handling the
>> VFIO_GROUP_NOTIFY_SET_KVM event introduced a kvm_busy flag indicating that
>> the vfio_ap device driver is busy setting or unsetting the KVM pointer.
>> A wait queue was employed to allow functions requiring access to the KVM
>> pointer to wait for the kvm_busy flag to be cleared. For the duration of
>> the wait period, the mdev lock was unlocked then acquired again after the
>> kvm_busy flag was cleared. This got rid of the lockdep report, but didn't
>> really resolve the problem.
> Can you please elaborate on the last point. You mean that we can have
> circular locking even after 0cc00c8d4050, but instead of getting stuck in
> on a lock we will get stuck on wait_event_cmd()? If that is it, please
> state it clearly in the description, and if you can to it in the short
> description.

This patch was in response to the following review comments made by Jason
Gunthorpe:

* Message ID: <20210525162927.GC1002214@nvidia.com>
    "... the kvm_busy should be replaced by a proper rwsem,
     don't try to open code locks like that - it just defeats lockdep
     analysis".

* Message ID: <20210527112433.GX1002214@nvidia.com>
    "Usually when people start open coding locks it is often
    because lockdep complained. Open coding a lock makes
    lockdep stop because the lockdep code
    is removed, but it doesn't fix anything. The kvm_busy
    should be replaced by a proper rwsem, don't try to
    open code locks like that - it just defeats lockdep
    analysis."

I will paraphrase and include the information from Jason's
comments in the description.

>> This patch removes the the kvm_busy flag and wait queue as they are not
>> necessary to resolve the lockdep splat problem. The wait queue was
>> introduced to prevent changes to the matrix used to update the guest's
>> AP configuration. The idea was that whenever an adapter, domain or control
>> domain was being assigned to or unassigned from the matrix, the function
>> would wait until the group notifier function was no longer busy with the
>> KVM pointer.
>>
>> The thing is, the KVM pointer value (matrix_mdev->kvm) is always set and
>> cleared while holding the matrix_dev->lock mutex. The assignment and
>> unassignment interfaces also lock the matrix_dev->lock mutex prior to
>> checking whether the matrix_mdev->kvm pointer is set and if so, returns
>> the -EBUSY error from the function. Consequently, there is no chance for
>> an update to the matrix to occur while the guest's AP configuration is
>> being updated.
>>
>> Fixes: 0cc00c8d4050 ("s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>


  reply	other threads:[~2021-06-30 14:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25 22:07 Tony Krowiak
2021-06-28 17:34 ` Jason Gunthorpe
2021-06-28 18:20   ` Tony Krowiak
2021-06-28 18:22     ` Jason Gunthorpe
2021-06-28 18:27       ` Tony Krowiak
2021-06-28 20:29 ` Halil Pasic
2021-06-30 14:31   ` Tony Krowiak [this message]
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=25edecce-0795-3b00-a155-bfcc8499f1be@linux.ibm.com \
    --to=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=jgg@nvidia.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.ibm.com \
    --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

Powered by JetHome