[PATCH 04/12] kho: add callback for table pages
Pratyush Yadav
pratyush at kernel.org
Wed Apr 29 06:39:06 PDT 2026
From: "Pratyush Yadav (Google)" <pratyush at kernel.org>
The KHO memory preservation radix tree does not mark the table pages
themselves as scratch. This is done to avoid a circular dependency where
preserving a page can lead of allocating other preserved pages. This
means any walker looking for free ranges of memory outside of scratch
areas will ignore the table
Add a table callback that is invoked for each table page. The callback
is given the physical address of the table page.
Signed-off-by: Pratyush Yadav (Google) <pratyush at kernel.org>
---
include/linux/kho_radix_tree.h | 3 +++
kernel/liveupdate/kexec_handover.c | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/linux/kho_radix_tree.h b/include/linux/kho_radix_tree.h
index 030da6399d28..fe7151d89361 100644
--- a/include/linux/kho_radix_tree.h
+++ b/include/linux/kho_radix_tree.h
@@ -37,12 +37,15 @@ struct kho_radix_tree {
/**
* struct kho_radix_walk_cb - Callbacks for KHO radix tree walk.
* @key: Called on each present key in the radix tree.
+ * @table: Called on each table of the radix tree itself. Receives the
+ * physical address of the page containing the table.
*
* For each callback, a return value of 0 continues the walk and a non-zero
* return value is directly returned to the caller.
*/
struct kho_radix_walk_cb {
int (*key)(unsigned long key);
+ int (*table)(phys_addr_t phys);
};
#ifdef CONFIG_KEXEC_HANDOVER
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 4a5d1b47799c..94ca831b41c9 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -273,6 +273,12 @@ static int kho_radix_walk_leaf(struct kho_radix_leaf *leaf, unsigned long key,
unsigned int i;
int err;
+ if (cb->table) {
+ err = cb->table(virt_to_phys(leaf));
+ if (err)
+ return err;
+ }
+
if (!cb->key)
return 0;
@@ -295,6 +301,12 @@ static int __kho_radix_walk_tree(struct kho_radix_node *root,
unsigned int shift;
int err;
+ if (cb->table) {
+ err = cb->table(virt_to_phys(root));
+ if (err)
+ return err;
+ }
+
for (i = 0; i < PAGE_SIZE / sizeof(phys_addr_t); i++) {
if (!root->table[i])
continue;
--
2.54.0.545.g6539524ca2-goog
More information about the kexec
mailing list