From: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
To: avi@redhat.com, mtosatti@redhat.com
Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp,
kvm-ia64@vger.kernel.org
Subject: [PATCH 3/3] KVM: Centralize irq_lock aquisition during KVM_CREATE_IRQCHIP
Date: Thu, 16 Dec 2010 01:45:27 +0900 [thread overview]
Message-ID: <20101216014527.9e5b1aa6.takuya.yoshikawa@gmail.com> (raw)
In-Reply-To: <20101216013917.a8a8bab9.takuya.yoshikawa@gmail.com>
From: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Move irq_lock aquisition from kvm_setup_default_irq_routing(), inside of
kvm_set_irq_routing(), to its caller.
This makes the lock management clearer, with a bit longer irq_lock section.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
---
arch/ia64/kvm/kvm-ia64.c | 2 ++
arch/x86/kvm/x86.c | 4 ++--
virt/kvm/irq_comm.c | 2 --
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 060c594..34a1699 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -951,7 +951,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
mutex_unlock(&kvm->slots_lock);
if (r)
goto out;
+ mutex_lock(&kvm->irq_lock);
r = kvm_setup_default_irq_routing(kvm);
+ mutex_unlock(&kvm->irq_lock);
if (r) {
mutex_lock(&kvm->slots_lock);
kvm_ioapic_destroy(kvm);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 736ab93..5c70869 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3319,13 +3319,13 @@ long kvm_arch_vm_ioctl(struct file *filp,
smp_wmb();
kvm->arch.vpic = vpic;
smp_wmb();
+ mutex_lock(&kvm->irq_lock);
r = kvm_setup_default_irq_routing(kvm);
if (r) {
- mutex_lock(&kvm->irq_lock);
kvm_ioapic_destroy(kvm);
kvm_destroy_pic(kvm);
- mutex_unlock(&kvm->irq_lock);
}
+ mutex_unlock(&kvm->irq_lock);
create_irqchip_unlock:
mutex_unlock(&kvm->slots_lock);
mutex_unlock(&kvm->lock);
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 9f614b4..265fd2f 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -407,10 +407,8 @@ int kvm_set_irq_routing(struct kvm *kvm,
++ue;
}
- mutex_lock(&kvm->irq_lock);
old = kvm->irq_routing;
kvm_irq_routing_update(kvm, new);
- mutex_unlock(&kvm->irq_lock);
synchronize_rcu();
--
1.7.1
prev parent reply other threads:[~2010-12-15 16:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-15 16:39 [PATCH-v2 0/3] KVM: Take missing slots_lock for kvm_io_bus_unregister_dev() Takuya Yoshikawa
2010-12-15 16:41 ` [PATCH 1/3] " Takuya Yoshikawa
2010-12-16 9:12 ` Avi Kivity
2010-12-15 16:43 ` [PATCH 2/3] KVM: Centralize slots_lock aquisition during KVM_CREATE_IRQCHIP Takuya Yoshikawa
2010-12-16 9:11 ` Avi Kivity
2010-12-16 9:29 ` Takuya Yoshikawa
2010-12-16 9:34 ` Avi Kivity
2010-12-16 9:47 ` Takuya Yoshikawa
2010-12-16 9:55 ` Avi Kivity
2010-12-16 12:51 ` Takuya Yoshikawa
2010-12-15 16:45 ` Takuya Yoshikawa [this message]
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=20101216014527.9e5b1aa6.takuya.yoshikawa@gmail.com \
--to=takuya.yoshikawa@gmail.com \
--cc=avi@redhat.com \
--cc=kvm-ia64@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=yoshikawa.takuya@oss.ntt.co.jp \
/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