From: David Matlack <dmatlack@google.com>
To: Pratyush Yadav <pratyush@kernel.org>
Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>
Subject: Re: [PATCH 1/2] liveupdate: Reference count outgoing FLB data
Date: Tue, 2 Jun 2026 17:25:34 +0000 [thread overview]
Message-ID: <ah8SDsIuZQXyvpZq@google.com> (raw)
In-Reply-To: <2vxzfr34dfty.fsf@kernel.org>
On 2026-06-02 07:15 PM, Pratyush Yadav wrote:
> Hi David,
>
> On Thu, May 28 2026, David Matlack wrote:
>
> > Increment the outgoing FLB refcount in liveupdate_flb_get_outgoing() so
> > that the FLB structure cannot be freed while the caller is actively
> > using it. Add an additional liveupdate_flb_put_outgoing() function so
> > the caller can explicitly indicate when it is done using the outgoing
> > FLB.
> >
> > During a Live Update, the kernel may need to fetch the outgoing FLB
> > outside of the scope of a file handler's preserve() and unpreserve()
> > callbacks. In that situation there is no way for the caller to protect
> > itself against the outgoing FLB from being freed while it is using it.
> > Incrementing the reference count in liveupdate_flb_get_outgoing()
> > ensures it cannot be freed.
>
> We grab a reference to the FLB's module when the first file using the
> FLB is preserved. So the FLB should never go away while preserved files
> exist. Once all preserved files go away, you normally shouldn't be doing
> anything with the FLB anyway.
>
> Can you please elaborate on the use case and why this is a problem?
> Using the FLB outside of the standard LUO file callbacks sounds
> problematic.
The scenario I had in mind was to remove a PCI device from the outgoing
FLB if the device is forcibly removed while the file is still preserved,
for example someone writes 1 to /sys/bus/pci/devices/.../remove or a
device is physically hot-unplugged.
Specifically this call here from the patch below:
+void pci_liveupdate_cleanup_device(struct pci_dev *dev)
+{
+ /*
+ * It should be safe to READ_ONCE() outside of the rwsem during cleanup
+ * since there should no longer be any references to @dev on the system.
+ */
+ if (READ_ONCE(dev->liveupdate.outgoing)) {
+ pci_WARN(dev, 1, "Destroying outgoing-preserved device!\n");
+ pci_liveupdate_unpreserve(dev);
+ }
+}
https://lore.kernel.org/linux-pci/20260522202410.3104264-3-dmatlack@google.com/
I can do this without adding reference counting to
liveupdate_flb_get_outgoing(), but the reference counting makes it
obvious that the outgoing FLB will not be freed while I am using it
here, and also aligns with liveupdate_flb_get_incoming().
> >
> > This change also aligns the outgoing FLB lifecycle management with the
> > incoming FLB, since the latter uses the same get/put semantics.
> >
> > Fixes: cab056f2aae7 ("liveupdate: luo_flb: introduce File-Lifecycle-Bound global state")
> > Assisted-by: Gemini:gemini-3-pro-preview
> > Signed-off-by: David Matlack <dmatlack@google.com>
> [...]
>
> --
> Regards,
> Pratyush Yadav
next prev parent reply other threads:[~2026-06-02 17:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 17:41 [PATCH 0/2] liveupdate: Small FLB fixes David Matlack
2026-05-28 17:41 ` [PATCH 1/2] liveupdate: Reference count outgoing FLB data David Matlack
2026-06-02 17:15 ` Pratyush Yadav
2026-06-02 17:25 ` David Matlack [this message]
2026-06-03 3:36 ` Pasha Tatashin
2026-05-28 17:41 ` [PATCH 2/2] liveupdate: Remember FLB retrieve() status David Matlack
2026-06-02 17:18 ` Pratyush Yadav
2026-06-03 3:36 ` Pasha Tatashin
2026-06-04 5:28 ` [PATCH 0/2] liveupdate: Small FLB fixes Mike Rapoport
2026-06-05 13:09 ` Pratyush Yadav
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ah8SDsIuZQXyvpZq@google.com \
--to=dmatlack@google.com \
--cc=akpm@linux-foundation.org \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.