The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] tracing/eprobe: Install the trigger for every instance that enables the eprobe
@ 2026-10-31 20:39 David Carlier
  2026-11-06 10:56 ` Masami Hiramatsu (Google)
  0 siblings, 1 reply; 2+ messages in thread
From: David Carlier @ 2026-10-31 20:39 UTC (permalink / raw)
  To: Masami Hiramatsu, Steven Rostedt
  Cc: Mathieu Desnoyers, linux-trace-kernel, linux-kernel,
	David Carlier, stable

The eprobe trigger lives in the instance of the enabling file, but it is
only added when the eprobe is first enabled and only removed when the
last file goes away. A second instance then records nothing, and the
first instance's trigger is left behind once the eprobe is disabled
there, so the eprobe can be deleted while that trigger still uses it.

Add and remove the trigger for each file.

Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")
Cc: stable@vger.kernel.org
Signed-off-by: David Carlier <devnexen@gmail.com>
---
 kernel/trace/trace_eprobe.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
index 998e6390937a..a0bc6fa1fc69 100644
--- a/kernel/trace/trace_eprobe.c
+++ b/kernel/trace/trace_eprobe.c
@@ -661,20 +661,20 @@ static int enable_trace_eprobe(struct trace_event_call *call,
 	} else
 		trace_probe_set_flag(tp, TP_FLAG_PROFILE);
 
-	if (enabled)
+	/* The trigger lives in the instance of the file, add it for each file */
+	if (!file && enabled)
 		return 0;
 
 	for_each_trace_eprobe_tp(ep, tp) {
 		ret = enable_eprobe(ep, file);
 		if (ret)
 			break;
-		enabled = true;
 		cnt++;
 	}
 
 	if (ret) {
 		/* Failed to enable one of them. Roll back all */
-		if (enabled) {
+		if (cnt) {
 			/*
 			 * It's a bug if one failed for something other than memory
 			 * not being available but another eprobe succeeded.
@@ -709,18 +709,11 @@ static int disable_trace_eprobe(struct trace_event_call *call,
 	if (file) {
 		if (!trace_probe_get_file_link(tp, file))
 			return -ENOENT;
-		if (!trace_probe_has_single_file(tp))
-			goto out;
-		trace_probe_clear_flag(tp, TP_FLAG_TRACE);
-	} else
-		trace_probe_clear_flag(tp, TP_FLAG_PROFILE);
-
-	if (!trace_probe_is_enabled(tp)) {
 		for_each_trace_eprobe_tp(ep, tp)
 			disable_eprobe(ep, file->tr);
-	}
+	} else
+		trace_probe_clear_flag(tp, TP_FLAG_PROFILE);
 
- out:
 	if (file)
 		/*
 		 * Synchronization is done in below function. For perf event,
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tracing/eprobe: Install the trigger for every instance that enables the eprobe
  2026-10-31 20:39 [PATCH] tracing/eprobe: Install the trigger for every instance that enables the eprobe David Carlier
@ 2026-11-06 10:56 ` Masami Hiramatsu (Google)
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-11-06 10:56 UTC (permalink / raw)
  To: David Carlier
  Cc: Steven Rostedt, Mathieu Desnoyers, linux-trace-kernel,
	linux-kernel

On Sat, 31 Oct 2026 20:39:15 +0000, David Carlier <devnexen@gmail.com> wrote:

> diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> --- a/kernel/trace/trace_eprobe.c
> +++ b/kernel/trace/trace_eprobe.c
> @@ -661,20 +661,20 @@ static int enable_trace_eprobe(struct trace_event_call *call,
>  		trace_probe_set_flag(tp, TP_FLAG_PROFILE);
>  
> +	/* The trigger lives in the instance of the file, add it for each file */
> +	if (!file && enabled)

Hmm, when reviewing this patch, I found file should not be NULL
because enable/disable_trace_eprobe() are only ever called via
eprobe_register() with `TRACE_REG_REGISTER/UNREGISTER` where `file` is
always non-NULL.

So we should expect !file case is a bug. So at the entry of these functions
we can add:

	if (WARN_ON_ONCE(!file))
		return -EINVAL;

and remove !file blocks.

Thanks!

>  		return 0;
>  
>  	for_each_trace_eprobe_tp(ep, tp) {

-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-06 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-31 20:39 [PATCH] tracing/eprobe: Install the trigger for every instance that enables the eprobe David Carlier
2026-11-06 10:56 ` Masami Hiramatsu (Google)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox