All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] tracing: Add an option to show symbols in _text+offset for function profiler
Date: Thu, 23 Oct 2025 08:59:37 +0900	[thread overview]
Message-ID: <20251023085937.0dbeac1fde692da17f5ec5a4@kernel.org> (raw)
In-Reply-To: <20251022123259.59ada139@gandalf.local.home>

On Wed, 22 Oct 2025 12:32:59 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Thu, 23 Oct 2025 00:38:11 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
> > @@ -554,7 +556,29 @@ static int function_stat_show(struct seq_file *m, void *v)
> >  		return 0;
> >  #endif
> >  
> > -	kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
> > +	if (tr->trace_flags & TRACE_ITER(PROF_TEXT_OFFSET)) {
> > +		long offset;
> > +
> > +		if (core_kernel_text(rec->ip)) {
> > +			refsymbol = "_text";
> > +			offset = rec->ip - (unsigned long)_text;
> > +		} else {
> > +			struct module *mod;
> > +
> > +			guard(rcu)();
> > +			mod = __module_text_address(rec->ip);
> > +			if (mod) {
> > +				refsymbol = mod->name;
> > +				/* Calculate offset from module's text entry address. */
> > +				offset = rec->ip - (unsigned long)mod->mem[MOD_TEXT].base;
> > +			}
> > +		}
> > +		if (refsymbol)
> > +			snprintf(str, sizeof(str), "  %s%+ld", refsymbol, offset);
> 
> Let's be consistent as offsets are printed as hex every place else:

OK.

> 
> 			snprintf(str, sizeof(str), "  %s+%#lx", refsymbol, offset);
> 
> Also, did you mean to add the '+' after the '%'?

Ah, yes it is for the case if the offset < 0. It should not happen, but
for robustness.

Thank you,

> 
> -- Steve
> 
> 
> > +	}
> > +	if (!refsymbol)
> > +		kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
> > +
> >  	seq_printf(m, "  %-30.30s  %10lu", str, rec->counter);
> >  
> >  #ifdef CONFIG_FUNCTION_GRAPH_TRACER


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

  reply	other threads:[~2025-10-22 23:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 15:37 [PATCH v5 0/2] tracing: Add an option to show symbols in _text+offset for function profiler Masami Hiramatsu (Google)
2025-10-22 15:38 ` [PATCH v5 1/2] tracing: Allow tracer to add more than 32 options Masami Hiramatsu (Google)
2025-10-22 15:38 ` [PATCH v5 2/2] tracing: Add an option to show symbols in _text+offset for function profiler Masami Hiramatsu (Google)
2025-10-22 16:32   ` Steven Rostedt
2025-10-22 23:59     ` Masami Hiramatsu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-10-30  3:01 [PATCH v5 0/2] " Masami Hiramatsu (Google)
2025-10-30  3:02 ` [PATCH v5 2/2] " Masami Hiramatsu (Google)

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=20251023085937.0dbeac1fde692da17f5ec5a4@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=rostedt@goodmis.org \
    /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.