Skip to contentSkip to conversation

tracing: Propagate errors from remote event bulk updates

PATCH Superseded Jackie Liu 3 participants 6 messages Jul 15 – Jul 16 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jackie Liu

author
#0 lore raw

PATCH 1/1 tracing: Propagate errors from remote event bulk updates

From: Jackie Liu <[email protected]>

remote_events_dir_enable_write() ignores the return value from trace_remote_enable_event(). If a remote rejects an event state change, the write therefore reports success even though the affected event remains in its previous state.

Keep trying all events, but retain and return the first error. This matches __ftrace_set_clr_event_nolock(), which permits partial updates while notifying userspace when an operation fails.

Fixes 775cb093bc50 ("tracing: Add events/ root files to trace remotes")
Assisted-by Codex:gpt-5.6-sol
---
 kernel/trace/trace_remote.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
kernel/trace/trace_remote.c +12 -1
index 0f6ef5c36d84..5212e685f0a3 100644
@@ -1149,11 +1149,22 @@ static ssize_t remote_events_dir_enable_write(struct file *filp, const char __us
 	guard(mutex)(&remote->lock);
 
 	for (i = 0; i < remote->nr_events; i++) {
+		int eret;
 		struct remote_event *evt = &remote->events[i];
 
-		trace_remote_enable_event(remote, evt, enable);
+		eret = trace_remote_enable_event(remote, evt, enable);
+		/*
+		 * Save the first error and return that. Some events
+		 * may still have been enabled, but let the user
+		 * know that something went wrong.
+		 */
+		if (!ret && eret)
+			ret = eret;
 	}
 
+	if (ret)
+		return ret;
+
 	return count;
 }
 
Signature · 1 line
2.54.0
#1 lore raw
Quoted 7 lines · Jackie Liu

From: Jackie Liu <[email protected]>

remote_events_dir_enable_write() ignores the return value from trace_remote_enable_event(). If a remote rejects an event state change, the write therefore reports success even though the affected event remains in its previous state.

Quoted 7 lines

Keep trying all events, but retain and return the first error. This matches __ftrace_set_clr_event_nolock(), which permits partial updates while notifying userspace when an operation fails.

Fixes 775cb093bc50 ("tracing: Add events/ root files to trace remotes")
Assisted-by Codex:gpt-5.6-sol

I have sent a related improvement for that here [1]

[1] https://lore.kernel.org/all/[email protected]/

Quoted 36 lines
---
 kernel/trace/trace_remote.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
kernel/trace/trace_remote.c +12 -1
index 0f6ef5c36d84..5212e685f0a3 100644
@@ -1149,11 +1149,22 @@ static ssize_t remote_events_dir_enable_write(struct file *filp, const char __us
 	guard(mutex)(&remote->lock);
 
 	for (i = 0; i < remote->nr_events; i++) {
+		int eret;
 		struct remote_event *evt = &remote->events[i];
 
-		trace_remote_enable_event(remote, evt, enable);
+		eret = trace_remote_enable_event(remote, evt, enable);
+		/*
+		 * Save the first error and return that. Some events
+		 * may still have been enabled, but let the user
+		 * know that something went wrong.
+		 */
+		if (!ret && eret)
+			ret = eret;
 	}
 
+	if (ret)
+		return ret;
+
 	return count;
 }
 
Signature · 1 line
2.54.0
author
#2 lore raw

2026年7月15日 14:44, "Vincent Donnefort" <[email protected] mailto:[email protected]?to=%22Vincent%20Donnefort%22%20%3Cvdonnefort%40google.com%3E > 写到:

Quoted 15 lines · Jackie Liu
Quoted 13 lines

From: Jackie Liu <[email protected]>

remote_events_dir_enable_write() ignores the return value from trace_remote_enable_event(). If a remote rejects an event state change, the write therefore reports success even though the affected event remains in its previous state.

Keep trying all events, but retain and return the first error. This matches __ftrace_set_clr_event_nolock(), which permits partial updates while notifying userspace when an operation fails.

Quoted 7 lines
Quoted 4 lines
Fixes 775cb093bc50 ("tracing: Add events/ root files to trace remotes")
Assisted-by Codex:gpt-5.6-sol

I have sent a related improvement for that here [1]

[1] https://lore.kernel.org/all/[email protected]/

Thanks for the pointer.

I checked the v2 series. Patch 02/18 handles registration failure cleanup, and patch 03/18 changes the boolean parsing in remote_events_dir_enable_write(), but the loop still ignores errors from trace_remote_enable_event().

Would you prefer this fix to be folded into your series, or should I resend a v2 rebased on top of it?

Signature · 1 line
Jackie Liu
Quoted 38 lines
Quoted 37 lines

---
 kernel/trace/trace_remote.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_remote.c b/kernel/trace/trace_remote.c
index 0f6ef5c36d84..5212e685f0a3 100644
--- a/kernel/trace/trace_remote.c
+++ b/kernel/trace/trace_remote.c
@@ -1149,11 +1149,22 @@ static ssize_t remote_events_dir_enable_write(struct file *filp, const char __us guard(mutex)(&remote->lock);

for (i = 0; i < remote->nr_events; i++) {
+ int eret;
struct remote_event *evt = &remote->events[i];

- trace_remote_enable_event(remote, evt, enable);
+ eret = trace_remote_enable_event(remote, evt, enable);
+ /*
+ * Save the first error and return that. Some events
+ * may still have been enabled, but let the user
+ * know that something went wrong.
+ */
+ if (!ret && eret)
+ ret = eret;
}

+ if (ret)
+ return ret;
+
return count;
}

--
2.54.0

#3 lore raw
Quoted 28 lines · Jackie Liu

2026年7月15日 14:44, "Vincent Donnefort" <[email protected] mailto:[email protected]?to=%22Vincent%20Donnefort%22%20%3Cvdonnefort%40google.com%3E > 写到:

Quoted 15 lines · Jackie Liu
Quoted 13 lines

From: Jackie Liu <[email protected]>

remote_events_dir_enable_write() ignores the return value from trace_remote_enable_event(). If a remote rejects an event state change, the write therefore reports success even though the affected event remains in its previous state.

Keep trying all events, but retain and return the first error. This matches __ftrace_set_clr_event_nolock(), which permits partial updates while notifying userspace when an operation fails.

Quoted 7 lines
Quoted 4 lines
Fixes 775cb093bc50 ("tracing: Add events/ root files to trace remotes")
Assisted-by Codex:gpt-5.6-sol

I have sent a related improvement for that here [1]

[1] https://lore.kernel.org/all/[email protected]/

Thanks for the pointer.

Quoted 7 lines

I checked the v2 series. Patch 02/18 handles registration failure cleanup, and patch 03/18 changes the boolean parsing in remote_events_dir_enable_write(), but the loop still ignores errors from trace_remote_enable_event().

Would you prefer this fix to be folded into your series, or should I resend a v2 rebased on top of it?

Ha yes my bad. Then no, no need to send it separately.

Quoted 20 lines
Signature · 2 lines
-- 
Jackie Liu
Quoted 13 lines
Quoted 13 lines

---
 kernel/trace/trace_remote.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_remote.c b/kernel/trace/trace_remote.c
index 0f6ef5c36d84..5212e685f0a3 100644
--- a/kernel/trace/trace_remote.c
+++ b/kernel/trace/trace_remote.c
@@ -1149,11 +1149,22 @@ static ssize_t remote_events_dir_enable_write(struct file *filp, const char __us guard(mutex)(&remote->lock);

Quoted 3 lines
Quoted 3 lines

for (i = 0; i < remote->nr_events; i++) {
+ int eret;
struct remote_event *evt = &remote->events[i];

Could you declare ert after? I have tried to use the reverse christmas tree everywhere in the trace remote code.

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines

- trace_remote_enable_event(remote, evt, enable);
+ eret = trace_remote_enable_event(remote, evt, enable);
+ /*
+ * Save the first error and return that. Some events
+ * may still have been enabled, but let the user
+ * know that something went wrong.
+ */
+ if (!ret && eret)
+ ret = eret;
}

+ if (ret)
+ return ret;
+
return count;
}

--
2.54.0

maintainer
#4 lore raw
Quoted 9 lines · On Wed, 15 Jul 2026 08:25:09 +0100 Vincent Donnefort <[email protected]>…
Quoted 7 lines

I checked the v2 series. Patch 02/18 handles registration failure cleanup, and patch 03/18 changes the boolean parsing in remote_events_dir_enable_write(), but the loop still ignores errors from trace_remote_enable_event().

Would you prefer this fix to be folded into your series, or should I resend a v2 rebased on top of it?

Ha yes my bad. Then no, no need to send it separately.

So should I take this patch and send it to Linus now?

-- Steve

#5 lore raw
Quoted 8 lines · Steven Rostedt
Quoted 5 lines · On Wed, 15 Jul 2026 08:25:09 +0100 Vincent Donnefort <[email protected]>…
Quoted 5 lines

I checked the v2 series. Patch 02/18 handles registration failure cleanup, and patch 03/18 changes the boolean parsing in remote_events_dir_enable_write(), but the loop still ignores errors from trace_remote_enable_event().

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Would you prefer this fix to be folded into your series, or should I resend a v2 rebased on top of it?

Ha yes my bad. Then no, no need to send it separately.

So should I take this patch and send it to Linus now?

There's a v2 here [1] with my Reviewed-by tag.

[1] https://lore.kernel.org/all/[email protected]/

Quoted 2 lines

-- Steve