[PATCH 3/9] liveupdate: Make failed retrieves distinguishable from dropped files
From: Chris Down
Date: Wed Nov 11 2026 - 02:56:22 EST
At Meta, we want to use live update to upgrade hypervisors in place and
preserve service fd stores across systemctl kexec. Our kernel rollout
stops automatically when host health checks fail.
We need it to stop if the new kernel can't give back state that a VMM or
service handed over. We also want to track files that userspace never
asks for.
Today the process that tries a retrieve sees its error, but a fleet
collector can't see that error or tell whether a session went unclaimed.
Opening /dev/liveupdate to check would itself trigger deserialisation on
the first open and can get in the way of the real restorer because the
device is exclusive-open. The collector polls procfs and sysfs, so it
needs a result it can read after the event.
Let's expose the incoming deserialisation state and aggregate session
and file counts under /sys/class/misc/liveupdate/incoming/. A collector
can stop the rollout on state=failed or files_failed > 0, and track
files that were dropped or are still held. The session owner already
knows which VM or service it belongs to, so there is no need to expose
session names.
Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>
---
.../ABI/testing/sysfs-class-misc-liveupdate | 44 ++++++++++++++++
Documentation/userspace-api/liveupdate.rst | 7 +++
MAINTAINERS | 1 +
kernel/liveupdate/luo_core.c | 50 +++++++++++++++++++
kernel/liveupdate/luo_file.c | 16 +++++-
kernel/liveupdate/luo_internal.h | 34 +++++++++++++
kernel/liveupdate/luo_session.c | 6 +++
7 files changed, 156 insertions(+), 2 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-class-misc-liveupdate
diff --git a/Documentation/ABI/testing/sysfs-class-misc-liveupdate b/Documentation/ABI/testing/sysfs-class-misc-liveupdate
new file mode 100644
index 000000000000..25e3b49d7aeb
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-misc-liveupdate
@@ -0,0 +1,44 @@
+What: /sys/class/misc/liveupdate/incoming/
+Date: Nov 2026
+Contact: kexec@xxxxxxxxxxxxxxxxxxx
+Description:
+ Incoming Live Update Orchestrator (LUO) state and counters.
+ Present when live update is enabled. Each attribute is read
+ independently.
+Users: system monitoring
+
+What: /sys/class/misc/liveupdate/incoming/state
+Date: Nov 2026
+Contact: kexec@xxxxxxxxxxxxxxxxxxx
+Description: read only
+ Status of incoming LUO sessions:
+
+ "none" No sessions were handed over.
+ "pending" Deserialization has not finished. It
+ starts on the first open of /dev/liveupdate.
+ "deserialized" The sessions can be retrieved.
+ "failed" Deserialization failed. Opening
+ /dev/liveupdate returns -EIO.
+Users: system monitoring
+
+What: /sys/class/misc/liveupdate/incoming/sessions
+What: /sys/class/misc/liveupdate/incoming/files
+Date: Nov 2026
+Contact: kexec@xxxxxxxxxxxxxxxxxxx
+Description: read only
+ Number of sessions deserialized and number of files in
+ those sessions, respectively. Counts can be partial while
+ state is "pending" or after it changes to "failed".
+Users: system monitoring
+
+What: /sys/class/misc/liveupdate/incoming/files_retrieved
+What: /sys/class/misc/liveupdate/incoming/files_failed
+What: /sys/class/misc/liveupdate/incoming/files_dropped
+Date: Nov 2026
+Contact: kexec@xxxxxxxxxxxxxxxxxxx
+Description: read only
+ Number of successful retrieves, permanent retrieve failures,
+ and files discarded at session finish without a recorded
+ retrieve outcome, respectively. Retrieves and failures are
+ counted when they occur.
+Users: system monitoring
diff --git a/Documentation/userspace-api/liveupdate.rst b/Documentation/userspace-api/liveupdate.rst
index cdd74627ab75..39bbb91d0dd4 100644
--- a/Documentation/userspace-api/liveupdate.rst
+++ b/Documentation/userspace-api/liveupdate.rst
@@ -45,6 +45,13 @@ For details, see:
- `sd_pid_notify_with_fds(3)
<https://www.freedesktop.org/software/systemd/man/latest/sd_pid_notify_with_fds.html>`_
+Monitoring
+==========
+
+Read ``/sys/class/misc/liveupdate/incoming/`` to monitor incoming
+sessions and file retrievals without opening ``/dev/liveupdate``.
+See Documentation/ABI/testing/sysfs-class-misc-liveupdate for the sysfs ABI.
+
See Also
========
diff --git a/MAINTAINERS b/MAINTAINERS
index 1572f6c905aa..b98b95cd6d12 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15523,6 +15523,7 @@ L: kexec@xxxxxxxxxxxxxxxxxxx
L: linux-kernel@xxxxxxxxxxxxxxx
S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux.git
+F: Documentation/ABI/testing/sysfs-class-misc-liveupdate
F: Documentation/core-api/liveupdate.rst
F: Documentation/mm/memfd_preservation.rst
F: Documentation/userspace-api/liveupdate.rst
diff --git a/kernel/liveupdate/luo_core.c b/kernel/liveupdate/luo_core.c
index 1b2bda22902d..ba174e9aae03 100644
--- a/kernel/liveupdate/luo_core.c
+++ b/kernel/liveupdate/luo_core.c
@@ -75,6 +75,8 @@ static struct {
*/
DECLARE_RWSEM(luo_register_rwlock);
+struct luo_incoming_stats luo_incoming_stats;
+
static int __init early_liveupdate_param(char *buf)
{
return kstrtobool(buf, &luo_global.enabled);
@@ -423,11 +425,59 @@ static const struct file_operations luo_fops = {
.unlocked_ioctl = luo_ioctl,
};
+static const char * const luo_incoming_state_names[] = {
+ [LUO_INCOMING_NONE] = "none",
+ [LUO_INCOMING_PENDING] = "pending",
+ [LUO_INCOMING_DESERIALIZED] = "deserialized",
+ [LUO_INCOMING_FAILED] = "failed",
+};
+
+static ssize_t state_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ enum luo_incoming_state state = READ_ONCE(luo_incoming_stats.state);
+
+ return sysfs_emit(buf, "%s\n", luo_incoming_state_names[state]);
+}
+static DEVICE_ATTR_RO(state);
+
+#define LUO_INCOMING_ATTR_RO(_name) \
+static ssize_t _name##_show(struct device *dev, \
+ struct device_attribute *attr, char *buf) \
+{ \
+ return sysfs_emit(buf, "%ld\n", \
+ atomic_long_read(&luo_incoming_stats._name)); \
+} \
+static DEVICE_ATTR_RO(_name)
+
+LUO_INCOMING_ATTR_RO(sessions);
+LUO_INCOMING_ATTR_RO(files);
+LUO_INCOMING_ATTR_RO(files_retrieved);
+LUO_INCOMING_ATTR_RO(files_failed);
+LUO_INCOMING_ATTR_RO(files_dropped);
+
+static struct attribute *luo_incoming_attrs[] = {
+ &dev_attr_state.attr,
+ &dev_attr_sessions.attr,
+ &dev_attr_files.attr,
+ &dev_attr_files_retrieved.attr,
+ &dev_attr_files_failed.attr,
+ &dev_attr_files_dropped.attr,
+ NULL
+};
+
+static const struct attribute_group luo_incoming_group = {
+ .name = "incoming",
+ .attrs = luo_incoming_attrs,
+};
+__ATTRIBUTE_GROUPS(luo_incoming);
+
static struct luo_device_state luo_dev = {
.miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "liveupdate",
.fops = &luo_fops,
+ .groups = luo_incoming_groups,
},
.in_use = ATOMIC_INIT(0),
};
diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
index a39992da504f..3aac1afa05c0 100644
--- a/kernel/liveupdate/luo_file.c
+++ b/kernel/liveupdate/luo_file.c
@@ -543,6 +543,16 @@ void luo_file_unfreeze(struct luo_file_set *file_set,
memset(file_set_ser, 0, sizeof(*file_set_ser));
}
+/* Record the first retrieve result. A negative status is permanent. */
+static void luo_file_set_retrieve_status(struct luo_file *luo_file, int status)
+{
+ luo_file->retrieve_status = status;
+ if (status > 0)
+ atomic_long_inc(&luo_incoming_stats.files_retrieved);
+ else
+ atomic_long_inc(&luo_incoming_stats.files_failed);
+}
+
/**
* luo_retrieve_file - Restores a preserved file from a file_set by its token.
* @file_set: The file_set from which to retrieve the file.
@@ -611,7 +621,7 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token,
err = luo_file->fh->ops->retrieve(&args);
if (err) {
/* Keep the error code for later use. */
- luo_file->retrieve_status = err;
+ luo_file_set_retrieve_status(luo_file, err);
return err;
}
@@ -624,7 +634,7 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token,
luo_file->file, GFP_KERNEL));
*filep = luo_file->file;
- luo_file->retrieve_status = 1;
+ luo_file_set_retrieve_status(luo_file, 1);
return 0;
}
@@ -719,6 +729,8 @@ int luo_file_finish(struct luo_file_set *file_set)
struct luo_file, list);
luo_file_finish_one(file_set, luo_file);
+ if (!luo_file->retrieve_status)
+ atomic_long_inc(&luo_incoming_stats.files_dropped);
if (luo_file->file) {
xa_erase(&luo_preserved_files,
diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_internal.h
index dac6644bfb18..504963fc9898 100644
--- a/kernel/liveupdate/luo_internal.h
+++ b/kernel/liveupdate/luo_internal.h
@@ -77,6 +77,40 @@ struct luo_session {
extern struct rw_semaphore luo_register_rwlock;
+/**
+ * enum luo_incoming_state - Deserialization state of incoming sessions
+ * @LUO_INCOMING_NONE: No incoming sessions.
+ * @LUO_INCOMING_PENDING: Deserialization has not finished.
+ * @LUO_INCOMING_DESERIALIZED: Sessions are ready to retrieve.
+ * @LUO_INCOMING_FAILED: Deserialization failed.
+ */
+enum luo_incoming_state {
+ LUO_INCOMING_NONE,
+ LUO_INCOMING_PENDING,
+ LUO_INCOMING_DESERIALIZED,
+ LUO_INCOMING_FAILED,
+};
+
+/**
+ * struct luo_incoming_stats - Incoming session and file counters
+ * @state: Deserialization state.
+ * @sessions: Sessions deserialized.
+ * @files: Files in deserialized sessions.
+ * @files_retrieved: Files retrieved.
+ * @files_failed: Permanent retrieve failures.
+ * @files_dropped: Files discarded without a retrieve outcome.
+ */
+struct luo_incoming_stats {
+ enum luo_incoming_state state;
+ atomic_long_t sessions;
+ atomic_long_t files;
+ atomic_long_t files_retrieved;
+ atomic_long_t files_failed;
+ atomic_long_t files_dropped;
+};
+
+extern struct luo_incoming_stats luo_incoming_stats;
+
static inline struct liveupdate_session *luo_session_from_file_set(struct luo_file_set *file_set)
{
struct luo_session *session;
diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c
index 74bc66929f4b..1a40607bfc45 100644
--- a/kernel/liveupdate/luo_session.c
+++ b/kernel/liveupdate/luo_session.c
@@ -549,6 +549,7 @@ int __init luo_session_setup_incoming(u64 sessions_pa)
return err;
sh->active = true;
+ luo_incoming_stats.state = LUO_INCOMING_PENDING;
return 0;
}
@@ -583,6 +584,9 @@ static int luo_session_deserialize_one(struct luo_session_header *sh,
return err;
}
+ atomic_long_inc(&luo_incoming_stats.sessions);
+ atomic_long_add(session->file_set.count, &luo_incoming_stats.files);
+
return 0;
}
@@ -626,12 +630,14 @@ int luo_session_deserialize(void)
}
kho_block_set_destroy(&sh->block_set);
+ WRITE_ONCE(luo_incoming_stats.state, LUO_INCOMING_DESERIALIZED);
return 0;
save_err:
kho_block_set_destroy(&sh->block_set);
saved_err = err;
+ WRITE_ONCE(luo_incoming_stats.state, LUO_INCOMING_FAILED);
return err;
}
--
2.54.0