From: jeff.xie@linux.dev
To: "Steven Rostedt" <rostedt@goodmis.org>
Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
xiehuan09@gmail.com
Subject: Re: [PATCH] ftrace: Get the true parent ip for function tracer
Date: Wed, 21 Aug 2024 14:16:12 +0000 [thread overview]
Message-ID: <ef273629d92e108ad166faf1f4abccac6cda461a@linux.dev> (raw)
In-Reply-To: <20240821095910.1888d7fa@gandalf.local.home>
August 21, 2024 at 9:59 PM, "Steven Rostedt" <rostedt@goodmis.org> wrote:
Hi Steven,
>
> On Wed, 21 Aug 2024 21:27:55 +0800
>
> Jeff Xie <jeff.xie@linux.dev> wrote:
>
> Hi Jeff,
>
> Thanks for the patch.
>
> >
> > Signed-off-by: Jeff Xie <jeff.xie@linux.dev>
> >
> > ---
> >
> > kernel/trace/trace_functions.c | 18 ++++++++++++++++++
> >
> > 1 file changed, 18 insertions(+)
> >
> >
> >
> > diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
> >
> > index 3b0cea37e029..273b8c7eeb2d 100644
> >
> > --- a/kernel/trace/trace_functions.c
> >
> > +++ b/kernel/trace/trace_functions.c
> >
> > @@ -176,6 +176,19 @@ static void function_trace_start(struct trace_array *tr)
> >
> > tracing_reset_online_cpus(&tr->array_buffer);
> >
> > }
> >
> >
> >
> > +static unsigned long
> >
> > +function_get_true_parent_ip(unsigned long parent_ip, struct ftrace_regs *fregs)
> >
>
> I wonder if we should make this inline, or even __always_inline, as this
>
> will be called in a very hot path, and I want to make sure that the
>
> compiler always inlines it. It likely should, but we should also give the
>
> compiler a hint that it should.
Yes, Thank you for your suggestion. It is indeed a very hot path,
and I will add __always_inline in the next version.
>
> -- Steve
>
> >
> > +{
> >
> > + unsigned long true_parent_ip;
> >
> > + int idx = 0;
> >
> > +
> >
> > + true_parent_ip = parent_ip;
> >
> > + if (unlikely(parent_ip == (unsigned long)&return_to_handler))
> >
> > + true_parent_ip = ftrace_graph_ret_addr(current, &idx, parent_ip,
> >
> > + (unsigned long *)fregs->regs.sp);
> >
> > + return true_parent_ip;
> >
> > +}
> >
> > +
> >
> > static void
> >
> > function_trace_call(unsigned long ip, unsigned long parent_ip,
> >
> > struct ftrace_ops *op, struct ftrace_regs *fregs)
> >
> > @@ -193,6 +206,8 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
> >
> > if (bit < 0)
> >
> > return;
> >
> >
> >
> > + parent_ip = function_get_true_parent_ip(parent_ip, fregs);
> >
> > +
> >
> > trace_ctx = tracing_gen_ctx();
> >
> >
> >
> > cpu = smp_processor_id();
> >
> > @@ -241,6 +256,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
> >
> > * recursive protection is performed.
> >
> > */
> >
> > local_irq_save(flags);
> >
> > + parent_ip = function_get_true_parent_ip(parent_ip, fregs);
> >
> > cpu = raw_smp_processor_id();
> >
> > data = per_cpu_ptr(tr->array_buffer.data, cpu);
> >
> > disabled = atomic_inc_return(&data->disabled);
> >
> > @@ -309,6 +325,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
> >
> > if (bit < 0)
> >
> > return;
> >
> >
> >
> > + parent_ip = function_get_true_parent_ip(parent_ip, fregs);
> >
> > cpu = smp_processor_id();
> >
> > data = per_cpu_ptr(tr->array_buffer.data, cpu);
> >
> > if (atomic_read(&data->disabled))
> >
> > @@ -356,6 +373,7 @@ function_stack_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
> >
> > * recursive protection is performed.
> >
> > */
> >
> > local_irq_save(flags);
> >
> > + parent_ip = function_get_true_parent_ip(parent_ip, fregs);
> >
> > cpu = raw_smp_processor_id();
> >
> > data = per_cpu_ptr(tr->array_buffer.data, cpu);
> >
> > disabled = atomic_inc_return(&data->disabled);
> >
>
prev parent reply other threads:[~2024-08-21 14:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 13:27 [PATCH] ftrace: Get the true parent ip for function tracer Jeff Xie
2024-08-21 13:59 ` Steven Rostedt
2024-08-21 14:16 ` jeff.xie [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef273629d92e108ad166faf1f4abccac6cda461a@linux.dev \
--to=jeff.xie@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=xiehuan09@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.