vfio/pci: Lazy PBA emulation
commit95239e162518dc6577164be3d9a789aba7f591a3
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 19 Jan 2016 18:33:42 +0000 (19 11:33 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 19 Jan 2016 18:33:42 +0000 (19 11:33 -0700)
tree357b84f217fbc385239e12863fe87eb514ceef2d
parentf5793fd9e1fd89808f4adbfe690235b094176a37
vfio/pci: Lazy PBA emulation

The PCI spec recommends devices use additional alignment for MSI-X
data structures to allow software to map them to separate processor
pages.  One advantage of doing this is that we can emulate those data
structures without a significant performance impact to the operation
of the device.  Some devices fail to implement that suggestion and
assigned device performance suffers.

One such case of this is a Mellanox MT27500 series, ConnectX-3 VF,
where the MSI-X vector table and PBA are aligned on separate 4K
pages.  If PBA emulation is enabled, performance suffers.  It's not
clear how much value we get from PBA emulation, but the solution here
is to only lazily enable the emulated PBA when a masked MSI-X vector
fires.  We then attempt to more aggresively disable the PBA memory
region any time a vector is unmasked.  The expectation is then that
a typical VM will run entirely with PBA emulation disabled, and only
when used is that emulation re-enabled.

Reported-by: Shyam Kaushik <shyam.kaushik@gmail.com>
Tested-by: Shyam Kaushik <shyam.kaushik@gmail.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/pci.c
hw/vfio/pci.h
trace-events