Re: [RFC 0/4] pci/sriov: support VFs dynamic addition

From: Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
Date: Sun Nov 13 2022 - 08:47:22 EST


Hi leon,

在 2022/11/12 0:39, Leon Romanovsky 写道:
On Fri, Nov 11, 2022 at 10:27:18PM +0800, Longpeng(Mike) wrote:
From: Longpeng <longpeng2@xxxxxxxxxx>

We can enable SRIOV and add VFs by /sys/bus/pci/devices/..../sriov_numvfs, but
this operation needs to spend lots of time if there has a large amount of VFs.
For example, if the machine has 10 PFs and 250 VFs per-PF, enable all the VFs
concurrently would cost about 200-250ms. However most of them are not need to be
used at the moment, so we can enable SRIOV first but add VFs on demand.

It is unclear what took 200-250ms, is it physical VF creation or bind of
the driver to these VFs?

It is neither. In our test, we already created physical VFs before, so we skipped the 100ms waiting when writing PCI_SRIOV_CTRL. And our driver only probes PF, it just returns an error if the function is VF.

The hotspot is the sriov_add_vfs (but no driver probe in fact) which is a long procedure. Each step costs only a little, but the total cost is not acceptable in some time-sensitive cases.

What’s more, the sriov_add_vfs adds the VFs of a PF one by one. So we can mostly support 10 concurrent calls if there has 10 PFs.

If the latter, you can try with sriov_drivers_autoprobe set to true. This is how
ennoblement of large SR-IOV systems is done.
> Also PCI spec declares "VF enable" bit, which is applicable to all VFs
associated to that PF, see section "9.3.3.3.1 VF Enable".

Thanks


This series introduces two interfaces:
1. sriov_numvfs_no_scan: enable SRIOV without add the VFs.
2. sriov_scan_vf_id: add a specific VF.

Longpeng (4):
pci/sriov: extract sriov_numvfs common helper
pci/sriov: add vf_bitmap to mark the vf id allocation
pci/sriov: add sriov_numfs_no_scan interface
pci/sriov: add sriov_scan_vf_id interface

drivers/pci/iov.c | 162 +++++++++++++++++++++++++++++++++++++++++-----
drivers/pci/pci.h | 1 +
2 files changed, 148 insertions(+), 15 deletions(-)

--
2.23.0

.