From: Alex Williamson <alex.williamson@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
jbaron@redhat.com, jan.kiszka@siemens.com
Subject: Re: [PATCH] kvm: lock slots_lock around device assignment
Date: Wed, 18 Apr 2012 20:58:24 -0600 [thread overview]
Message-ID: <1334804304.3112.243.camel@bling.home> (raw)
In-Reply-To: <20120419023008.GB17648@amt.cnet>
On Wed, 2012-04-18 at 23:30 -0300, Marcelo Tosatti wrote:
> On Tue, Apr 17, 2012 at 09:46:44PM -0600, Alex Williamson wrote:
> > @@ -340,7 +343,11 @@ int kvm_iommu_unmap_guest(struct kvm *kvm)
> > if (!domain)
> > return 0;
> >
> > + mutex_lock(&kvm->slots_lock);
> > kvm_iommu_unmap_memslots(kvm);
> > + kvm->arch.iommu_domain = NULL;
> > + mutex_unlock(&kvm->slots_lock);
> > +
> > iommu_domain_free(domain);
> > return 0;
> > }
>
> This might trigger lockdep warnings due to
>
> kvm_vm_ioctl_create_vcpu
> mutex_lock(&kvm->lock)
> kvm_put_kvm(kvm)
> kvm_destroy_vm
> kvm_iommu_unmap_guest
>
> sequence.
>
> Better drop it, it is not necessary in vm destruction
> path (since only user is self).
I actually ran this with lockdep and didn't generate a warning;
hopefully I had it configured correctly. Also, we'll soon be unmapping
the guest any time we remove the last assigned device so this will no
longer be a vm destruction-only path. We can just as easily race adding
new mappings or removing already removed ones on that path. We also
acquire kvm->lock in the mapping path:
kvm_vm_ioctl_assign_device() {
mutex_lock(&kvm->lock);
if (!kvm->arch.iommu_domain) {
r = kvm_iommu_map_guest(kvm);
which by inspection and the lock ordering note in kvm_main seems to be
ok. Thanks,
Alex
next prev parent reply other threads:[~2012-04-19 2:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-18 3:46 [PATCH] kvm: lock slots_lock around device assignment Alex Williamson
2012-04-19 2:30 ` Marcelo Tosatti
2012-04-19 2:58 ` Alex Williamson [this message]
2012-04-19 3:04 ` Marcelo Tosatti
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=1334804304.3112.243.camel@bling.home \
--to=alex.williamson@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=jbaron@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.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