kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/pci: Separate SR-IOV VF dev_set
@ 2025-06-26 22:56 Alex Williamson
  2025-06-30  6:32 ` Tian, Kevin
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Alex Williamson @ 2025-06-26 22:56 UTC (permalink / raw)
  To: alex.williamson, kvm
  Cc: aaronlewis, jgg, bhelgaas, dmatlack, vipinsh, seanjc, jrhilke,
	kevin.tian

In the below noted Fixes commit we introduced a reflck mutex to allow
better scaling between devices for open and close.  The reflck was
based on the hot reset granularity, device level for root bus devices
which cannot support hot reset or bus/slot reset otherwise.  Overlooked
in this were SR-IOV VFs, where there's also no bus reset option, but
the default for a non-root-bus, non-slot-based device is bus level
reflck granularity.

The reflck mutex has since become the dev_set mutex and is our defacto
serialization for various operations and ioctls.  It still seems to be
the case though that sets of vfio-pci devices really only need
serialization relative to hot resets affecting the entire set, which
is not relevant to SR-IOV VFs.  As described in the Closes link below,
this serialization contributes to startup latency when multiple VFs
sharing the same "bus" are opened concurrently.

Mark the device itself as the basis of the dev_set for SR-IOV VFs.

Reported-by: Aaron Lewis <aaronlewis@google.com>
Closes: https://lore.kernel.org/all/20250626180424.632628-1-aaronlewis@google.com
Tested-by: Aaron Lewis <aaronlewis@google.com>
Fixes: e309df5b0c9e ("vfio/pci: Parallelize device open and release")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/vfio/pci/vfio_pci_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index 6328c3a05bcd..261a6dc5a5fc 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -2149,7 +2149,7 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev)
 		return -EBUSY;
 	}
 
-	if (pci_is_root_bus(pdev->bus)) {
+	if (pci_is_root_bus(pdev->bus) || pdev->is_virtfn) {
 		ret = vfio_assign_device_set(&vdev->vdev, vdev);
 	} else if (!pci_probe_reset_slot(pdev->slot)) {
 		ret = vfio_assign_device_set(&vdev->vdev, pdev->slot);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-07-15 18:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 22:56 [PATCH] vfio/pci: Separate SR-IOV VF dev_set Alex Williamson
2025-06-30  6:32 ` Tian, Kevin
2025-06-30 13:15 ` Yi Liu
2025-06-30 14:57   ` Alex Williamson
2025-07-02 16:00 ` Jason Gunthorpe
2025-07-02 17:50   ` Alex Williamson
2025-07-02 17:55     ` Jason Gunthorpe
2025-07-03  6:10       ` Tian, Kevin
2025-07-03 13:23         ` Jason Gunthorpe
2025-07-03 20:29           ` Alex Williamson
2025-07-03 23:35             ` Jason Gunthorpe
2025-07-15 18:42               ` Alex Williamson
2025-07-15 18:53                 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).