* [PATCH] tracing: Add notrace to event functions that hook to ftrace
@ 2026-11-19 17:43 Steven Rostedt
2026-11-19 17:56 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2026-11-19 17:43 UTC (permalink / raw)
To: LKML, Linux Trace Kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Mark Rutland
From: Steven Rostedt <rostedt@goodmis.org>
A few functions in trace_events.c are used to hook to the ftrace function
hooks. Before CONFIG_FUNCTION_SELF_TRACING was added, these functions were not
marked for tracing because the entire directory was set to "notrace". But
now that certain files can be traced by ftrace when the
CONFIG_FUNCTION_SELF_TRACING config is set, individual functions that use ftrace
must be annotated with "notrace" otherwise they can trigger a triple fault
when called.
Annotate the trace_events.c functions that are attached to ftrace with
"notrace.
Cc: stable@vger.kernel.org
Fixes: f93a7d0caccd6 ("ftrace: Allow tracing of some of the tracing code")
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_events.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index c9d31c9f3fca..7f89160aeff3 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -4317,7 +4317,7 @@ static void update_event_probe(struct event_probe_data *data)
set_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &data->file->flags);
}
-static void
+static void notrace
event_enable_probe(unsigned long ip, unsigned long parent_ip,
struct trace_array *tr, struct ftrace_probe_ops *ops,
void *data)
@@ -4334,7 +4334,7 @@ event_enable_probe(unsigned long ip, unsigned long parent_ip,
update_event_probe(edata);
}
-static void
+static void notrace
event_enable_count_probe(unsigned long ip, unsigned long parent_ip,
struct trace_array *tr, struct ftrace_probe_ops *ops,
void *data)
@@ -5205,7 +5205,7 @@ static DEFINE_PER_CPU(atomic_t, ftrace_test_event_disable);
static struct trace_event_file event_trace_file __initdata;
-static void __init
+static void notrace __init
function_test_events_call(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *op, struct ftrace_regs *regs)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tracing: Add notrace to event functions that hook to ftrace
2026-11-19 17:43 [PATCH] tracing: Add notrace to event functions that hook to ftrace Steven Rostedt
@ 2026-11-19 17:56 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-19 17:56 UTC (permalink / raw)
To: Steven Rostedt, Linux Trace Kernel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] tracing: missing notrace on update_event_probe() causes ftrace
recursion
--
commit fa7d6fcf36a58e2cb33d20aff7d184dfe9c6060d
Author: Steven Rostedt <rostedt@goodmis.org>
tracing: Add notrace to event functions that hook to ftrace
This commit adds the notrace annotation to event_enable_probe(),
event_enable_count_probe(), and function_test_events_call() so they are
not traced when CONFIG_FUNCTION_SELF_TRACING is enabled.
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 6afed2091e19c..fa8927068609a 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -4317,7 +4317,7 @@ static void update_event_probe(struct event_probe_data *data)
> set_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &data->file->flags);
> }
>
> -static void
> +static void notrace
> event_enable_probe(unsigned long ip, unsigned long parent_ip,
> struct trace_array *tr, struct ftrace_probe_ops *ops,
> void *data)
> @@ -4334,7 +4334,7 @@ event_enable_probe(unsigned long ip, unsigned long parent_ip,
> update_event_probe(edata);
> }
>
> -static void
> +static void notrace
> event_enable_count_probe(unsigned long ip, unsigned long parent_ip,
> struct trace_array *tr, struct ftrace_probe_ops *ops,
> void *data)
[Severity: High]
Should update_event_probe() also be marked notrace (or inline)?
Both event_enable_probe() and event_enable_count_probe() run via
function_trace_probe_call() without FTRACE_OPS_FL_RECURSION and call
update_event_probe(). Because update_event_probe() is neither notrace nor
inline, GCC cannot inline it into its notrace callers and emits it with
an ftrace entry hook under CONFIG_FUNCTION_SELF_TRACING. If an
enable_event or disable_event function probe matches update_event_probe()
(for example via a wildcard filter in set_ftrace_filter), calling
update_event_probe() re-enters function_trace_probe_call() and recurses
until the stack overflows.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119124319.3a8bfe50@gandalf.local.home?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 17:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 17:43 [PATCH] tracing: Add notrace to event functions that hook to ftrace Steven Rostedt
2026-11-19 17:56 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox