Re: [PATCH v6 2/7] kho: link outgoing blocks lazily in kho_block
From: Mike Rapoport
Date: Thu Nov 19 2026 - 06:04:06 EST
Hi,
> Currently, kho_block_add() links each preallocated block onto the
> serialized chain immediately, even while it is still empty. This
> assumes all preallocated blocks are populated together before the
> chain is referenced by KHO.
>
> When sessions are serialized incrementally ahead of reboot, extra
> blocks may be preallocated for sessions that have not been serialized
> yet. Keeping those blocks linked leaves empty trailing blocks on the
> KHO chain.
>
> Keep preallocated outgoing blocks unlinked in kho_block_add() and link
> each block lazily in kho_block_set_it_reserve_entry() when advancing
> into it. Also unlink blocks in kho_block_set_clear() and stop at
> unlinked blocks in kho_block_set_it_read_entry().
>
> Signed-off-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
> ---
> kernel/liveupdate/kho_block.c | 38 +++++++++++++++++++++++------------
> 1 file changed, 25 insertions(+), 13 deletions(-)
>
> diff --git a/kernel/liveupdate/kho_block.c b/kernel/liveupdate/kho_block.c
> index 0d2a342ef4228..21cee45fa1cc0 100644
> --- a/kernel/liveupdate/kho_block.c
> +++ b/kernel/liveupdate/kho_block.c
> @@ -16,6 +16,11 @@
> * array of serialized entries. Multiple blocks are linked together via a
> * physical pointer in the header, forming a linked list that can be easily
> * traversed in both the current and the next kernel.
> + *
> + * Outgoing blocks preallocated via kho_block_set_grow() remain unlinked until
> + * entries are reserved via kho_block_set_it_reserve_entry(). This allows
> + * entries to be serialized incrementally without exposing empty trailing blocks
> + * on the physical chain.
With the kho-ro preparation dropped, I don't see what the empty linked
blocks break. Every session is serialized in luo_session_serialize() before
kexec, and nblocks always matches ceil(count / entries per block), so by the
time the chain is handed over all the preallocated blocks are populated.
Empty trailing blocks exist only for a short while before reboot and nobody
looks at them. If they did reach the next kernel, kho_block_set_restore()
would refuse them anyway.
It only matters if something reads the chain while sessions are being
serialized, and that's kho-ro. So either describe here what actually goes
wrong without this patch, or move it to the kho-ro series where it's needed.
--
Sincerely yours,
Mike.