Remove the KHO notifier registration and callbacks from the memblock
subsystem. These notifiers were tied to the former KHO finalize and
abort events, which are no longer used.
Memblock now preserves its `reserve_mem` regions and registers its
metadata by calling kho_preserve_phys(), kho_preserve_folio(), and
kho_add_subtree() directly within its initialization function.
Signed-off-by: Jason Miu <jasonmiu@google.com>
---
include/linux/kexec_handover.h | 5 ++--
kernel/kexec_handover.c | 48 +++++++++++++++++++++-------------
mm/memblock.c | 45 +++++++------------------------
3 files changed, 42 insertions(+), 56 deletions(-)
diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h
index c8229cb11f4b..9566c90a3501 100644
--- a/include/linux/kexec_handover.h
+++ b/include/linux/kexec_handover.h
@@ -27,7 +27,7 @@ bool kho_is_enabled(void);
int kho_preserve_folio(struct folio *folio);
int kho_preserve_phys(phys_addr_t phys, size_t size);
struct folio *kho_restore_folio(phys_addr_t phys);
-int kho_add_subtree(struct kho_serialization *ser, const char *name, void *fdt);
+int kho_add_subtree(const char *name, void *fdt);
int kho_retrieve_subtree(const char *name, phys_addr_t *phys);
int register_kho_notifier(struct notifier_block *nb);
@@ -58,8 +58,7 @@ static inline struct folio *kho_restore_folio(phys_addr_t phys)
return NULL;
}
-static inline int kho_add_subtree(struct kho_serialization *ser,
- const char *name, void *fdt)
+static inline int kho_add_subtree(const char *name, void *fdt)
{
return -EOPNOTSUPP;
}
diff --git a/kernel/kexec_handover.c b/kernel/kexec_handover.c
index 34cf0ce4f359..ee4f430dfae0 100644
--- a/kernel/kexec_handover.c
+++ b/kernel/kexec_handover.c
@@ -640,9 +640,21 @@ static int kho_debugfs_fdt_add(struct list_head *list, struct dentry *dir,
return 0;
}
+struct kho_out {
+ struct blocking_notifier_head chain_head;
+ struct dentry *dir;
+ struct kho_serialization ser;
+};
+
+static struct kho_out kho_out = {
+ .chain_head = BLOCKING_NOTIFIER_INIT(kho_out.chain_head),
+ .ser = {
+ .fdt_list = LIST_HEAD_INIT(kho_out.ser.fdt_list),
+ },
+};
+
/**
* kho_add_subtree - record the physical address of a sub FDT in KHO root tree.
- * @ser: serialization control object passed by KHO notifiers.
* @name: name of the sub tree.
* @fdt: the sub tree blob.
*
@@ -655,16 +667,29 @@ static int kho_debugfs_fdt_add(struct list_head *list, struct dentry *dir,
*
* Return: 0 on success, error code on failure
*/
-int kho_add_subtree(struct kho_serialization *ser, const char *name, void *fdt)
+int kho_add_subtree(const char *name, void *fdt)
{
+ struct kho_serialization *ser = &kho_out.ser;
int err = 0;
+ int root_node_offset, subnode_offset;
u64 phys = (u64)virt_to_phys(fdt);
void *root = page_to_virt(ser->fdt);
- err |= fdt_begin_node(root, name);
- err |= fdt_property(root, PROP_SUB_FDT, &phys, sizeof(phys));
- err |= fdt_end_node(root);
+ /* Reload the KHO root FDT to the same buffer */
+ err = fdt_open_into(root, root, PAGE_SIZE);
+ if (err)
+ return err;
+
+ root_node_offset = fdt_path_offset(fdt, "/");
+ if (root_node_offset < 0)
+ return root_node_offset;
+
+ subnode_offset = fdt_add_subnode(root, root_node_offset, name);
+ if (subnode_offset < 0)
+ return subnode_offset;
+ err = fdt_setprop(root, subnode_offset,
+ PROP_SUB_FDT, &phys, sizeof(phys));
if (err)
return err;
@@ -672,19 +697,6 @@ int kho_add_subtree(struct kho_serialization *ser, const char *name, void *fdt)
}
EXPORT_SYMBOL_GPL(kho_add_subtree);
-struct kho_out {
- struct blocking_notifier_head chain_head;
- struct dentry *dir;
- struct kho_serialization ser;
-};
-
-static struct kho_out kho_out = {
- .chain_head = BLOCKING_NOTIFIER_INIT(kho_out.chain_head),
- .ser = {
- .fdt_list = LIST_HEAD_INIT(kho_out.ser.fdt_list),
- },
-};
-
int register_kho_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&kho_out.chain_head, nb);
diff --git a/mm/memblock.c b/mm/memblock.c
index 117d963e677c..602a16cb467a 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2510,39 +2510,6 @@ int reserve_mem_release_by_name(const char *name)
#define RESERVE_MEM_KHO_NODE_COMPATIBLE "reserve-mem-v1"
static struct page *kho_fdt;
-static int reserve_mem_kho_finalize(struct kho_serialization *ser)
-{
- int err = 0, i;
-
- for (i = 0; i < reserved_mem_count; i++) {
- struct reserve_mem_table *map = &reserved_mem_table[i];
-
- err |= kho_preserve_phys(map->start, map->size);
- }
-
- err |= kho_preserve_folio(page_folio(kho_fdt));
- err |= kho_add_subtree(ser, MEMBLOCK_KHO_FDT, page_to_virt(kho_fdt));
-
- return notifier_from_errno(err);
-}
-
-static int reserve_mem_kho_notifier(struct notifier_block *self,
- unsigned long cmd, void *v)
-{
- switch (cmd) {
- case KEXEC_KHO_FINALIZE:
- return reserve_mem_kho_finalize((struct kho_serialization *)v);
- case KEXEC_KHO_ABORT:
- return NOTIFY_DONE;
- default:
- return NOTIFY_BAD;
- }
-}
-
-static struct notifier_block reserve_mem_kho_nb = {
- .notifier_call = reserve_mem_kho_notifier,
-};
-
static int __init prepare_kho_fdt(void)
{
int err = 0, i;
@@ -2583,7 +2550,7 @@ static int __init prepare_kho_fdt(void)
static int __init reserve_mem_init(void)
{
- int err;
+ int err, i;
if (!kho_is_enabled() || !reserved_mem_count)
return 0;
@@ -2592,7 +2559,15 @@ static int __init reserve_mem_init(void)
if (err)
return err;
- err = register_kho_notifier(&reserve_mem_kho_nb);
+ for (i = 0; i < reserved_mem_count; i++) {
+ struct reserve_mem_table *map = &reserved_mem_table[i];
+
+ err |= kho_preserve_phys(map->start, map->size);
+ }
+
+ err |= kho_preserve_folio(page_folio(kho_fdt));
+ err |= kho_add_subtree(MEMBLOCK_KHO_FDT, page_to_virt(kho_fdt));
+
if (err) {
put_page(kho_fdt);
kho_fdt = NULL;
--
2.51.0.618.g983fd99d29-goog
Hi Jason, kernel test robot noticed the following build errors: [auto build test ERROR on rppt-memblock/for-next] [also build test ERROR on linus/master v6.17] [cannot apply to rppt-memblock/fixes akpm-mm/mm-everything next-20250929] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Jason-Miu/kho-Adopt-KHO-radix-tree-data-structures/20251001-092230 base: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git for-next patch link: https://lore.kernel.org/r/20251001011941.1513050-3-jasonmiu%40google.com patch subject: [PATCH v1 2/3] memblock: Remove KHO notifier usage config: x86_64-randconfig-003-20251001 (https://download.01.org/0day-ci/archive/20251002/202510020000.IIPFcxsW-lkp@intel.com/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251002/202510020000.IIPFcxsW-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202510020000.IIPFcxsW-lkp@intel.com/ All errors (new ones prefixed by >>): >> lib/test_kho.c:59:44: error: too many arguments to function call, expected 2, have 3 59 | err |= kho_add_subtree(ser, KHO_TEST_FDT, folio_address(state->fdt)); | ~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/kexec_handover.h:30:5: note: 'kho_add_subtree' declared here 30 | int kho_add_subtree(const char *name, void *fdt); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. vim +59 lib/test_kho.c b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 40) b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 41) static int kho_test_notifier(struct notifier_block *self, unsigned long cmd, b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 42) void *v) b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 43) { b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 44) struct kho_test_state *state = &kho_test_state; b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 45) struct kho_serialization *ser = v; b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 46) int err = 0; b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 47) b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 48) switch (cmd) { b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 49) case KEXEC_KHO_ABORT: b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 50) return NOTIFY_DONE; b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 51) case KEXEC_KHO_FINALIZE: b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 52) /* Handled below */ b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 53) break; b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 54) default: b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 55) return NOTIFY_BAD; b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 56) } b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 57) b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 58) err |= kho_preserve_folio(state->fdt); b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 @59) err |= kho_add_subtree(ser, KHO_TEST_FDT, folio_address(state->fdt)); b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 60) b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 61) return err ? NOTIFY_BAD : NOTIFY_DONE; b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 62) } b753522bed0b7e Mike Rapoport (Microsoft 2025-07-27 63) -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.