From patchwork Tue Sep 18 03:16:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 1470341 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3864E3FE65 for ; Tue, 18 Sep 2012 03:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932717Ab2IRDQX (ORCPT ); Mon, 17 Sep 2012 23:16:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49855 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932623Ab2IRDQV (ORCPT ); Mon, 17 Sep 2012 23:16:21 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8I3GL3F004257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Sep 2012 23:16:21 -0400 Received: from bling.home (ovpn-113-153.phx2.redhat.com [10.3.113.153]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8I3GK7f031192; Mon, 17 Sep 2012 23:16:20 -0400 From: Alex Williamson Subject: [PATCH v10 1/2] kvm: Provide pre-locked setup to irq ack notifier To: avi@redhat.com, mst@redhat.com Cc: gleb@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 17 Sep 2012 21:16:20 -0600 Message-ID: <20120918031617.12021.22195.stgit@bling.home> In-Reply-To: <20120918031156.12021.27838.stgit@bling.home> References: <20120918031156.12021.27838.stgit@bling.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This enables better integration into irqfd setup where we can adjust our lock ordering to hold irq_lock, making these callable and avoiding irq source ID races. Signed-off-by: Alex Williamson --- include/linux/kvm_host.h | 4 ++++ virt/kvm/irq_comm.c | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index b70b48b..84f6950 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -628,8 +628,12 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level); int kvm_set_msi(struct kvm_kernel_irq_routing_entry *irq_entry, struct kvm *kvm, int irq_source_id, int level); void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin); +void __kvm_register_irq_ack_notifier(struct kvm *kvm, + struct kvm_irq_ack_notifier *kian); void kvm_register_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian); +void __kvm_unregister_irq_ack_notifier(struct kvm *kvm, + struct kvm_irq_ack_notifier *kian); void kvm_unregister_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian); int kvm_request_irq_source_id(struct kvm *kvm); diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 83402d7..dd0cbf6 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -191,19 +191,33 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) rcu_read_unlock(); } +/* hold kvm->irq_lock */ +void __kvm_register_irq_ack_notifier(struct kvm *kvm, + struct kvm_irq_ack_notifier *kian) +{ + hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list); +} + void kvm_register_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian) { mutex_lock(&kvm->irq_lock); - hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list); + __kvm_register_irq_ack_notifier(kvm, kian); mutex_unlock(&kvm->irq_lock); } +/* hold kvm->irq_lock and wait for rcu grace period */ +void __kvm_unregister_irq_ack_notifier(struct kvm *kvm, + struct kvm_irq_ack_notifier *kian) +{ + hlist_del_init_rcu(&kian->link); +} + void kvm_unregister_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian) { mutex_lock(&kvm->irq_lock); - hlist_del_init_rcu(&kian->link); + __kvm_unregister_irq_ack_notifier(kvm, kian); mutex_unlock(&kvm->irq_lock); synchronize_rcu(); }