Subject: Re: [PATCH 03/19] x86/ftrace: Make function graph use ftrace directly

From: Jiri Olsa <[email-masked]>
Date: Tue, 8 Jun 2021 20:51:25 +0200

On Tue, Jun 08, 2021 at 11:35:58AM -0700, Andrii Nakryiko wrote:

SNIP

> > diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
> > index b8a0d1d564fb..58e96b45e9da 100644
> > --- a/kernel/trace/fgraph.c
> > +++ b/kernel/trace/fgraph.c
> > @@ -115,6 +115,7 @@ int function_graph_enter(unsigned long ret, unsigned long func,
> >  {
> >         struct ftrace_graph_ent trace;
> >
> > +#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
> >         /*
> >          * Skip graph tracing if the return location is served by direct trampoline,
> >          * since call sequence and return addresses are unpredictable anyway.
> > @@ -124,6 +125,7 @@ int function_graph_enter(unsigned long ret, unsigned long func,
> >         if (ftrace_direct_func_count &&
> >             ftrace_find_rec_direct(ret - MCOUNT_INSN_SIZE))
> >                 return -EBUSY;
> > +#endif
> >         trace.func = func;
> >         trace.depth = ++current->curr_ret_depth;
> >
> > @@ -333,10 +335,10 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
> >  #endif /* HAVE_FUNCTION_GRAPH_RET_ADDR_PTR */
> >
> >  static struct ftrace_ops graph_ops = {
> > -       .func                   = ftrace_stub,
> > +       .func                   = ftrace_graph_func,
> >         .flags                  = FTRACE_OPS_FL_INITIALIZED |
> > -                                  FTRACE_OPS_FL_PID |
> > -                                  FTRACE_OPS_FL_STUB,
> > +                                  FTRACE_OPS_FL_PID
> > +                                  FTRACE_OPS_GRAPH_STUB,
> 
> nit: this looks so weird... Why not define FTRACE_OPS_GRAPH_STUB as
> zero in case of #ifdef ftrace_graph_func? Then it will be natural and
> correctly looking | FTRACE_OPS_GRAPH_STUB?

ok, I can change that

thanks,
jirka

> 
> >  #ifdef FTRACE_GRAPH_TRAMP_ADDR
> >         .trampoline             = FTRACE_GRAPH_TRAMP_ADDR,
> >         /* trampoline_size is only needed for dynamically allocated tramps */
> > --
> > 2.31.1
> >
>