On 8/29/25 13:07, Mark Cave-Ayland wrote:
On 15/07/2025 14:38, BALATON Zoltan wrote:

On Tue, 15 Jul 2025, Mark Cave-Ayland wrote:
Use QOM casts to convert between VFIOPCIDevice and PCIDevice instead of
accessing pdev directly.

Signed-off-by: Mark Cave-Ayland <[email protected]>
---
hw/vfio/pci.c | 202 ++++++++++++++++++++++++++++++--------------------
1 file changed, 120 insertions(+), 82 deletions(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 1093b28df7..fb9eb58da5 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -119,6 +119,7 @@ static void vfio_intx_mmap_enable(void *opaque)
static void vfio_intx_interrupt(void *opaque)
{
    VFIOPCIDevice *vdev = opaque;
+    PCIDevice *pdev = PCI_DEVICE(vdev);

Don't do that. Opaque data is already type checked when it is registered for 
the callback and cannot be changed so additional type checking here is just a 
performance hit without any advantage. It's OK to do it in less frequently 
called functions but don't add unnecessary casts to functions that can be 
called a lot.

In general the QOM casts fall into the noise in a standard profile, but I can 
see how it could be possible they might show up in the interrupt fast path.

I'll look at getting a vfio-pci perf test set up here to see if there is a 
noticeable effect in this case, and if so think about what the best approach is.

Booting with 'pci=nomsi' and running iperf should give some info
on INTx performance.

Thanks,

C.


Reply via email to