VFIO: PCI: eliminate unnecessary overhead in vfio_pci_reflck_find
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 fetchvfio_devicefrompci_devunconditionally in funcvfio_pci_reflck_find. This overhead, such as the competition of vfio.group_lock, can be eliminated by checkpci_dev_driverwithvfio_pci_driverfirst.
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 thedevice_datais a validvfio_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.