ftrace: Fixes for v6.18
Subsystems (3)
cover ftrace: Fixes for v6.18
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(-)
PATCH 1/2 fgraph: Initialize ftrace_ops->private for function graph ops
From: Shengming Hu <[email protected]>
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.
--- kernel/trace/fgraph.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/fgraph.c +1 -0
@@ -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 }
Signature · 1 line
2.51.0
PATCH 2/2 fgraph: Check ftrace_pids_enabled on registration for early filtering
In reply to Steven RostedtFrom: Shengming Hu <[email protected]>
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.
--- kernel/trace/fgraph.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/trace/fgraph.c +7 -2
@@ -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 ;
Signature · 1 line
2.51.0