From patchwork Wed Dec 15 16:45:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 413891 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBFGjb6q002252 for ; Wed, 15 Dec 2010 16:45:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751364Ab0LOQpf (ORCPT ); Wed, 15 Dec 2010 11:45:35 -0500 Received: from mail-ew0-f45.google.com ([209.85.215.45]:32814 "EHLO mail-ew0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751237Ab0LOQpe (ORCPT ); Wed, 15 Dec 2010 11:45:34 -0500 Received: by ewy10 with SMTP id 10so1360625ewy.4 for ; Wed, 15 Dec 2010 08:45:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=oDS6/75SWoGLzN3XBtDlp9sOfQL8WEI1T9KvsFbzUFg=; b=t2rRHJJYrRYOw2zX7AWlKOKLZP2VlFYwLGIYApDNoqt8enDjOlc8rxrAex00VEGg7l AupR9vA34g9MtuwSuN6FDZA4oDE8NSjAb80iTQt4kBw6Kpwlwqh0+pa79LR9oNe/qswI 6XY41m5Cr+GRJde2/Fu5UB1GkwIijExI8dG+4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=U0gs4GATFXoIU/EuAQlJKT3y7Mpb2AiUijYqwidOjVZRDYb+TRO/HQMDQC2STILgmE h53mCHoLeyDZ121L+Np4U4IN7cJAlDYjLM8dkzMiz7ts8y3bAHJTM/OYhJfL8Q7XGS6R NT+LVaqE85WiNnvt3PhtgiskE+2DKJ+VjrI70= Received: by 10.223.113.131 with SMTP id a3mr1489952faq.135.1292431532794; Wed, 15 Dec 2010 08:45:32 -0800 (PST) Received: from amd (x097031.dynamic.ppp.asahi-net.or.jp [122.249.97.31]) by mx.google.com with ESMTPS id n7sm522835fam.35.2010.12.15.08.45.29 (version=SSLv3 cipher=RC4-MD5); Wed, 15 Dec 2010 08:45:32 -0800 (PST) Date: Thu, 16 Dec 2010 01:45:27 +0900 From: Takuya Yoshikawa 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 Message-Id: <20101216014527.9e5b1aa6.takuya.yoshikawa@gmail.com> In-Reply-To: <20101216013917.a8a8bab9.takuya.yoshikawa@gmail.com> References: <20101216013917.a8a8bab9.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.1.0beta2 (GTK+ 2.22.0; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 15 Dec 2010 16:45:39 +0000 (UTC) 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();