Skip to content

make interrupt injection lockless (almost)

Gleb Natapov kvm 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest8 patches 10 repliesIn review
  2. v28 patches 19 repliesSuperseded
  3. v110 patches 16 repliesSuperseded

Changes in v3 from the cover letter

Drop patch that changes irq_lock to spinlock.
Use mutex for ioapic lock.
Do not call ack notifier if there is no GSI mapping.
Call pic_clear_isr() after PIC state completely changed.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8Do not call ack notifiers on PIC reset.arch/x86/kvm/i8259.c+0 -162 replies
2/8Change irq routing table to use gsi indexed array.include/linux/kvm_host.h virt/kvm/irq_comm.c virt/kvm/kvm_main.c+55 -390 replies
3/8Maintain back mapping from irqchip/pin to gsi.arch/ia64/include/asm/kvm.h arch/x86/include/asm/kvm.h include/linux/kvm_host.h +1 more+17 -171 reply
4/8Move irq routing data structure to rcu lockingvirt/kvm/irq_comm.c+11 -50 replies
5/8Move irq ack notifier list to arch independent code.arch/ia64/include/asm/kvm_host.h arch/x86/include/asm/kvm_host.h include/linux/kvm_host.h +2 more+4 -50 replies
6/8Convert irq notifiers lists to RCU locking.virt/kvm/irq_comm.c+12 -100 replies
7/8Move IO APIC to its own lock.arch/ia64/kvm/kvm-ia64.c arch/x86/kvm/i8259.c arch/x86/kvm/lapic.c +3 more+86 -426 replies
8/8Drop kvm->irq_lock lock from irq injection path.arch/ia64/kvm/kvm-ia64.c arch/x86/kvm/i8254.c arch/x86/kvm/lapic.c +4 more+1 -170 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/8] make interrupt injection lockless (almost)

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 removes kvm->irq_lock from irq injection path effectively making 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. Patches 1/2 changes irq routing data structure to much more efficient one.

v1->v2:
Drop MSI injection interface (for now).
Use irq_lock to protect irq routing and ack notifiers. Splitting irq routing table changes to two patches (+ comments addressed). Drop ioapic/pic lock before calling ack notifiers.
v2->v3
Drop patch that changes irq_lock to spinlock.
Use mutex for ioapic lock.
Do not call ack notifier if there is no GSI mapping.
Call pic_clear_isr() after PIC state completely changed.

Gleb Natapov (8):
Do not call ack notifiers on PIC reset. Change irq routing table to use gsi indexed array. Maintain back mapping from irqchip/pin to gsi. Move irq routing data structure to rcu locking Move irq ack notifier list to arch independent code. Convert irq notifiers lists to RCU locking. Move IO APIC to its own lock.
Drop kvm->irq_lock lock from irq injection path.

 arch/ia64/include/asm/kvm.h      |    1 +
 arch/ia64/include/asm/kvm_host.h |    1 -
 arch/ia64/kvm/kvm-ia64.c         |    9 +--
 arch/x86/include/asm/kvm.h       |    1 +
 arch/x86/include/asm/kvm_host.h  |    1 -
 arch/x86/kvm/i8254.c             |    2 -
 arch/x86/kvm/i8259.c             |   38 +++++-------
 arch/x86/kvm/lapic.c             |    7 +--
 arch/x86/kvm/x86.c               |   12 +---
 include/linux/kvm_host.h         |   18 +++++-
 virt/kvm/eventfd.c               |    2 -
 virt/kvm/ioapic.c                |   80 ++++++++++++++++++------
 virt/kvm/ioapic.h                |    4 +
 virt/kvm/irq_comm.c              |  127 ++++++++++++++++++++------------------
 virt/kvm/kvm_main.c              |    4 +-
 15 files changed, 171 insertions(+), 136 deletions(-)