Skip to contentSkip to conversation

VFIO: PCI: eliminate unnecessary overhead in vfio_pci_reflck_find

PATCH linmiaohe 1 participant 1 message Nov 6, 2019 KVM

lore
Share & tools
lore

linmiaohe

author
#0 lore raw

On Wed, 6 Nov 2019 03:25
Alex Williamson wrote

Quoted 9 lines
Quoted 8 lines

From: Miaohe Lin <[email protected]>

The driver of the pci device may not equal to vfio_pci_driver, but we fetch vfio_device from pci_dev unconditionally in func vfio_pci_reflck_find. This overhead, such as the competition of vfio.group_lock, can be eliminated by check pci_dev_driver with vfio_pci_driver first.

Quoted 3 lines

I believe this introduces a race. When we hold a reference to the vfio device, an unbind from a vfio bus driver will be blocked in vfio_del_group_dev(). Therefore if we test the driver is vfio-pci while holding this reference, we know that it cannot be released and the device_data is a valid vfio_pci_device. Testing the driver prior to acquiring a vfio device reference is meaningless as we have no guarantee that the driver has not changed by the time we acquire a reference. Are you actually seeing contention here or was this a code inspection optimization? Thanks,

Alex

Thanks for your reply and patient explanation. It was a code inspection optimization, and obviously, I missed something. I'm really sorry about that.

Best wishes.
Have a nice day.