Re: [PATCH v7 04/22] liveupdate: luo_session: add sessions support
From: Mike Rapoport
Date: Sun Nov 23 2025 - 09:16:44 EST
On Sat, Nov 22, 2025 at 05:23:31PM -0500, Pasha Tatashin wrote:
> Introduce concept of "Live Update Sessions" within the LUO framework.
> LUO sessions provide a mechanism to group and manage `struct file *`
> instances (representing file descriptors) that need to be preserved
> across a kexec-based live update.
>
> Each session is identified by a unique name and acts as a container
> for file objects whose state is critical to a userspace workload, such
> as a virtual machine or a high-performance database, aiming to maintain
> their functionality across a kernel transition.
>
> This groundwork establishes the framework for preserving file-backed
> state across kernel updates, with the actual file data preservation
> mechanisms to be implemented in subsequent patches.
>
> Signed-off-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
> ---
> include/linux/kho/abi/luo.h | 71 +++++
> include/uapi/linux/liveupdate.h | 3 +
> kernel/liveupdate/Makefile | 3 +-
> kernel/liveupdate/luo_core.c | 9 +
> kernel/liveupdate/luo_internal.h | 29 ++
> kernel/liveupdate/luo_session.c | 462 +++++++++++++++++++++++++++++++
> 6 files changed, 576 insertions(+), 1 deletion(-)
> create mode 100644 kernel/liveupdate/luo_session.c
>
...
> +int __init luo_session_setup_outgoing(void *fdt_out)
> +{
> + struct luo_session_header_ser *header_ser;
> + void *outgoing_buffer;
> + u64 header_ser_pa;
> + int err;
> +
> + outgoing_buffer = kho_alloc_preserve(LUO_SESSION_PGCNT << PAGE_SHIFT);
> + if (IS_ERR(outgoing_buffer))
> + return PTR_ERR(header_ser);
Should be
return PTR_ERR(outgoing_buffer);
Or, preferably, just drop outgoing_buffer and use header_ser everywhere.
> + header_ser = outgoing_buffer;
> + header_ser_pa = virt_to_phys(header_ser);
> +
> + err = fdt_begin_node(fdt_out, LUO_FDT_SESSION_NODE_NAME);
> + err |= fdt_property_string(fdt_out, "compatible",
> + LUO_FDT_SESSION_COMPATIBLE);
> + err |= fdt_property(fdt_out, LUO_FDT_SESSION_HEADER, &header_ser_pa,
> + sizeof(header_ser_pa));
> + err |= fdt_end_node(fdt_out);
> +
> + if (err)
> + goto err_unpreserve;
> +
> + luo_session_global.outgoing.header_ser = header_ser;
> + luo_session_global.outgoing.ser = (void *)(header_ser + 1);
> + luo_session_global.outgoing.active = true;
> +
> + return 0;
> +
> +err_unpreserve:
> + kho_unpreserve_free(header_ser);
> + return err;
> +}
...
> +int luo_session_deserialize(void)
> +{
> + struct luo_session_header *sh = &luo_session_global.incoming;
> + static bool is_deserialized;
> + static int err;
> +
> + /* If has been deserialized, always return the same error code */
> + if (is_deserialized)
> + return err;
is_deserialized and err are uninitialized here.
> +
> + is_deserialized = true;
> + if (!sh->active)
> + return 0;
> +
...
> +/**
> + * luo_session_quiesce - Ensure no active sessions exist and lock session lists.
> + *
> + * Acquires exclusive write locks on both incoming and outgoing session lists.
> + * It then validates no sessions exist in either list.
> + *
> + * This mechanism is used during file handler un/registration to ensure that no
> + * sessions are currently using the handler, and no new sessions can be created
> + * while un/registration is in progress.
It makes sense to add something like this comment from luo_file.c here as well:
* This prevents registering new handlers while sessions are active or
* while deserialization is in progress.
> + *
> + * Return:
> + * true - System is quiescent (0 sessions) and locked.
> + * false - Active sessions exist. The locks are released internally.
> + */
With those addressed:
Reviewed-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
--
Sincerely yours,
Mike.