KVM: Intelligent device lookup on I/O bus
authorSasha Levin <levinsasha928@gmail.com>
Wed, 27 Jul 2011 13:00:48 +0000 (16:00 +0300)
committerAvi Kivity <avi@redhat.com>
Sun, 25 Sep 2011 16:17:59 +0000 (19:17 +0300)
commit743eeb0b01d2fbf4154bf87bff1ebb6fb18aeb7a
tree5392464930f7e77131d65f32ba96ce4665307629
parent0d460ffc0956d2dbe12ca9f5f6aa0f8701ea9d73
KVM: Intelligent device lookup on I/O bus

Currently the method of dealing with an IO operation on a bus (PIO/MMIO)
is to call the read or write callback for each device registered
on the bus until we find a device which handles it.

Since the number of devices on a bus can be significant due to ioeventfds
and coalesced MMIO zones, this leads to a lot of overhead on each IO
operation.

Instead of registering devices, we now register ranges which points to
a device. Lookup is done using an efficient bsearch instead of a linear
search.

Performance test was conducted by comparing exit count per second with
200 ioeventfds created on one byte and the guest is trying to access a
different byte continuously (triggering usermode exits).
Before the patch the guest has achieved 259k exits per second, after the
patch the guest does 274k exits per second.

Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/i8254.c
arch/x86/kvm/i8259.c
arch/x86/kvm/irq.h
arch/x86/kvm/x86.c
include/linux/kvm_host.h
virt/kvm/coalesced_mmio.c
virt/kvm/eventfd.c
virt/kvm/ioapic.c
virt/kvm/kvm_main.c