linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Zecheng Li <zecheng@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Xu Liu <xliuprof@google.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/9] perf annotate: Skip annotating data types to lea instructions
Date: Mon, 20 Oct 2025 13:29:37 +0900	[thread overview]
Message-ID: <aPW6sUywwZzDeOkW@google.com> (raw)
In-Reply-To: <aO6ZIQ2WwTPGWATX@x1>

On Tue, Oct 14, 2025 at 03:40:33PM -0300, Arnaldo Carvalho de Melo wrote:
> On Mon, Oct 13, 2025 at 06:15:58PM +0000, Zecheng Li wrote:
> > Introduce a helper function is_address_gen_insn() to check
> > arch-dependent address generation instructions like lea in x86. Remove
> > type annotation on these instructions since they are not accessing
> > memory. It should be counted as `no_mem_ops`.
> > 
> > Signed-off-by: Zecheng Li <zecheng@google.com>
> > ---
> >  tools/perf/util/annotate.c | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> > 
> > diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> > index a2e34f149a07..fb60467fa877 100644
> > --- a/tools/perf/util/annotate.c
> > +++ b/tools/perf/util/annotate.c
> > @@ -2698,6 +2698,20 @@ static bool is_stack_canary(struct arch *arch, struct annotated_op_loc *loc)
> >  	return false;
> >  }
> >  
> > +/**
> > + * Returns true if the instruction has a memory operand without
> > + * performing a load/store
> > + */
> > +static bool is_address_gen_insn(struct arch *arch, struct disasm_line *dl)
> > +{
> > +	if (arch__is(arch, "x86")) {
> > +		if (!strncmp(dl->ins.name, "lea", 3))
> > +			return true;
> > +	}
> 
> Can't we turn this into:
> 
> tatic bool disasm_line__is_address_gen_insn(const struct disasm_line *dl)
> {
> 		return dl->ins.address_gen;
> }

Probably better to add ins->ops->addr_gen() instead of adding a new
field to the struct ins.  Then it could be:

static bool ins__is_addr_gen(const struct ins *ins)
{
	return ins->ops == &addr_gen_ops;
}

But this requires more changes and it can be done later.

Thanks,
Namhyung

> 
> I.e. at some initial step when setting dl->ins, cache this series of
> string operations and then use it s result?
> 
> - Arnaldo
> 
> > +
> >  static struct disasm_line *
> >  annotation__prev_asm_line(struct annotation *notes, struct disasm_line *curr)
> >  {
> > @@ -2806,6 +2820,12 @@ __hist_entry__get_data_type(struct hist_entry *he, struct arch *arch,
> >  		return &stackop_type;
> >  	}
> >  
> > +	if (is_address_gen_insn(arch, dl)) {
> > +		istat->bad++;
> > +		ann_data_stat.no_mem_ops++;
> > +		return NO_TYPE;
> > +	}
> > +
> >  	for_each_insn_op_loc(&loc, i, op_loc) {
> >  		struct data_loc_info dloc = {
> >  			.arch = arch,
> > -- 
> > 2.51.0.788.g6d19910ace-goog

  reply	other threads:[~2025-10-20  4:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-13 18:15 [PATCH v4 0/9] perf tools: Some improvements on data type profiler Zecheng Li
2025-10-13 18:15 ` [PATCH v4 1/9] perf annotate: Skip annotating data types to lea instructions Zecheng Li
2025-10-14 18:40   ` Arnaldo Carvalho de Melo
2025-10-20  4:29     ` Namhyung Kim [this message]
2025-10-13 18:15 ` [PATCH v4 2/9] perf annotate: Track address registers via TSR_KIND_POINTER Zecheng Li
2025-10-13 18:16 ` [PATCH v4 3/9] perf annotate: Track arithmetic instructions on pointers Zecheng Li
2025-10-13 18:16 ` [PATCH v4 4/9] perf annotate: Save pointer offset in stack state Zecheng Li
2025-10-13 18:16 ` [PATCH v4 5/9] perf annotate: Invalidate register states for untracked instructions Zecheng Li
2025-10-13 18:16 ` [PATCH v4 6/9] perf dwarf-aux: Skip check_variable for die_find_variable_by_reg Zecheng Li
2025-10-13 18:16 ` [PATCH v4 7/9] perf dwarf-aux: Preserve typedefs in match_var_offset Zecheng Li
2025-10-25 17:40   ` Namhyung Kim
2025-10-13 18:16 ` [PATCH v4 8/9] perf annotate: Improve type comparison from different scopes Zecheng Li
2025-10-25 17:46   ` Namhyung Kim
2025-10-13 18:16 ` [PATCH v4 9/9] perf dwarf-aux: Support DW_OP_piece expressions Zecheng Li
2025-10-25 17:57   ` Namhyung Kim
2025-10-22  0:41 ` [PATCH v4 0/9] perf tools: Some improvements on data type profiler Namhyung Kim

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=aPW6sUywwZzDeOkW@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=xliuprof@google.com \
    --cc=zecheng@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).