Re: [PATCH v5 5/6] liveupdate: Add LIVEUPDATE_SESSION_FREEZE ioctl to freeze sessions early

From: Mike Rapoport

Date: Wed Nov 11 2026 - 06:20:47 EST


Hi,

> Currently, LUO sessions are frozen automatically only inside the
> reboot(LINUX_REBOOT_CMD_KEXEC) pathway, where luo_session_serialize()
> iterates through all outgoing sessions under global write locks and
> freezes them serially during shutdown. On hosts running multiple
> workloads that quiesce one by one ahead of kexec, userspace needs an
> explicit per-session freeze point so each session can capture final file
> state under its per-session mutex as soon as its workload pauses.
>
> Introduce LIVEUPDATE_SESSION_FREEZE on session FDs to freeze an outgoing
> session early. The ioctl runs .freeze() across all preserved files in
> the session and serializes their metadata. Once frozen, no additional
> files can be added to the session, and subsequent freeze calls return
> -EBUSY. Freeze is only valid on outgoing sessions and returns -EINVAL on
> incoming ones.
>
> By default (flags == 0), session lifetime remains bound to the session
> FD: the session stays frozen while the FD remains open, and closing the
> session FD before reboot (for example, to abort the session or on
> process exit/crash) unfreezes it via .unfreeze(), unpreserves its files,
> and reclaims all resources. During kexec, already-frozen sessions skip
> the late auto-freeze and are published into the outgoing KHO subtree.
>
> With LIVEUPDATE_SESSION_FREEZE_COMMIT set in
> struct liveupdate_session_freeze.flags, the frozen session is committed:
> it and its FLB dependencies are immediately inserted into the outgoing
> KHO subtree via luo_session_publish_one(), and the session survives
> close() with full ownership retained by LUO until reboot. Once
> committed, closing the session FD (or another session failing to freeze
> during reboot) never unfreezes or unpreserves the session, allowing
> processes to hand off preserved state and exit prior to kexec.
>
> Update the uAPI and core LUO documentation to describe session freeze
> and commit semantics.

Please teach your LLM to use shorter paragraphs, focus on why and don't
list every implementation detail, but only important ones.

> Signed-off-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
> ---
> Documentation/userspace-api/liveupdate.rst | 30 +++++++++
> include/linux/liveupdate.h | 3 +-
> include/uapi/linux/liveupdate.h | 46 +++++++++++++
> kernel/liveupdate/luo_file.c | 54 +++++++--------
> kernel/liveupdate/luo_internal.h | 7 ++
> kernel/liveupdate/luo_session.c | 77 ++++++++++++++++++++--
> 6 files changed, 184 insertions(+), 33 deletions(-)
>
> diff --git a/Documentation/userspace-api/liveupdate.rst b/Documentation/userspace-api/liveupdate.rst
> index cdd74627ab75b..d36537c556ccb 100644
> --- a/Documentation/userspace-api/liveupdate.rst
> +++ b/Documentation/userspace-api/liveupdate.rst
> @@ -22,6 +22,36 @@ change, so compatibility is not guaranteed when kexec rebooting between
> different kernel versions. This is expected to change and stabilize in a future
> version.
>
> +Session Freeze and Commit
> +=========================
> +
> +By default, LUO freezes active sessions automatically inside the
> +``reboot(LINUX_REBOOT_CMD_KEXEC)`` syscall path, and an outgoing session's
> +lifetime is bound to its open session FD: closing the FD before reboot aborts
> +preservation and returns all resources.
> +
> +Userspace may also freeze an outgoing session explicitly ahead of reboot via
> +``ioctl(session_fd, LIVEUPDATE_SESSION_FREEZE, &arg)`` once it has finished
> +preserving and modifying the session's files:
> +
> +- **Freeze** (``flags == 0``): Executes ``.freeze()`` on all preserved files in
> + the session under the per-session lock (allowing multiple sessions to freeze
> + concurrently), while keeping session lifetime tied to ``session_fd``. When
> + ``session_fd`` is closed before reboot (for example, to abort the session or
> + on process exit/crash), LUO runs ``.unfreeze()`` and ``.unpreserve()`` on all
> + files in the session and reclaims all resources. As long as ``session_fd``
> + remains open, the session stays frozen across any failed ``reboot()`` attempt;
> + at kexec time, already-frozen sessions skip the late auto-freeze step and are
> + published into the outgoing KHO subtree.
> +- **Freeze and commit** (``LIVEUPDATE_SESSION_FREEZE_COMMIT``): Freezes the
> + session's files, immediately inserts the session and its FLB dependencies
> + into the outgoing KHO subtree, and commits the session so that it survives
> + closing ``session_fd`` with ownership retained by LUO until reboot. Once
> + committed, closing ``session_fd`` (or another session failing to freeze
> + during ``reboot()``) will neither unfreeze nor unpreserve the session,
> + allowing processes to hand off preserved state to LUO and exit prior to
> + kexec.

Too wall-of-text'y, too much markup.

I'm stopping here until v6.

--
Sincerely yours,
Mike.