Skip to content

Commit 1650a1b

Browse files
HSM6236rostedt
authored andcommitted
fgraph: Check ftrace_pids_enabled on registration for early filtering
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: df3ec5d ("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>
1 parent b5d6d3f commit 1650a1b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

kernel/trace/fgraph.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,13 @@ int register_ftrace_graph(struct fgraph_ops *gops)
13771377

13781378
ftrace_graph_active++;
13791379

1380+
/* Always save the function, and reset at unregistering */
1381+
gops->saved_func = gops->entryfunc;
1382+
#ifdef CONFIG_DYNAMIC_FTRACE
1383+
if (ftrace_pids_enabled(&gops->ops))
1384+
gops->entryfunc = fgraph_pid_func;
1385+
#endif
1386+
13801387
if (ftrace_graph_active == 2)
13811388
ftrace_graph_disable_direct(true);
13821389

@@ -1396,8 +1403,6 @@ int register_ftrace_graph(struct fgraph_ops *gops)
13961403
} else {
13971404
init_task_vars(gops->idx);
13981405
}
1399-
/* Always save the function, and reset at unregistering */
1400-
gops->saved_func = gops->entryfunc;
14011406

14021407
gops->ops.flags |= FTRACE_OPS_FL_GRAPH;
14031408

0 commit comments

Comments
 (0)