kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] make interrupt injection lockless (almost)
@ 2009-08-09 12:41 Gleb Natapov
  2009-08-09 12:41 ` [PATCH 01/10] Change irq routing table to use gsi indexed array Gleb Natapov
                   ` (9 more replies)
  0 siblings, 10 replies; 37+ messages in thread
From: Gleb Natapov @ 2009-08-09 12:41 UTC (permalink / raw)
  To: avi; +Cc: kvm

kvm->irq_lock protects too much stuff, but still fail to protect
everything it was design to protect (see ack notifiers call in pic). I
want to make IRQ injection fast path as lockless as possible. This patch
series split kvm->irq_lock mutex to smaller spinlocks each one protects
only one thing. Irq routing, irq notifier lists and ioapic gain their own
spinlock.  Pic is already has its own lock. This patch series also makes
interrupt injection to lapic lockless (several kvm_irq_delivery_to_apic()
may run in parallel), but access to lapic was never fully locked in the
first place. VCPU could access lapic in parallel with interrupt injection.
Patch 1 changes irq routing data structure to much more efficient one.
Patch 10 introduce API that allows to send MSI message without going
through irq routing table. This allows us, among other thing, to limit irq
routing table to a small number of entries.

Gleb Natapov (10):
  Change irq routing table to use gsi indexed array.
  Move irq routing data structure to rcu locking
  Move irq ack notifier list to arch independent code.
  Convert irq notifiers lists to RCU locking.
  Protect irq_sources_bitmap by kvm->lock instead of kvm->irq_lock
  Move irq routing to its own locking.
  Move irq notifiers lists to its own locking.
  Move IO APIC to its own lock.
  Drop kvm->irq_lock lock.
  Introduce MSI message sending interface that bypass IRQ routing.

 arch/ia64/include/asm/kvm_host.h |    1 -
 arch/ia64/kvm/kvm-ia64.c         |   55 +++++++++--
 arch/x86/include/asm/kvm_host.h  |    3 +-
 arch/x86/kvm/i8254.c             |    4 +-
 arch/x86/kvm/i8259.c             |    8 +-
 arch/x86/kvm/lapic.c             |    7 +-
 arch/x86/kvm/x86.c               |   58 +++++++++---
 include/linux/kvm.h              |   10 ++-
 include/linux/kvm_host.h         |   21 +++-
 virt/kvm/eventfd.c               |    2 -
 virt/kvm/ioapic.c                |   53 +++++++----
 virt/kvm/ioapic.h                |    4 +-
 virt/kvm/irq_comm.c              |  196 +++++++++++++++++++++----------------
 virt/kvm/kvm_main.c              |   11 +-
 14 files changed, 277 insertions(+), 156 deletions(-)


^ permalink raw reply	[flat|nested] 37+ messages in thread
* [PATCH 0/10] [RFC] more fine grained locking for IRQ injection
@ 2009-07-14 14:30 Gleb Natapov
  2009-07-14 14:30 ` [PATCH 08/10] Move IO APIC to its own lock Gleb Natapov
  0 siblings, 1 reply; 37+ messages in thread
From: Gleb Natapov @ 2009-07-14 14:30 UTC (permalink / raw)
  To: kvm; +Cc: mtosatti

kvm->irq_lock protects too much stuff, but still fail to protect
everything it was design to protect (see ack notifiers call in pic). I
want to make IRQ injection logic use more fine grained locking. This patch
series split kvm->irq_lock mutex to smaller spinlocks each one protects
only one thing. Irq routing, irq notifier lists and ioapic gain their own
spinlock.  pic is already uses its own lock. This patch series also makes
interrupt injection to lapic lockless (several kvm_irq_delivery_to_apic()
may run in parallel), but access to lapic was never fully locked in the
first place. VCPU could access lapic in parallel with interrupt injection.

This patch series is exactly like previous two combined + one more patch
that changes irq_routing to use gsi indexed array to map from gsi to irq
chip. But now the patch series comes with numbers. Here is oprofile data
of one WindowsXP boot with two cpus generated by the command
 "opreport -l | grep kvm | awk '{print $1" "$5}' | grep irq"

Master:                              With patches:
996 kvm_set_irq                      412 __apic_accept_irq
502 __apic_accept_irq		     298 kvm_set_irq
250 kvm_irq_delivery_to_apic	     228 kvm_irq_delivery_to_api
162 kvm_ioapic_set_irq		     178 kvm_ioapic_set_irq
162 kvm_pic_set_irq		     137 enable_irq_window
95 kvm_apic_set_irq		     122 kvm_pic_set_irq
82 kvm_set_pic_irq		     71 kvm_apic_set_irq
77 enable_irq_window		     55 pic_get_irq
60 vmx_inject_irq		     48 vmx_inject_irq
52 pic_get_irq			     44 kvm_set_ioapic_irq
49 kvm_set_ioapic_irq		     42 kvm_set_pic_irq
48 pic_update_irq		     42 pic_update_irq
40 pic_irq_request		     17 kvm_notify_acked_irq
37 kvm_notify_acked_irq		     17 pic_irq_request
				     1 kvm_inject_pit_timer_irqs

And the same with the patchset + small userspace hack (remove pic from
irq routing table when guest stops use it):
418 __apic_accept_irq
242 kvm_irq_delivery_to_apic
212 kvm_set_irq
112 kvm_ioapic_set_irq
98 enable_irq_window
81 kvm_apic_set_irq
72 vmx_inject_irq
60 kvm_pic_set_irq
30 kvm_set_ioapic_irq
20 pic_get_irq
12 pic_update_irq
11 kvm_set_pic_irq
10 pic_irq_request
7 kvm_notify_acked_irq

Gleb Natapov (9):
  Unregister ack notifier callback on PIT freeing.
  Move irq ack notifier list to arch independent code.
  Convert irq notifiers lists to RCU locking.
  Protect irq_sources_bitmap by kvm->lock instead of kvm->irq_lock
  Move irq routing to its own locking.
  Move irq notifiers lists to its own locking.
  Move IO APIC to its own lock.
  Drop kvm->irq_lock lock.
  Change irq routing table to use gsi indexed array.

 arch/ia64/include/asm/kvm_host.h |    1 -
 arch/ia64/kvm/kvm-ia64.c         |   29 +++++++---
 arch/x86/include/asm/kvm_host.h  |    1 -
 arch/x86/kvm/i8254.c             |    6 +-
 arch/x86/kvm/lapic.c             |    7 +--
 arch/x86/kvm/x86.c               |   32 +++++++----
 include/linux/kvm_host.h         |   15 ++++-
 virt/kvm/eventfd.c               |    2 -
 virt/kvm/ioapic.c                |   50 ++++++++++------
 virt/kvm/ioapic.h                |    1 +
 virt/kvm/irq_comm.c              |  117 +++++++++++++++++++++-----------------
 virt/kvm/kvm_main.c              |    8 +-
 12 files changed, 157 insertions(+), 112 deletions(-)


^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2009-08-09 15:16 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
  -- strict thread matches above, loose matches on Subject: below --
2009-07-14 14:30 [PATCH 0/10] [RFC] more fine grained locking for IRQ injection Gleb Natapov
2009-07-14 14:30 ` [PATCH 08/10] Move IO APIC to its own lock Gleb Natapov
2009-07-15 17:57   ` Marcelo Tosatti
2009-07-15 20:48     ` Gleb Natapov
2009-07-15 21:38       ` Marcelo Tosatti
2009-07-16  7:51         ` Gleb Natapov
2009-07-16 18:09           ` Marcelo Tosatti
2009-07-16 20:49             ` Gleb Natapov
2009-07-17 15:19               ` Marcelo Tosatti
2009-07-17 17:32                 ` Gleb Natapov
2009-07-17 20:09                   ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).