[PATCH] rasdaemon: ras-events: Adapt to kernel v6.19 memory-failure trace event directory change

Junhao He posted 1 patch 1 month ago
ras-events.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
[PATCH] rasdaemon: ras-events: Adapt to kernel v6.19 memory-failure trace event directory change
Posted by Junhao He 1 month ago
Kernel v6.19 moves memory_failure_event from the "ras" trace event
group to a separate "memory_failure" group, as the event's
TRACE_SYSTEM changed from "ras" to "memory_failure". This changes
the tracefs path from events/ras/memory_failure_event to
events/memory_failure/memory_failure_event.

Add get_memory_failure_group_name() to dynamically detect which
path exists, ensuring backward compatibility with older kernels
that still use the "ras" group.

kernel commit:
    https://lore.kernel.org/all/20251119095943.67125-1-xieyuanbin1@huawei.com/

Signed-off-by: Junhao He <hejunhao3@h-partners.com>
---
 ras-events.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/ras-events.c b/ras-events.c
index ab2dd51..229ea93 100644
--- a/ras-events.c
+++ b/ras-events.c
@@ -66,6 +66,20 @@ static const struct event_trigger event_triggers[] = {
 #endif
 };
 
+#ifdef HAVE_MEMORY_FAILURE
+static const char *get_memory_failure_group_name(struct ras_events *ras)
+{
+	char fname[MAX_PATH + 1];
+
+	snprintf(fname, sizeof(fname), "%s/events/memory_failure/memory_failure_event",
+					ras->tracing);
+	if (access(fname, F_OK) == 0)
+		return "memory_failure";
+
+	return "ras"; /* fallback to old path */
+}
+#endif
+
 static int get_mountdir_by_type(char *mount_type, char *tracing_dir, size_t len)
 {
 	FILE *fp;
@@ -325,7 +339,9 @@ int toggle_ras_mc_event(int enable)
 #endif
 
 #ifdef HAVE_MEMORY_FAILURE
-	rc |= __toggle_ras_mc_event(ras, "ras", "memory_failure_event", enable);
+	const char *group = get_memory_failure_group_name(ras);
+
+	rc |= __toggle_ras_mc_event(ras, group, "memory_failure_event", enable);
 #endif
 
 #ifdef HAVE_CXL
@@ -1166,13 +1182,15 @@ int handle_ras_events(int record_events, int enable_ipmitool)
 #endif
 
 #ifdef HAVE_MEMORY_FAILURE
-	rc = add_event_handler(ras, pevent, page_size, "ras", "memory_failure_event",
+	const char *group = get_memory_failure_group_name(ras);
+
+	rc = add_event_handler(ras, pevent, page_size, group, "memory_failure_event",
 			       ras_memory_failure_event_handler, NULL, MF_EVENT);
 	if (!rc)
 		num_events++;
 	else if (rc != EVENT_DISABLED)
 		log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
-		    "ras", "memory_failure_event");
+		    group, "memory_failure_event");
 #endif
 
 #ifdef HAVE_CXL
-- 
2.33.0
Re: [PATCH] rasdaemon: ras-events: Adapt to kernel v6.19 memory-failure trace event directory change
Posted by Xie Yuanbin 1 month ago
On Thu, 27 Aug 2026 12:06:41 +0800, Junhao He wrote:
> Kernel v6.19 moves memory_failure_event from the "ras" trace event
> group to a separate "memory_failure" group, as the event's
> TRACE_SYSTEM changed from "ras" to "memory_failure". This changes
> the tracefs path from events/ras/memory_failure_event to
> events/memory_failure/memory_failure_event.
>
> Add get_memory_failure_group_name() to dynamically detect which
> path exists, ensuring backward compatibility with older kernels
> that still use the "ras" group.
>
> kernel commit:
>     https://lore.kernel.org/all/20251119095943.67125-1-xieyuanbin1@huawei.com/

Can this patch solve your problem?
Link: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e57d6e9e20b551e4910d7a6331a81775c3ad6693