From: Chris Down <chris@chrisdown.name>
To: Pasha Tatashin <pasha.tatashin@soleen.com>,
Mike Rapoport <rppt@kernel.org>,
Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>,
Baoquan He <baoquan.he@linux.dev>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
kexec@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org, kernel-team@meta.com,
Breno Leitao <leitao@debian.org>,
sashiko-bot@kernel.org
Subject: [PATCH v2 4/7] kho: Expose rejected handovers that look like cold boots
Date: Sat, 28 Nov 2026 10:27:38 -0800 [thread overview]
Message-ID: <3131fae711e7e2350689ebf4dbf5cb8209625cf5.1795857773.git.chris@chrisdown.name> (raw)
In-Reply-To: <cover.1795857773.git.chris@chrisdown.name>
At Meta, our rollout needs to stop if the new kernel rejects the KHO
handover. For example, if it doesn't recognise the handover FDT's
compatible string, it can boot normally with all the preserved state
lost. LUO's incoming/state reads "none", as on a cold boot. We log
"disabling KHO revival", but our fleet collector reads procfs and sysfs
and can't rely on kernel logs from every host.
Let's add /sys/kernel/kho/incoming/state so the collector can tell a
rejected handover from an ordinary boot. "revived" means the kernel
accepted the handover and completed the preserved memory map walk. LUO
reports the outcome of restoring sessions separately.
KHO has no sysfs directory yet, so this adds /sys/kernel/kho in its own
file, kho_sysfs.c. It is set up separately from kho_init(), because
kho_init() returns early when KHO is disabled, and a rejected handover
still needs to be reported then.
Signed-off-by: Chris Down <chris@chrisdown.name>
---
.../ABI/testing/sysfs-class-misc-liveupdate | 3 ++
Documentation/ABI/testing/sysfs-kernel-kho | 11 ++++
Documentation/admin-guide/mm/kho.rst | 8 +++
MAINTAINERS | 2 +
kernel/liveupdate/Makefile | 2 +-
kernel/liveupdate/kexec_handover.c | 9 ++++
kernel/liveupdate/kexec_handover_internal.h | 8 +++
kernel/liveupdate/kho_sysfs.c | 54 +++++++++++++++++++
8 files changed, 96 insertions(+), 1 deletion(-)
create mode 100644 Documentation/ABI/testing/sysfs-kernel-kho
create mode 100644 kernel/liveupdate/kho_sysfs.c
diff --git a/Documentation/ABI/testing/sysfs-class-misc-liveupdate b/Documentation/ABI/testing/sysfs-class-misc-liveupdate
index 25e3b49d7aeb..8c3814ee3d37 100644
--- a/Documentation/ABI/testing/sysfs-class-misc-liveupdate
+++ b/Documentation/ABI/testing/sysfs-class-misc-liveupdate
@@ -19,6 +19,9 @@ Description: read only
"deserialized" The sessions can be retrieved.
"failed" Deserialization failed. Opening
/dev/liveupdate returns -EIO.
+
+ See /sys/kernel/kho/incoming/state for the status of
+ the underlying KHO handover.
Users: system monitoring
What: /sys/class/misc/liveupdate/incoming/sessions
diff --git a/Documentation/ABI/testing/sysfs-kernel-kho b/Documentation/ABI/testing/sysfs-kernel-kho
new file mode 100644
index 000000000000..21488e35d1f3
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-kho
@@ -0,0 +1,11 @@
+What: /sys/kernel/kho/incoming/state
+Date: Nov 2026
+Contact: kexec@lists.infradead.org
+Description: read only
+ Status of the incoming KHO handover:
+
+ "none" No handover was passed to this kernel.
+ "revived" The kernel accepted the handover and completed
+ the walk of its preserved memory map.
+ "failed" The kernel rejected the handover.
+Users: system monitoring
diff --git a/Documentation/admin-guide/mm/kho.rst b/Documentation/admin-guide/mm/kho.rst
index 4281da6be5fa..8810813a5d0a 100644
--- a/Documentation/admin-guide/mm/kho.rst
+++ b/Documentation/admin-guide/mm/kho.rst
@@ -81,6 +81,14 @@ At scale, correlating crashes to the previous kernel version enables
faster root cause analysis when issues only occur in specific kernel
transition scenarios.
+sysfs Interfaces
+================
+
+``/sys/kernel/kho/incoming/state``
+ Status of the incoming KHO handover.
+
+See Documentation/ABI/testing/sysfs-kernel-kho for the sysfs ABI.
+
debugfs Interfaces
==================
diff --git a/MAINTAINERS b/MAINTAINERS
index 5c74e7dfcdc0..baf39fcc0e87 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14779,6 +14779,7 @@ L: kexec@lists.infradead.org
L: linux-mm@kvack.org
S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux.git
+F: Documentation/ABI/testing/sysfs-kernel-kho
F: Documentation/admin-guide/mm/kho.rst
F: Documentation/core-api/kho/*
F: include/asm-generic/kexec_handover.h
@@ -14786,6 +14787,7 @@ F: include/linux/kexec_handover.h
F: include/linux/kho/
F: include/linux/kho_block.h
F: kernel/liveupdate/kexec_handover*
+F: kernel/liveupdate/kho_sysfs.c
F: lib/test_kho.c
F: tools/testing/selftests/kho/
diff --git a/kernel/liveupdate/Makefile b/kernel/liveupdate/Makefile
index d9f469462556..6de82ffe8d40 100644
--- a/kernel/liveupdate/Makefile
+++ b/kernel/liveupdate/Makefile
@@ -7,7 +7,7 @@ luo-y := \
luo_flb.o \
luo_session.o
-obj-$(CONFIG_KEXEC_HANDOVER) += kexec_handover.o
+obj-$(CONFIG_KEXEC_HANDOVER) += kexec_handover.o kho_sysfs.o
obj-$(CONFIG_KEXEC_HANDOVER_DEBUGFS) += kexec_handover_debugfs.o
obj-$(CONFIG_LIVEUPDATE) += luo.o
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 233c126f6352..aff96aa401f8 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -102,6 +102,7 @@ struct kho_in {
phys_addr_t bootmem_phys;
char previous_release[__NEW_UTS_LEN + 1];
u32 kexec_count;
+ enum kho_incoming_state state;
struct kho_debugfs dbg;
struct kho_radix_tree radix_tree;
};
@@ -1744,6 +1745,7 @@ err:
*/
kho_in.fdt_phys = 0;
kho_in.radix_tree.root = NULL;
+ kho_in.state = KHO_INCOMING_FAILED;
}
static __init int kho_out_fdt_setup(void)
@@ -1770,6 +1772,11 @@ static __init int kho_out_fdt_setup(void)
return err;
}
+enum kho_incoming_state kho_in_state(void)
+{
+ return kho_in.state;
+}
+
static void __init kho_in_kexec_metadata(void)
{
struct kho_kexec_metadata *metadata;
@@ -1981,6 +1988,7 @@ err:
*/
kho_in.fdt_phys = 0;
kho_in.bootmem_phys = 0;
+ kho_in.state = KHO_INCOMING_FAILED;
}
void __init kho_memory_init(void)
@@ -2079,6 +2087,7 @@ unmap_bootmem:
unmap_fdt:
early_memunmap(fdt, fdt_len);
report:
+ kho_in.state = populated ? KHO_INCOMING_REVIVED : KHO_INCOMING_FAILED;
if (!populated)
pr_warn("disabling KHO revival\n");
}
diff --git a/kernel/liveupdate/kexec_handover_internal.h b/kernel/liveupdate/kexec_handover_internal.h
index e9685e1ef6d7..b559f5d43116 100644
--- a/kernel/liveupdate/kexec_handover_internal.h
+++ b/kernel/liveupdate/kexec_handover_internal.h
@@ -22,6 +22,14 @@ struct kho_debugfs {};
extern struct kho_bootmem *kho_bootmem;
extern unsigned int kho_bootmem_cnt;
+enum kho_incoming_state {
+ KHO_INCOMING_NONE,
+ KHO_INCOMING_REVIVED,
+ KHO_INCOMING_FAILED,
+};
+
+enum kho_incoming_state kho_in_state(void);
+
#ifdef CONFIG_KEXEC_HANDOVER_DEBUGFS
int kho_debugfs_init(void);
void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt);
diff --git a/kernel/liveupdate/kho_sysfs.c b/kernel/liveupdate/kho_sysfs.c
new file mode 100644
index 000000000000..eb2e4ce72f20
--- /dev/null
+++ b/kernel/liveupdate/kho_sysfs.c
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * kho_sysfs.c - kexec handover sysfs interfaces
+ */
+
+#include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
+#include "kexec_handover_internal.h"
+
+static const char * const kho_incoming_state_names[] = {
+ [KHO_INCOMING_NONE] = "none",
+ [KHO_INCOMING_REVIVED] = "revived",
+ [KHO_INCOMING_FAILED] = "failed",
+};
+
+static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
+ char *buf)
+{
+ return sysfs_emit(buf, "%s\n", kho_incoming_state_names[kho_in_state()]);
+}
+static struct kobj_attribute state_attr = __ATTR_RO(state);
+
+static struct attribute *incoming_attrs[] = {
+ &state_attr.attr,
+ NULL
+};
+
+static const struct attribute_group incoming_group = {
+ .name = "incoming",
+ .attrs = incoming_attrs,
+};
+
+/*
+ * Set up separately from kho_init(), because kho_init() returns early
+ * when KHO is disabled, and a rejected handover still needs to be
+ * reported then.
+ */
+static int __init kho_sysfs_init(void)
+{
+ struct kobject *kho_kobj;
+ int err;
+
+ kho_kobj = kobject_create_and_add("kho", kernel_kobj);
+ if (!kho_kobj)
+ return -ENOMEM;
+
+ err = sysfs_create_group(kho_kobj, &incoming_group);
+ if (err)
+ kobject_put(kho_kobj);
+
+ return err;
+}
+late_initcall(kho_sysfs_init);
--
2.56.1
next prev parent reply other threads:[~2026-11-28 18:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 18:27 [PATCH v2 0/7] kho, liveupdate: KHO/LUO observability Chris Down
2026-11-28 18:27 ` [PATCH v2 1/7] kho: Reclaim the metadata page left reserved after kexec Chris Down
2026-11-28 18:27 ` [PATCH v2 2/7] liveupdate: Make failed retrieves distinguishable from dropped files Chris Down
2026-11-28 18:27 ` [PATCH v2 3/7] selftests/liveupdate: Catch incorrect file accounting across kexec Chris Down
2026-11-28 18:27 ` Chris Down [this message]
2026-11-28 18:27 ` [PATCH v2 5/7] kho: Report how much handover memory is preserved and restored Chris Down
2026-11-28 18:27 ` [PATCH v2 6/7] liveupdate: Expose the sequence number for consecutive live updates Chris Down
2026-11-28 18:27 ` [PATCH v2 7/7] selftests/liveupdate: Check handover revival, sequence and memory stats Chris Down
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=3131fae711e7e2350689ebf4dbf5cb8209625cf5.1795857773.git.chris@chrisdown.name \
--to=chris@chrisdown.name \
--cc=baoquan.he@linux.dev \
--cc=corbet@lwn.net \
--cc=graf@amazon.com \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=leitao@debian.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=rppt@kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=skhan@linuxfoundation.org \
/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
all inboxes | Powered by JetHome®