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

Vipin Sharma
2026-04-30T18:25:27Z

On Tue, Apr 28, 2026 at 02:12:13PM -0700, David Matlack wrote:
> On Tue, Apr 28, 2026 at 1:20 PM Vipin Sharma <vipinsh@google.com> wrote:
> >
> > On Thu, Apr 23, 2026 at 09:23:06PM +0000, David Matlack wrote:
> > > +int pci_liveupdate_preserve(struct pci_dev *dev)
> > > +{
> > > + struct pci_ser *ser;
> > > + int i, ret;
> > > +
> > > + guard(mutex)(&pci_flb_outgoing_lock);
> > > +
> > > + ret = liveupdate_flb_get_outgoing(&pci_liveupdate_flb, (void **)&ser);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + if (!ser)
> > > + return -ENOENT;
> > > +
> > > + if (dev->is_virtfn)
> > > + return -EINVAL;
> > > +
> > > + if (dev->liveupdate_outgoing)
> > > + return -EBUSY;
> > > +
> > > + if (ser->nr_devices == ser->max_nr_devices)
> > > + return -ENOSPC;
> > > +
> > > + 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];
> > > +
> > > + if (dev_ser->refcount)
> > > + continue;
> > > +
> > > + pci_info(dev, "Device will be preserved across next Live Update\n");
> > > + ser->nr_devices++;
> > > +
> > > + dev_ser->domain = pci_domain_nr(dev->bus);
> > > + dev_ser->bdf = pci_dev_id(dev);
> > > + dev_ser->refcount = 1;
> > > +
> > > + dev->liveupdate_outgoing = dev_ser;
> > > + return 0;
> > > + }
> > > +
> > > + return -ENOSPC;
> >
> > Since it is executing under a mutex, and we already failed
> > 'if (ser->nr_devices == ser->max_nr_devices) check above, will we ever reach
> > here and return -ENOSPC?
>
> Yeah I wouldn't expect to ever reach here.

Will you be removing it or want to keep it just in case scenario?

>
> > > diff --git a/include/linux/kho/abi/pci.h b/include/linux/kho/abi/pci.h
> > > index 5c0e92588c00..5b4c8d9e462c 100644
> > > --- a/include/linux/kho/abi/pci.h
> > > +++ b/include/linux/kho/abi/pci.h
> > > @@ -23,19 +23,20 @@
> > > * incrementing the version number in the PCI_LUO_FLB_COMPATIBLE string.
> > > */
> > >
> > > -#define PCI_LUO_FLB_COMPATIBLE "pci-v1"
> > > +#define PCI_LUO_FLB_COMPATIBLE "pci-v2"
> >
> > Just curious, why did we change the version here?
>
> Because a field in struct pci_dev_ser changed.
>
> > It's not like just
> > previous patch is working enough to perform a live update. As the config
> > is experimental, can't we just keep it PCI-v1 for the whole series?
>
> What is the benefit of keeping "pci-v1"?
>

I don't see any benefit in keeping v1 or changing to v2 as well.

My reasoning is that before this series is merged, there is no real need
for versioning here. This is first series which is introducing PCI
liveupdate. It is not gonna be that someone has merged patch 1 only, run
its kernel and then kexec to next kernel which has patch 2.

> I think it makes sense to follow the rule we set which is to update
> the compatibility string in any commit that changes the ABI.

Okay, this is also fine.