[PATCH RESEND] function_graph: restore direct mode when callbacks drop to one

hu.shengming@zte.com.cn posted 1 patch 1 month, 2 weeks ago
kernel/trace/fgraph.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH RESEND] function_graph: restore direct mode when callbacks drop to one
Posted by hu.shengming@zte.com.cn 1 month, 2 weeks ago
From: Shengming Hu <hu.shengming@zte.com.cn>

When registering a second fgraph callback, direct path is disabled
and array loop is used instead.
When ftrace_graph_active falls back to one, we try to re-enable direct
mode via ftrace_graph_enable_direct(true, ...).
But ftrace_graph_enable_direct() incorrectly disables the static key
rather than enabling it.
This leaves fgraph_do_direct permanently off after first multi-callback
transition, so direct fast mode is never restored.

Fixes: cc60ee813b503 ("function_graph: Use static_call and branch to optimize entry function")
Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
---
 kernel/trace/fgraph.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index cc48d16be43e..4df766c690f9 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -1303,7 +1303,7 @@ static void ftrace_graph_enable_direct(bool enable_branch, struct fgraph_ops *go
 	static_call_update(fgraph_func, func);
 	static_call_update(fgraph_retfunc, retfunc);
 	if (enable_branch)
-		static_branch_disable(&fgraph_do_direct);
+		static_branch_enable(&fgraph_do_direct);
 }

 static void ftrace_graph_disable_direct(bool disable_branch)
--
2.25.1