[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251126173331679XGVF98NLhyLJRdtNkVZ6w@zte.com.cn>
Date: Wed, 26 Nov 2025 17:33:31 +0800 (CST)
From: <wang.yaxin@....com.cn>
To: <wang.yaxin@....com.cn>
Cc: <rostedt@...dmis.org>, <mhiramat@...nel.org>, <mark.rutland@....com>,
<mathieu.desnoyers@...icios.com>, <linux-kernel@...r.kernel.org>,
<linux-trace-kernel@...r.kernel.org>, <hu.shengming@....com.cn>,
<zhang.run@....com.cn>, <yang.yang29@....com.cn>
Subject: [PATCH v2 2/3] fgraph: Check ftrace_pids_enabled on registration for early filtering
From: Shengming Hu <hu.shengming@....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.
Signed-off-by: Shengming Hu <hu.shengming@....com.cn>
---
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 f6f25d81a..65ac0f04a 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -1369,6 +1369,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);
@@ -1388,8 +1395,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.25.1
Powered by blists - more mailing lists