Thread (6 messages) 6 messages, 4 authors, 2025-10-09

Re: [PATCH v3 19/30] liveupdate: luo_sysfs: add sysfs state monitoring

From: Pratyush Yadav <pratyush@kernel.org>
Date: 2025-10-09 10:58:40
Also in: linux-doc, linux-fsdevel, linux-mm, lkml

On Wed, Oct 08 2025, yanjun.zhu wrote:
On 8/6/25 6:44 PM, Pasha Tatashin wrote:
quoted
Introduce a sysfs interface for the Live Update Orchestrator
under /sys/kernel/liveupdate/. This interface provides a way for
userspace tools and scripts to monitor the current state of the LUO
state machine.
The main feature is a read-only file, state, which displays the
current LUO state as a string ("normal", "prepared", "frozen",
"updated"). The interface uses sysfs_notify to allow userspace
listeners (e.g., via poll) to be efficiently notified of state changes.
ABI documentation for this new sysfs interface is added in
Documentation/ABI/testing/sysfs-kernel-liveupdate.
This read-only sysfs interface complements the main ioctl interface
provided by /dev/liveupdate, which handles LUO control operations and
resource management.
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
[...]
quoted
+#include <linux/kobject.h>
+#include <linux/liveupdate.h>
+#include <linux/sysfs.h>
+#include "luo_internal.h"
+
+static bool luo_sysfs_initialized;
+
+#define LUO_DIR_NAME	"liveupdate"
+
+void luo_sysfs_notify(void)
+{
+	if (luo_sysfs_initialized)
+		sysfs_notify(kernel_kobj, LUO_DIR_NAME, "state");
+}
+
+/* Show the current live update state */
+static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
+			  char *buf)
+{
+	return sysfs_emit(buf, "%s\n", luo_current_state_str());
Because the window of kernel live update is short, it is difficult to statistics
how many times the kernel is live updated.

Is it possible to add a variable to statistics the times that the kernel is live
updated?
The kernel doesn't do the live update on its own. The process is driven
and sequenced by userspace. So if you want to keep statistics, you
should do it from your userspace (luod maybe?). I don't see any need for
this in the kernel.
For example, define a global variable of type atomic_t or u64 in the core
module:

#include <linux/atomic.h>

static atomic_t klu_counter = ATOMIC_INIT(0);


Every time a live update completes successfully, increment the counter:

atomic_inc(&klu_counter);

Then exporting this value through /proc or /sys so that user space can check it:

static ssize_t klu_counter_show(struct kobject *kobj, struct kobj_attribute
*attr, char *buf)
{
    return sprintf(buf, "%d\n", atomic_read(&klu_counter));
}

Yanjun.Zhu
[...]

-- 
Regards,
Pratyush Yadav
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help