Re: [PATCH v7 23/36] function_graph: Add a new exit handler with parent_ip and ftrace_regs

Masami Hiramatsu
2024-02-18T02:53:34Z

On Fri, 16 Feb 2024 17:51:08 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> > > @@ -798,10 +798,6 @@ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret,
> > >
> > > *index += FGRAPH_RET_INDEX;
> > > *ret = ret_stack->ret;
> > > - trace->func = ret_stack->func;
> > > - trace->calltime = ret_stack->calltime;
> > > - trace->overrun = atomic_read(&current->trace_overrun);
> > > - trace->depth = current->curr_ret_depth;
> >
> > There's a lot of information stored in the trace structure. Why not pass
> > that to the new retregfunc?
> >
> > Then you don't need to separate this code out.
>
> Sorry, I couldn't catch what you meant, Would you mean to call
> ftrace_pop_return_trace() before calling retregfunc()?? because some of the
> information are found from ret_stack, which is poped from shadow stack.

Ah, sorry I got what you said. I think this `trace` is not usable for the new
interface. Most of the information is only used for the function-graph tracer.
For example, trace->calltime and trace->overrun, trace->depth are used only
for the function-graph tracer, but not for the other tracers.

But yeah, this idea is considerable. It also allows us to just update
entryfunc() and retfunc() to pass fgraph_regs and return address.

Thank you!

--
Masami Hiramatsu (Google) <mhiramat@kernel.org>