Re: [PATCH] PCI: optimize proc sequential file read

Bjorn Helgaas
2024-10-22T15:44:44Z

[+cc Greg]

On Fri, Oct 18, 2024 at 01:47:28PM +0800, Guixin Liu wrote:
> PCI driver will traverse pci device list in pci_seq_start in every
> sequential file reading, use xarry to store all pci devices to
> accelerate finding the start.

> /* iterator */
> static void *pci_seq_start(struct seq_file *m, loff_t *pos)
> {
> - struct pci_dev *dev = NULL;
> + struct pci_dev *dev;
> loff_t n = *pos;
>
> - for_each_pci_dev(dev) {
> - if (!n--)
> - break;
> - }

Maybe another approach would be to use pci_get_device() directly
instead of for_each_pci_dev().

pci_get_device() takes a "from" starting point, so instead of keeping
track of the index "n", you could keep track of the current pci_dev.