Re: [PATCH v3 RESEND] function_graph: Enable funcgraph-args and funcgraph-retaddr to work simultaneously
From: Donglin Peng
Date: Wed Nov 12 2025 - 22:01:28 EST
On Thu, Nov 13, 2025 at 10:38 AM Donglin Peng <dolinux.peng@xxxxxxxxx> wrote:
>
> On Thu, Nov 13, 2025 at 10:02 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> >
> > On Thu, 13 Nov 2025 09:48:52 +0800
> > Donglin Peng <dolinux.peng@xxxxxxxxx> wrote:
> >
> > > I noticed that when funcgraph-args is enabled, it registers
> > > trace_graph_entry_args
> > > to replace trace_graph_entry. The only difference is whether a valid
> > > fregs pointer
> > > is passed.
> > >
> > > To reduce overhead, I propose consolidating the two entry functions. We could
> > > maintain only trace_graph_entry and pass the fregs parameter to graph_entry.
> > > Within __graph_entry, we can then conditionally record arguments based on
> > > 'TRACE_GRAPH_ARGS && !!fregs'.
> >
> > What overhead are you reducing? Why add a branch statement in a critical path?
>
> Thanks. During testing, I found that enabling funcgraph-args incurs significant
> overhead (344ms) compared to other trace options (near-zero).
>
> # time echo 1 > options/funcgraph-retaddr
>
> real 0m0.000s
> user 0m0.000s
> sys 0m0.000s
>
> # time echo 1 > options/funcgraph-args
>
> real 0m0.344s
> user 0m0.000s
> sys 0m0.344s
>
> So I thought it may need to be optimized.
>
> >
> > The graph_entry() should not be looking at the flags argument. It's called
> > by *every function*. Also note, I recently fixed the flags to be per
> > instance and not global. Which means testing the flags would require
> > indirection lookups.
>
> Thanks, I agree and it indeed introduces extra branch instruction and
> may introduce more overhead when using indirection lookups.
Is it necessary to do the same thing for funcgraph-retaddr considering
that it checks the global tracer_flags in the graph_entry?
>
> >
> > -- Steve