From: Jason Gunthorpe <jgg@nvidia.com>
To: Matthew Rosato <mjrosato@linux.ibm.com>
Cc: akrowiak@linux.ibm.com, jjherne@linux.ibm.com,
farman@linux.ibm.com, imbrenda@linux.ibm.com,
frankja@linux.ibm.com, pmorel@linux.ibm.com, david@redhat.com,
Sean Christopherson <seanjc@google.com>,
intel-gfx@lists.freedesktop.org, cohuck@redhat.com,
linux-kernel@vger.kernel.org, pasic@linux.ibm.com,
kvm@vger.kernel.org, pbonzini@redhat.com,
linux-s390@vger.kernel.org, borntraeger@linux.ibm.com,
intel-gvt-dev@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 1/2] KVM: async kvm_destroy_vm for vfio devices
Date: Thu, 12 Jan 2023 13:27:41 -0400 [thread overview]
Message-ID: <Y8BDDQi9W86UfszF@nvidia.com> (raw)
In-Reply-To: <f7c39317-92a4-520e-8e69-a8606cd40e9a@linux.ibm.com>
On Thu, Jan 12, 2023 at 12:21:17PM -0500, Matthew Rosato wrote:
> So should I work up a v2 that does symbol gets for kvm_get_kvm_safe
> and kvm_put_kvm from vfio_main and drop kvm_put_kvm_async? Or is
> the patch Yi is working on changing things such that will also
> address the deadlock issue?
I don't think Yi's part will help
> +361,22 @@ static int vfio_device_first_open(struct vfio_device
> *device, if (ret) goto err_module_put;
>
> + if (kvm && !vfio_kvm_get(kvm)) {
Do call it kvm_get_safe though
> + ret = -ENOENT;
> + goto err_unuse_iommu;
> + }
> device->kvm = kvm;
> if (device->ops->open_device) {
> ret = device->ops->open_device(device);
> if (ret)
> - goto err_unuse_iommu;
> + goto err_put_kvm;
> }
> return 0;
>
> -err_unuse_iommu:
> +err_put_kvm:
> + vfio_put_kvm(kvm);
> device->kvm = NULL;
> +err_unuse_iommu:
> if (iommufd)
> vfio_iommufd_unbind(device);
> else
> @@ -465,6 +471,9 @@ static int vfio_device_fops_release(struct inode *inode, struct file *filep)
>
> vfio_device_group_close(device);
>
> + if (device->open_count == 0 && device->group->kvm)
> + vfio_kvm_put(device->group->kvm);
> +
No, you can't touch group->kvm without holding the group lock,
that is the whole point of the problem..
This has to be device->kvm
Jason
WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgg@nvidia.com>
To: Matthew Rosato <mjrosato@linux.ibm.com>
Cc: Sean Christopherson <seanjc@google.com>,
alex.williamson@redhat.com, pbonzini@redhat.com,
cohuck@redhat.com, farman@linux.ibm.com, pmorel@linux.ibm.com,
borntraeger@linux.ibm.com, frankja@linux.ibm.com,
imbrenda@linux.ibm.com, david@redhat.com, akrowiak@linux.ibm.com,
jjherne@linux.ibm.com, pasic@linux.ibm.com,
zhenyuw@linux.intel.com, zhi.a.wang@intel.com,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
intel-gvt-dev@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: async kvm_destroy_vm for vfio devices
Date: Thu, 12 Jan 2023 13:27:41 -0400 [thread overview]
Message-ID: <Y8BDDQi9W86UfszF@nvidia.com> (raw)
In-Reply-To: <f7c39317-92a4-520e-8e69-a8606cd40e9a@linux.ibm.com>
On Thu, Jan 12, 2023 at 12:21:17PM -0500, Matthew Rosato wrote:
> So should I work up a v2 that does symbol gets for kvm_get_kvm_safe
> and kvm_put_kvm from vfio_main and drop kvm_put_kvm_async? Or is
> the patch Yi is working on changing things such that will also
> address the deadlock issue?
I don't think Yi's part will help
> +361,22 @@ static int vfio_device_first_open(struct vfio_device
> *device, if (ret) goto err_module_put;
>
> + if (kvm && !vfio_kvm_get(kvm)) {
Do call it kvm_get_safe though
> + ret = -ENOENT;
> + goto err_unuse_iommu;
> + }
> device->kvm = kvm;
> if (device->ops->open_device) {
> ret = device->ops->open_device(device);
> if (ret)
> - goto err_unuse_iommu;
> + goto err_put_kvm;
> }
> return 0;
>
> -err_unuse_iommu:
> +err_put_kvm:
> + vfio_put_kvm(kvm);
> device->kvm = NULL;
> +err_unuse_iommu:
> if (iommufd)
> vfio_iommufd_unbind(device);
> else
> @@ -465,6 +471,9 @@ static int vfio_device_fops_release(struct inode *inode, struct file *filep)
>
> vfio_device_group_close(device);
>
> + if (device->open_count == 0 && device->group->kvm)
> + vfio_kvm_put(device->group->kvm);
> +
No, you can't touch group->kvm without holding the group lock,
that is the whole point of the problem..
This has to be device->kvm
Jason
next prev parent reply other threads:[~2023-01-12 17:27 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 20:10 [Intel-gfx] [PATCH 0/2] kvm/vfio: fix potential deadlock on vfio group lock Matthew Rosato
2023-01-09 20:10 ` Matthew Rosato
2023-01-09 20:10 ` [Intel-gfx] [PATCH 1/2] KVM: async kvm_destroy_vm for vfio devices Matthew Rosato
2023-01-09 20:10 ` Matthew Rosato
2023-01-09 20:13 ` [Intel-gfx] " Jason Gunthorpe
2023-01-09 20:13 ` Jason Gunthorpe
2023-01-09 20:24 ` [Intel-gfx] " Matthew Rosato
2023-01-09 20:24 ` Matthew Rosato
2023-01-09 21:07 ` [Intel-gfx] " Anthony Krowiak
2023-01-09 21:07 ` Anthony Krowiak
2023-01-11 19:54 ` [Intel-gfx] " Sean Christopherson
2023-01-11 19:54 ` Sean Christopherson
2023-01-11 20:05 ` [Intel-gfx] " Jason Gunthorpe
2023-01-11 20:05 ` Jason Gunthorpe
2023-01-11 20:53 ` [Intel-gfx] " Sean Christopherson
2023-01-11 20:53 ` Sean Christopherson
2023-01-12 12:45 ` [Intel-gfx] " Jason Gunthorpe
2023-01-12 12:45 ` Jason Gunthorpe
2023-01-12 17:21 ` [Intel-gfx] " Matthew Rosato
2023-01-12 17:21 ` Matthew Rosato
2023-01-12 17:27 ` Jason Gunthorpe [this message]
2023-01-12 17:27 ` Jason Gunthorpe
2023-01-09 20:10 ` [Intel-gfx] [PATCH 2/2] KVM: s390: pci: use asyncronous kvm put Matthew Rosato
2023-01-09 20:10 ` Matthew Rosato
2023-01-09 21:10 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for kvm/vfio: fix potential deadlock on vfio group lock Patchwork
2023-01-09 21:38 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-01-10 7:08 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-01-11 20:39 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for kvm/vfio: fix potential deadlock on vfio group lock (rev2) Patchwork
2023-01-11 21:09 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for kvm/vfio: fix potential deadlock on vfio group lock (rev3) Patchwork
2023-01-12 19:32 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for kvm/vfio: fix potential deadlock on vfio group lock (rev4) Patchwork
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=Y8BDDQi9W86UfszF@nvidia.com \
--to=jgg@nvidia.com \
--cc=akrowiak@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=farman@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jjherne@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=pmorel@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.