From: Mike Rapoport <rppt@kernel.org>
To: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: linux-kselftest@vger.kernel.org, shuah@kernel.org,
akpm@linux-foundation.org, linux-mm@kvack.org,
skhan@linuxfoundation.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, corbet@lwn.net,
dmatlack@google.com, kexec@lists.infradead.org,
pratyush@kernel.org, skhawaja@google.com, graf@amazon.com
Subject: Re: [PATCH v4 07/13] kho: add support for linked-block serialization
Date: Tue, 2 Jun 2026 12:04:24 +0300 [thread overview]
Message-ID: <ah6cmLDuy3EwbDu_@kernel.org> (raw)
In-Reply-To: <178038801491.119771.18384706761138506132.b4-review@b4>
I sent it before seeing v5, so some of those are already addressed, but
please take a look anyway.
On Tue, Jun 02, 2026 at 11:13:34AM +0300, Mike Rapoport wrote:
> On Sat, 30 May 2026 22:19:32 +0000, Pasha Tatashin <pasha.tatashin@soleen.com> wrote:
> > diff --git a/include/linux/kho_block.h b/include/linux/kho_block.h
> > new file mode 100644
> > index 000000000000..5e6b87b1befa
> > --- /dev/null
> > +++ b/include/linux/kho_block.h
> > @@ -0,0 +1,79 @@
> > [ ... skip 19 lines ... ]
> > + struct list_head list;
> > + struct kho_block_header_ser *ser;
> > +};
> > +
> > +/**
> > + * struct kho_block_set - A set of blocks that belong to the same object.
>
> "same object" sounds off to me. The blocks belong to the same module?
> user?
>
> Thoughts?
>
> > + * @blocks: The list of serialization blocks (struct kho_block).
> > + * @nblocks: The number of allocated serialization blocks.
> > + * @head_pa: Physical address of the first block header.
> > + * @entry_size: The size of each entry in the blocks.
>
> I think it's "... entry in a block"
>
> > [ ... skip 42 lines ... ]
> > +
> > +void kho_block_it_init(struct kho_block_it *it, struct kho_block_set *bs);
> > +void *kho_block_it_next(struct kho_block_it *it);
> > +void *kho_block_it_read(struct kho_block_it *it);
> > +void *kho_block_it_prev(struct kho_block_it *it);
> > +void kho_block_it_finalize(struct kho_block_it *it);
>
> These operate on block sets, should be reflected in the names.
> Can be kho_blocks_ to avoid too long names.
>
> >
> > diff --git a/kernel/liveupdate/kho_block.c b/kernel/liveupdate/kho_block.c
> > new file mode 100644
> > index 000000000000..a4e650af946f
> > --- /dev/null
> > +++ b/kernel/liveupdate/kho_block.c
> > @@ -0,0 +1,384 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +/*
> > + * Copyright (c) 2026, Google LLC.
> > + * Pasha Tatashin <pasha.tatashin@soleen.com>
> > + */
> > +
> > +/**
> > + * DOC: KHO Serialization Blocks
> > + *
> > + * KHO provides a mechanism to preserve stateful data across a kexec handover
> > + * by serializing it into memory blocks. This file provides the common
>
> "This file" does not look good in HTML docs.
>
> > [ ... skip 15 lines ... ]
> > +
> > +/*
> > + * Safeguard limit for the number of serialization blocks. This is used to
> > + * prevent infinite loops and excessive memory allocation in case of memory
> > + * corruption in the preserved state.
> > + */
>
> Can you add how much memory it is and how many entries with, say, 4 u64
> it can accommodate?
>
> > [ ... skip 13 lines ... ]
> > +{
> > + if (unlikely(!bs->count_per_block)) {
> > + bs->count_per_block = (KHO_BLOCK_SIZE -
> > + sizeof(struct kho_block_header_ser)) /
> > + bs->entry_size;
> > + WARN_ON(!bs->count_per_block);
>
> Don't you want to set count_per_block in _init()?
>
> > [ ... skip 29 lines ... ]
> > + if (!block)
> > + return -ENOMEM;
> > +
> > + block->ser = ser;
> > + last = list_last_entry_or_null(&bs->blocks, struct kho_block, list);
> > + list_add_tail(&block->list, &bs->blocks);
>
> No locks?
>
> > [ ... skip 12 lines ... ]
> > + * @bs: The block set.
> > + * @count: The current number of entries.
> > + *
> > + * This function handles the dynamic expansion of a block set. It allocates
> > + * and links a new serialization block if the provided entry count matches
> > + * the current total capacity of the set.
>
> This is a weird semantics for a generic API. I'd expect _grow() would
> add count - current_count blocks.
>
> > [ ... skip 25 lines ... ]
> > +}
> > +
> > +/**
> > + * kho_block_shrink - Conditionally destroy the last block in a block set.
> > + * @bs: The block set.
> > + * @count: The current number of entries across all blocks.
>
> Maybe
> ... of valid entries?
>
> > + *
> > + * This function checks if the last block in the set is redundant based on the
> > + * total entry count and the capacity of the preceding blocks. If the entry
> > + * count can be accommodated by the blocks that come before the last one, the
> > + * last block is destroyed and removed from the set.
>
> This should mention that it's the caller responsibility to ensure that
> entries are removed in the right order.
>
> > [ ... skip 49 lines ... ]
> > +
> > + fast = phys_to_virt(fast->next);
> > + slow = phys_to_virt(slow->next);
> > +
> > + if (slow == fast) {
> > + pr_err("Cyclic list detected\n");
>
> Maybe "block set is corrupted"?
>
> > + return false;
> > + }
> > + }
> > +
> > + return true;
> > +}
> > +
> > +/**
> > + * kho_block_restore - Restore a block set from a physical address.
> > + * @bs: The block set to restore.
> > + * @head_pa: Physical address of the first block header.
>
> I'd mention that the block set should be allocated and initialized
>
> > [ ... skip 10 lines ... ]
> > + bs->incoming = true;
> > + if (!head_pa)
> > + return 0;
> > +
> > + bs->head_pa = head_pa;
> > + if (!kho_cyclic_blocks_check(bs)) {
>
> if (kho_block_set_cyclic())
>
> reads nicer IMO
>
> > [ ... skip 87 lines ... ]
> > +{
> > + if (!it->block)
> > + return NULL;
> > +
> > + if (it->i == kho_block_count_per_block(it->bs)) {
> > + it->block->ser->count = it->i;
>
> Why iterator updates ser->count?
>
> > + if (list_is_last(&it->block->list, &it->bs->blocks))
> > + return NULL;
> > + it->block = list_next_entry(it->block, list);
> > + it->i = 0;
> > + }
> > +
> > + return (void *)(it->block->ser + 1) + (it->i++ * it->bs->entry_size);
>
> In a month we'll need an LLM's help to understand what it does.
>
> > +}
> > +
> > +/**
> > + * kho_block_it_read - Return the next entry slot for reading.
> > + * @it: The block iterator.
>
> And what is the conceptual difference between this and _it_next()?
>
> > [ ... skip 49 lines ... ]
> > + * @it: The block iterator.
> > + */
> > +void kho_block_it_finalize(struct kho_block_it *it)
> > +{
> > + if (it->block)
> > + it->block->ser->count = it->i;
>
> So, it looks like the intention of _it_next is for write, and this ends a
> write iteration.
>
> I think the names should be adjusted to make it clearer.
>
> --
> Sincerely yours,
> Mike.
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-06-02 9:04 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 22:19 [PATCH v4 00/13] liveupdate: Remove limits on sessions and files Pasha Tatashin
2026-05-30 22:19 ` [PATCH v4 01/13] liveupdate: change file_set->count type to u64 for type safety Pasha Tatashin
2026-05-31 13:35 ` Pasha Tatashin
2026-06-01 12:08 ` Pratyush Yadav
2026-06-02 8:13 ` Mike Rapoport
2026-05-30 22:19 ` [PATCH v4 02/13] liveupdate: avoid mixing cleanup guards with goto in luo_session_retrieve_fd Pasha Tatashin
2026-05-31 12:52 ` Pasha Tatashin
2026-06-01 12:15 ` Pratyush Yadav
2026-06-02 8:13 ` Mike Rapoport
2026-05-30 22:19 ` [PATCH v4 03/13] liveupdate: centralize state management into struct luo_ser Pasha Tatashin
2026-06-01 12:19 ` Pratyush Yadav
2026-06-02 8:13 ` Mike Rapoport
2026-05-30 22:19 ` [PATCH v4 04/13] liveupdate: register luo_ser as KHO subtree Pasha Tatashin
2026-05-31 13:44 ` Pasha Tatashin
2026-06-01 12:39 ` Pratyush Yadav
2026-06-01 13:50 ` Pasha Tatashin
2026-06-01 14:27 ` Pratyush Yadav
2026-05-30 22:19 ` [PATCH v4 05/13] liveupdate: Extract luo_file_deserialize_one helper Pasha Tatashin
2026-05-30 22:19 ` [PATCH v4 06/13] liveupdate: Extract luo_session_deserialize_one helper Pasha Tatashin
2026-05-30 22:19 ` [PATCH v4 07/13] kho: add support for linked-block serialization Pasha Tatashin
2026-06-01 13:38 ` Pratyush Yadav
2026-06-01 14:37 ` Pasha Tatashin
2026-06-02 8:13 ` Mike Rapoport
2026-06-02 9:04 ` Mike Rapoport [this message]
2026-05-30 22:19 ` [PATCH v4 08/13] liveupdate: defer session block allocation and PA setting Pasha Tatashin
2026-06-01 13:47 ` Pratyush Yadav
2026-06-02 8:13 ` Mike Rapoport
2026-05-30 22:19 ` [PATCH v4 09/13] liveupdate: Remove limit on the number of sessions Pasha Tatashin
2026-06-01 14:03 ` Pratyush Yadav
2026-06-01 14:44 ` Pasha Tatashin
2026-05-30 22:19 ` [PATCH v4 10/13] liveupdate: Remove limit on the number of files per session Pasha Tatashin
2026-06-01 14:16 ` Pratyush Yadav
2026-06-01 14:40 ` Pasha Tatashin
2026-05-30 22:19 ` [PATCH v4 11/13] selftests/liveupdate: Test session and file limit removal Pasha Tatashin
2026-06-01 14:17 ` Pratyush Yadav
2026-05-30 22:19 ` [PATCH v4 12/13] selftests/liveupdate: Add stress-sessions kexec test Pasha Tatashin
2026-06-01 14:19 ` Pratyush Yadav
2026-05-30 22:19 ` [PATCH v4 13/13] selftests/liveupdate: Add stress-files " Pasha Tatashin
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=ah6cmLDuy3EwbDu_@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dmatlack@google.com \
--cc=graf@amazon.com \
--cc=kexec@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=skhawaja@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox