From: Alex Williamson <alex.williamson@redhat.com>
To: avi@redhat.com, mst@redhat.com
Cc: gleb@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v10 1/2] kvm: Provide pre-locked setup to irq ack notifier
Date: Mon, 17 Sep 2012 21:16:20 -0600 [thread overview]
Message-ID: <20120918031617.12021.22195.stgit@bling.home> (raw)
In-Reply-To: <20120918031156.12021.27838.stgit@bling.home>
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 <alex.williamson@redhat.com>
---
include/linux/kvm_host.h | 4 ++++
virt/kvm/irq_comm.c | 18 ++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
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();
}
next prev parent reply other threads:[~2012-09-18 3:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-18 3:16 [PATCH v10 0/2] kvm: level irqfd support Alex Williamson
2012-09-18 3:16 ` Alex Williamson [this message]
2012-09-18 3:16 ` [PATCH v10 2/2] kvm: Add resampling irqfds for level triggered interrupts Alex Williamson
2012-09-18 23:29 ` Michael S. Tsirkin
2012-09-19 8:59 ` Avi Kivity
2012-09-19 9:08 ` Michael S. Tsirkin
2012-09-19 9:10 ` Avi Kivity
2012-09-19 13:54 ` Alex Williamson
2012-09-19 14:35 ` Avi Kivity
2012-09-19 18:23 ` Alex Williamson
2012-09-19 18:48 ` Michael S. Tsirkin
2012-09-19 19:23 ` Alex Williamson
2012-09-19 19:59 ` Michael S. Tsirkin
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=20120918031617.12021.22195.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@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
all inboxes | Powered by JetHome®