* [for-linus][PATCH 0/2] ftrace: Fixes for v6.18
@ 2025-11-27 1:02 Steven Rostedt
2025-11-27 1:02 ` [for-linus][PATCH 1/2] fgraph: Initialize ftrace_ops->private for function graph ops Steven Rostedt
2025-11-27 1:02 ` [for-linus][PATCH 2/2] fgraph: Check ftrace_pids_enabled on registration for early filtering Steven Rostedt
0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-11-27 1:02 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton
ftrace fixes for v6.18:
- Fix regression of pid filtering of function graph tracer
When the function graph tracer allowed multiple instances of
graph tracing using subops, the filtering by pid broke.
The ftrace_ops->private that was used for pid filtering wasn't
updated on creation.
The wrong function entry callback was used when pid filtering was
enabled when the function graph tracer started, which meant that
the pid filtering wasn't happening.
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
ftrace/fixes
Head SHA1: 1650a1b6cb1ae6cb99bb4fce21b30ebdf9fc238e
Shengming Hu (2):
fgraph: Initialize ftrace_ops->private for function graph ops
fgraph: Check ftrace_pids_enabled on registration for early filtering
----
kernel/trace/fgraph.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread* [for-linus][PATCH 1/2] fgraph: Initialize ftrace_ops->private for function graph ops
2025-11-27 1:02 [for-linus][PATCH 0/2] ftrace: Fixes for v6.18 Steven Rostedt
@ 2025-11-27 1:02 ` Steven Rostedt
2025-11-27 1:02 ` [for-linus][PATCH 2/2] fgraph: Check ftrace_pids_enabled on registration for early filtering Steven Rostedt
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-11-27 1:02 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
stable, wang.yaxin, zhang.run, yang.yang29, Shengming Hu
From: Shengming Hu <hu.shengming@zte.com.cn>
The ftrace_pids_enabled(op) check relies on op->private being properly
initialized, but fgraph_ops's underlying ftrace_ops->private was left
uninitialized. This caused ftrace_pids_enabled() to always return false,
effectively disabling PID filtering for function graph tracing.
Fix this by copying src_ops->private to dst_ops->private in
fgraph_init_ops(), ensuring PID filter state is correctly propagated.
Cc: stable@vger.kernel.org
Cc: <wang.yaxin@zte.com.cn>
Cc: <mhiramat@kernel.org>
Cc: <mark.rutland@arm.com>
Cc: <mathieu.desnoyers@efficios.com>
Cc: <zhang.run@zte.com.cn>
Cc: <yang.yang29@zte.com.cn>
Fixes: c132be2c4fcc1 ("function_graph: Have the instances use their own ftrace_ops for filtering")
Link: https://patch.msgid.link/20251126172926004y3hC8QyU4WFOjBkU_UxLC@zte.com.cn
Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/fgraph.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index 484ad7a18463..d6222bb99d1d 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -1019,6 +1019,7 @@ void fgraph_init_ops(struct ftrace_ops *dst_ops,
mutex_init(&dst_ops->local_hash.regex_lock);
INIT_LIST_HEAD(&dst_ops->subop_list);
dst_ops->flags |= FTRACE_OPS_FL_INITIALIZED;
+ dst_ops->private = src_ops->private;
}
#endif
}
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [for-linus][PATCH 2/2] fgraph: Check ftrace_pids_enabled on registration for early filtering
2025-11-27 1:02 [for-linus][PATCH 0/2] ftrace: Fixes for v6.18 Steven Rostedt
2025-11-27 1:02 ` [for-linus][PATCH 1/2] fgraph: Initialize ftrace_ops->private for function graph ops Steven Rostedt
@ 2025-11-27 1:02 ` Steven Rostedt
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-11-27 1:02 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
stable, wang.yaxin, zhang.run, yang.yang29, Shengming Hu
From: Shengming Hu <hu.shengming@zte.com.cn>
When registering ftrace_graph, check if ftrace_pids_enabled is active.
If enabled, assign entryfunc to fgraph_pid_func to ensure filtering
is performed before executing the saved original entry function.
Cc: stable@vger.kernel.org
Cc: <wang.yaxin@zte.com.cn>
Cc: <mhiramat@kernel.org>
Cc: <mark.rutland@arm.com>
Cc: <mathieu.desnoyers@efficios.com>
Cc: <zhang.run@zte.com.cn>
Cc: <yang.yang29@zte.com.cn>
Link: https://patch.msgid.link/20251126173331679XGVF98NLhyLJRdtNkVZ6w@zte.com.cn
Fixes: df3ec5da6a1e7 ("function_graph: Add pid tracing back to function graph tracer")
Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/fgraph.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index d6222bb99d1d..599f2939cd94 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -1377,6 +1377,13 @@ int register_ftrace_graph(struct fgraph_ops *gops)
ftrace_graph_active++;
+ /* Always save the function, and reset at unregistering */
+ gops->saved_func = gops->entryfunc;
+#ifdef CONFIG_DYNAMIC_FTRACE
+ if (ftrace_pids_enabled(&gops->ops))
+ gops->entryfunc = fgraph_pid_func;
+#endif
+
if (ftrace_graph_active == 2)
ftrace_graph_disable_direct(true);
@@ -1396,8 +1403,6 @@ int register_ftrace_graph(struct fgraph_ops *gops)
} else {
init_task_vars(gops->idx);
}
- /* Always save the function, and reset at unregistering */
- gops->saved_func = gops->entryfunc;
gops->ops.flags |= FTRACE_OPS_FL_GRAPH;
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-27 1:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-27 1:02 [for-linus][PATCH 0/2] ftrace: Fixes for v6.18 Steven Rostedt
2025-11-27 1:02 ` [for-linus][PATCH 1/2] fgraph: Initialize ftrace_ops->private for function graph ops Steven Rostedt
2025-11-27 1:02 ` [for-linus][PATCH 2/2] fgraph: Check ftrace_pids_enabled on registration for early filtering Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox