diff mbox series

[RFC,18/32] function_graph: Fix to initalize ftrace_ops for fgraph with ftrace_graph_func

Message ID 169920060974.482486.15664806338999944098.stgit@devnote2 (mailing list archive)
State Superseded
Headers show
Series tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph | expand

Commit Message

Masami Hiramatsu (Google) Nov. 5, 2023, 4:10 p.m. UTC
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Fix to initialize the ftrace_ops of fgraph_ops with ftrace_graph_func
instead of ftrace_stub.

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 kernel/trace/fgraph.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Masami Hiramatsu (Google) Nov. 6, 2023, 10:04 a.m. UTC | #1
On Mon,  6 Nov 2023 01:10:10 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Fix to initialize the ftrace_ops of fgraph_ops with ftrace_graph_func
> instead of ftrace_stub.

I've changed this, because fprobe entry handler is not called via
fgraph without this. But maybe I have to set correct gops->ops.func
after init?

Thank you,

> 
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
>  kernel/trace/fgraph.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
> index 597250bd30dc..858fb73440ec 100644
> --- a/kernel/trace/fgraph.c
> +++ b/kernel/trace/fgraph.c
> @@ -872,7 +872,7 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
>  void fgraph_init_ops(struct ftrace_ops *dst_ops,
>  		     struct ftrace_ops *src_ops)
>  {
> -	dst_ops->func = ftrace_stub;
> +	dst_ops->func = ftrace_graph_func;
>  	dst_ops->flags = FTRACE_OPS_FL_PID | FTRACE_OPS_FL_STUB;
>  
>  #ifdef FTRACE_GRAPH_TRAMP_ADDR
> @@ -1120,7 +1120,7 @@ int register_ftrace_graph(struct fgraph_ops *gops)
>  
>  	if (!gops->ops.func) {
>  		gops->ops.flags |= FTRACE_OPS_FL_STUB;
> -		gops->ops.func = ftrace_stub;
> +		gops->ops.func = ftrace_graph_func;
>  #ifdef FTRACE_GRAPH_TRAMP_ADDR
>  		gops->ops.trampoline = FTRACE_GRAPH_TRAMP_ADDR;
>  #endif
>
Masami Hiramatsu (Google) Nov. 7, 2023, 1:49 a.m. UTC | #2
On Mon, 6 Nov 2023 19:04:16 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Mon,  6 Nov 2023 01:10:10 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > 
> > Fix to initialize the ftrace_ops of fgraph_ops with ftrace_graph_func
> > instead of ftrace_stub.
> 
> I've changed this, because fprobe entry handler is not called via
> fgraph without this. But maybe I have to set correct gops->ops.func
> after init?

I confirmed that this is right because it is introduced by
0c0593b45c9b ("x86/ftrace: Make function graph use ftrace directly")
which replaces ftrace_stub with ftrace_graph_func (which automatically
switched by architecture)

Thanks,

> 
> Thank you,
> 
> > 
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > ---
> >  kernel/trace/fgraph.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
> > index 597250bd30dc..858fb73440ec 100644
> > --- a/kernel/trace/fgraph.c
> > +++ b/kernel/trace/fgraph.c
> > @@ -872,7 +872,7 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
> >  void fgraph_init_ops(struct ftrace_ops *dst_ops,
> >  		     struct ftrace_ops *src_ops)
> >  {
> > -	dst_ops->func = ftrace_stub;
> > +	dst_ops->func = ftrace_graph_func;
> >  	dst_ops->flags = FTRACE_OPS_FL_PID | FTRACE_OPS_FL_STUB;
> >  
> >  #ifdef FTRACE_GRAPH_TRAMP_ADDR
> > @@ -1120,7 +1120,7 @@ int register_ftrace_graph(struct fgraph_ops *gops)
> >  
> >  	if (!gops->ops.func) {
> >  		gops->ops.flags |= FTRACE_OPS_FL_STUB;
> > -		gops->ops.func = ftrace_stub;
> > +		gops->ops.func = ftrace_graph_func;
> >  #ifdef FTRACE_GRAPH_TRAMP_ADDR
> >  		gops->ops.trampoline = FTRACE_GRAPH_TRAMP_ADDR;
> >  #endif
> > 
> 
> 
> -- 
> Masami Hiramatsu (Google) <mhiramat@kernel.org>
Steven Rostedt Nov. 7, 2023, 3:07 a.m. UTC | #3
On Tue, 7 Nov 2023 10:49:24 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> > I've changed this, because fprobe entry handler is not called via
> > fgraph without this. But maybe I have to set correct gops->ops.func
> > after init?  
> 
> I confirmed that this is right because it is introduced by
> 0c0593b45c9b ("x86/ftrace: Make function graph use ftrace directly")
> which replaces ftrace_stub with ftrace_graph_func (which automatically
> switched by architecture)

Agreed.

-- Steve
diff mbox series

Patch

diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index 597250bd30dc..858fb73440ec 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -872,7 +872,7 @@  unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
 void fgraph_init_ops(struct ftrace_ops *dst_ops,
 		     struct ftrace_ops *src_ops)
 {
-	dst_ops->func = ftrace_stub;
+	dst_ops->func = ftrace_graph_func;
 	dst_ops->flags = FTRACE_OPS_FL_PID | FTRACE_OPS_FL_STUB;
 
 #ifdef FTRACE_GRAPH_TRAMP_ADDR
@@ -1120,7 +1120,7 @@  int register_ftrace_graph(struct fgraph_ops *gops)
 
 	if (!gops->ops.func) {
 		gops->ops.flags |= FTRACE_OPS_FL_STUB;
-		gops->ops.func = ftrace_stub;
+		gops->ops.func = ftrace_graph_func;
 #ifdef FTRACE_GRAPH_TRAMP_ADDR
 		gops->ops.trampoline = FTRACE_GRAPH_TRAMP_ADDR;
 #endif