From: Avi Kivity <avi@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 01/10] Change irq routing table to use gsi indexed array.
Date: Sun, 09 Aug 2009 17:25:19 +0300 [thread overview]
Message-ID: <4A7EDC4F.6000104@redhat.com> (raw)
In-Reply-To: <1249821671-32356-2-git-send-email-gleb@redhat.com>
On 08/09/2009 03:41 PM, Gleb Natapov wrote:
> Use gsi indexed array instead of scanning all entries on each interrupt
> injection. Also maintain back mapping from irqchip/pin to gsi to speedup
> interrupt acknowledgment notifications.
>
> Signed-off-by: Gleb Natapov<gleb@redhat.com>
> ---
> include/linux/kvm_host.h | 11 +++++-
> virt/kvm/irq_comm.c | 87 ++++++++++++++++++++++++---------------------
> virt/kvm/kvm_main.c | 1 -
> 3 files changed, 55 insertions(+), 44 deletions(-)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index f814512..a38f576 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -129,7 +129,14 @@ struct kvm_kernel_irq_routing_entry {
> } irqchip;
> struct msi_msg msi;
> };
> - struct list_head link;
> + struct hlist_node link;
> +};
> +
> +struct kvm_irq_routing_table {
> + int chip[3][KVM_IOAPIC_NUM_PINS];
> + struct kvm_kernel_irq_routing_entry *rt_entries;
> + u32 max_gsi;
>
That's the table size, no? so call it nr_rt_entries to reflect that
(max_* implies an off-by-one).
> + struct hlist_head map[0];
> };
>
What's this? (comment explaining the type of data).
>
> struct kvm {
> @@ -167,7 +174,7 @@ struct kvm {
>
> struct mutex irq_lock;
> #ifdef CONFIG_HAVE_KVM_IRQCHIP
> - struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */
>
Like here.
> @@ -150,8 +152,9 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level)
> * IOAPIC. So set the bit in both. The guest will ignore
> * writes to the unused one.
> */
> - list_for_each_entry(e,&kvm->irq_routing, link)
> - if (e->gsi == irq) {
> + irq_rt = kvm->irq_routing;
> + if (irq< irq_rt->max_gsi)
>
irq here is int, so can overflow. I think all paths are protected, but
better to change irq to unsigned just in case.
> + hlist_for_each_entry(e, n,&irq_rt->map[irq], link) {
> int r = e->set(e, kvm, sig_level);
> if (r< 0)
> continue;
> @@ -163,20 +166,15 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level)
>
> void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
> {
> - struct kvm_kernel_irq_routing_entry *e;
> struct kvm_irq_ack_notifier *kian;
> struct hlist_node *n;
> - unsigned gsi = pin;
> + unsigned gsi;
>
> trace_kvm_ack_irq(irqchip, pin);
>
> - list_for_each_entry(e,&kvm->irq_routing, link)
> - if (e->type == KVM_IRQ_ROUTING_IRQCHIP&&
> - e->irqchip.irqchip == irqchip&&
> - e->irqchip.pin == pin) {
> - gsi = e->gsi;
> - break;
> - }
> + gsi = kvm->irq_routing->chip[irqchip][pin];
> + if (gsi == -1)
> + gsi = pin;
>
Please separate the reverse map to a separate patch.
> + new = kzalloc(sizeof(*new) + (max_gsi * sizeof(struct hlist_head)) +
> + (nr * sizeof(struct kvm_kernel_irq_routing_entry)),
> + GFP_KERNEL);
>
Wow.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2009-08-09 14:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-09 12:41 [PATCH 00/10] make interrupt injection lockless (almost) Gleb Natapov
2009-08-09 12:41 ` [PATCH 01/10] Change irq routing table to use gsi indexed array Gleb Natapov
2009-08-09 14:25 ` Avi Kivity [this message]
2009-08-09 12:41 ` [PATCH 02/10] Move irq routing data structure to rcu locking Gleb Natapov
2009-08-09 12:41 ` [PATCH 03/10] Move irq ack notifier list to arch independent code Gleb Natapov
2009-08-09 12:41 ` [PATCH 04/10] Convert irq notifiers lists to RCU locking Gleb Natapov
2009-08-09 12:41 ` [PATCH 05/10] Protect irq_sources_bitmap by kvm->lock instead of kvm->irq_lock Gleb Natapov
2009-08-09 12:41 ` [PATCH 06/10] Move irq routing to its own locking Gleb Natapov
2009-08-09 14:52 ` Avi Kivity
2009-08-09 12:41 ` [PATCH 07/10] Move irq notifiers lists " Gleb Natapov
2009-08-09 14:52 ` Avi Kivity
2009-08-09 14:49 ` Gleb Natapov
2009-08-09 14:57 ` Avi Kivity
2009-08-09 12:41 ` [PATCH 08/10] Move IO APIC to its own lock Gleb Natapov
2009-08-09 14:54 ` Avi Kivity
2009-08-09 14:57 ` Gleb Natapov
2009-08-09 15:10 ` Avi Kivity
2009-08-09 15:09 ` Gleb Natapov
2009-08-09 12:41 ` [PATCH 09/10] Drop kvm->irq_lock lock Gleb Natapov
2009-08-09 12:41 ` [PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing Gleb Natapov
2009-08-09 14:56 ` Avi Kivity
2009-08-09 14:52 ` Gleb Natapov
2009-08-09 15:01 ` Avi Kivity
2009-08-09 15:07 ` Gleb Natapov
2009-08-09 15:14 ` Avi Kivity
2009-08-09 15:14 ` Gleb Natapov
2009-08-09 15:22 ` Avi Kivity
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=4A7EDC4F.6000104@redhat.com \
--to=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.