[PATCH v5 4/6] liveupdate: luo_flb: support incremental outgoing FLB publication
Pasha Tatashin
pasha.tatashin at soleen.com
Wed Nov 11 13:08:39 PST 2026
On Wed Nov 11, 2026 at 6:18 AM EST, Mike Rapoport wrote:
> Hi,
>
>> When a session is published to KHO via luo_session_publish_one() ahead
>> of reboot, any FLBs that its preserved files depend on must already be
>> present in the outgoing KHO FLB array so the KHO tree remains
>> self-consistent.
>>
>> Currently, outgoing FLB metadata in luo_ser->flbs_pa is populated only
>> during reboot by luo_flb_serialize(), leaving luo_ser->flbs_pa empty
>> when sessions are published earlier.
>>
>> Publish outgoing FLBs from luo_session_publish_one() via
>> luo_file_publish_flbs() -> luo_flb_file_publish() ->
>> luo_flb_ser_publish_one(), and drop the now-redundant
>> luo_flb_serialize() pass from liveupdate_reboot(). For each published
>
> Oh, my :(
> Why do we care about exact long call sequence here?
>
>> file, luo_flb_ser_publish_one() either appends a new luo_flb_ser entry
>> with count = 1 using smp_store_release() on header_ser->count or
>> increments the existing entry's count in place, keeping the serialized
>> count equal to the exact number of published files in KHO without
>> including uncommitted sessions or transient
>> liveupdate_flb_get_outgoing() references.
>
> Got tired here, the prose needs a lot of human touch.
>
>> FLB publication is one-way and never needs to unpublish: before reboot
>> it runs only when a session is committed, and a committed session never
>> unpreserves its files, keeping private->outgoing.count >= 1 until
>> reboot so flb->ops->unpreserve() is never called on a published FLB.
>> If more FDs using an already-published FLB are preserved later,
>> flb->ops->preserve() is not called again; file handlers update the
>> shared live object via liveupdate_flb_get_outgoing(). Consequently, FLB
>> handlers must:
>> - return a stable root KHO handle in argp->data from .preserve() whose
>> address does not change as FDs are added later;
>> - synchronize concurrent mutations to outgoing.obj with their own lock;
>> - support per-FD rollback when uncommitted sessions close without
>> disturbing already-committed entries.
>>
>> Signed-off-by: Pasha Tatashin <pasha.tatashin at soleen.com>
>> ---
>> kernel/liveupdate/luo_core.c | 10 +--
>> kernel/liveupdate/luo_file.c | 16 +++++
>> kernel/liveupdate/luo_flb.c | 111 ++++++++++++++++++++-----------
>> kernel/liveupdate/luo_internal.h | 3 +-
>> kernel/liveupdate/luo_session.c | 2 +
>> 5 files changed, 95 insertions(+), 47 deletions(-)
>>
>> diff --git a/kernel/liveupdate/luo_core.c b/kernel/liveupdate/luo_core.c
>> index 1b2bda22902d2..9fef5161a1f3d 100644
>> --- a/kernel/liveupdate/luo_core.c
>> +++ b/kernel/liveupdate/luo_core.c
>> @@ -219,18 +219,10 @@ late_initcall(luo_late_startup);
>> */
>> int liveupdate_reboot(void)
>> {
>> - int err;
>> -
>> if (!liveupdate_enabled())
>> return 0;
>>
>> - err = luo_session_serialize();
>> - if (err)
>> - return err;
>> -
>> - luo_flb_serialize();
>> -
>> - return 0;
>> + return luo_session_serialize();
>
> I suppose the wall of text above describes why you change this.
Yes, FLBs are now serialized as each session is serialized, so the separate luo_flb_serialize() pass in liveupdate_reboot() goes away. I will make that clear and short in the commit message.
>
>> }
>>
>> /**
>> diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
>> index 988eb313a135f..611b9967a3a91 100644
>> --- a/kernel/liveupdate/luo_file.c
>> +++ b/kernel/liveupdate/luo_file.c
>> @@ -380,6 +380,22 @@ void luo_file_unpreserve_files(struct luo_file_set *file_set)
>> kho_block_set_destroy(&file_set->block_set);
>> }
>>
>> +/**
>> + * luo_file_publish_flbs - Publish FLBs for all preserved files in a file_set.
>> + * @file_set: The file_set being published to the outgoing KHO subtree.
>> + *
>> + * Iterates through all preserved files in @file_set and ensures their
>> + * associated FLB metadata is published in the outgoing KHO FLB array before
>> + * the session itself becomes visible in KHO.
>> + */
>> +void luo_file_publish_flbs(struct luo_file_set *file_set)
>> +{
>> + struct luo_file *luo_file;
>> +
>> + list_for_each_entry(luo_file, &file_set->files_list, list)
>> + luo_flb_file_publish(luo_file->fh);
>> +}
>> +
>> static int luo_file_freeze_one(struct luo_file_set *file_set,
>> struct luo_file *luo_file)
>> {
>> diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c
>> index cd715a7c1d992..6cd87a9f8307d 100644
>> --- a/kernel/liveupdate/luo_flb.c
>> +++ b/kernel/liveupdate/luo_flb.c
>> @@ -34,6 +34,15 @@
>> * This reference-counted approach ensures that shared state is saved exactly
>> * once and restored exactly once, regardless of how many files depend on it,
>> * and that its lifecycle is correctly managed across the kexec transition.
>> + *
>> + * Serialization: Outgoing FLB metadata is published into the KHO FLB array
>> + * incrementally as sessions are published to KHO (when committed early via
>> + * LIVEUPDATE_SESSION_FREEZE_COMMIT or during reboot). Because a committed
>> + * session never unpreserves its files, FLB publication is one-way: once
>> + * published, the FLB's .unpreserve() callback is never invoked and its root
>> + * KHO handle from .preserve() remains immutable in KHO, while later sessions
>> + * may still add or remove per-FD state in the shared live object under the FLB
>> + * handler's own synchronization.
>> */
>
>
>>
>> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>> @@ -72,6 +81,13 @@ static struct luo_flb_global luo_flb_global = {
>> .list = LIST_HEAD_INIT(luo_flb_global.list),
>> };
>>
>> +/*
>> + * Serializes updates to luo_flb_global.outgoing.header_ser and .ser[].
>> + * Lock hierarchy:
>> + * luo_register_rwlock -> private->outgoing.lock -> luo_flb_ser_lock
>> + */
>> +static DEFINE_MUTEX(luo_flb_ser_lock);
>> +
>> /*
>> * struct luo_flb_link - Links an FLB definition to a file handler's internal
>> * list of dependencies.
>> @@ -104,6 +120,36 @@ static struct luo_flb_private *luo_flb_get_private(struct liveupdate_flb *flb)
>> return private;
>> }
>>
>> +static void luo_flb_ser_publish_one(const struct liveupdate_flb *flb, u64 data)
>> +{
>> + struct luo_flb_header *fh = &luo_flb_global.outgoing;
>> + u64 nr;
>> +
>> + guard(mutex)(&luo_flb_ser_lock);
>> + if (!fh->active)
>> + return;
>> +
>> + nr = fh->header_ser->count;
>> + for (u64 i = 0; i < nr; i++) {
>> + if (!strcmp(fh->ser[i].name, flb->compatible)) {
>> + WRITE_ONCE(fh->ser[i].count, fh->ser[i].count + 1);
>
> An LLM says:
>
> Why the WRITE_ONCE()? All writers hold luo_flb_ser_lock, and nobody reads
> this before kexec.
Same kho-ro prep as in patch 2, will switch to fh->ser[i].count++ in v6
and move the concurrent reader bits to the kho-ro or luo-ro series.
>
>> + return;
>> + }
>> + }
>> +
>> + if (WARN_ON_ONCE(nr >= LUO_FLB_MAX))
>> + return;
>> +
>> + strscpy(fh->ser[nr].name, flb->compatible, sizeof(fh->ser[nr].name));
>> + fh->ser[nr].data = data;
>> + fh->ser[nr].count = 1;
>> + /*
>> + * Ensure the serialized FLB entry is visible before exposing the
>> + * incremented count to concurrent KHO readers.
>> + */
>> + smp_store_release(&fh->header_ser->count, nr + 1);
>
> An LLM says:
>
> And this release store pairs with nothing.
ditto
--
Pasha
More information about the kexec
mailing list