Re: [PATCH v4 02/11] PCI: liveupdate: Track outgoing preserved PCI devices

David Matlack
2026-04-30T21:15:25Z

On 2026-04-28 05:24 PM, Samiullah Khawaja wrote:
> On Thu, Apr 23, 2026 at 09:23:06PM +0000, David Matlack wrote:

> > + for (i = 0; i < ser->max_nr_devices; i++) {
> > + /*
> > + * Start searching at index ser->nr_devices. This should result
> > + * in a constant time search under expected conditions (devices
> > + * are not getting unpreserved).
> > + */
> > + int index = (ser->nr_devices + i) % ser->max_nr_devices;
> > + struct pci_dev_ser *dev_ser = &ser->devices[index];
>
> nit: Maybe we can move this logic in a separate function as down the road
> when we expand this to add VFs and Hotpluggable devices, this might
> change significantly? It's good if it is self-contained.

Did you mean to leave this comment on pci_flb_preserve() where it
decides how many devices to allocate room for?

> > +static inline struct pci_dev_ser *pci_liveupdate_outgoing(struct pci_dev *dev)
> > +{
> > + return dev->liveupdate_outgoing;
> > +}
>
> Is this expected to be called under the outgoing lock?

For now this API is only used during shutdown, at which point userspace
should have already been stopped so drivers should not be changing the
preservation status of an outgoing device. So I don't think this needs
to be under the outgoing lock, but it would be nice to have some more
explicit synchronization.