linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 5/5] perf annotate: Add --skip-empty option
Date: Mon, 5 Aug 2024 16:26:11 -0300	[thread overview]
Message-ID: <ZrEnU6_MMEYY4GMU@x1> (raw)
In-Reply-To: <20240803211332.1107222-6-namhyung@kernel.org>

On Sat, Aug 03, 2024 at 02:13:32PM -0700, Namhyung Kim wrote:
> Like in perf report, we want to hide empty events in the perf annotate
> output.  This is consistent when the option is set in perf report.
> 
> For example, the following command would use 3 events including dummy.

The option --skip-empty is useful, but I wonder if for "dummy" it
shouldn't be the default, i.e. a per-event "skip" or "hide" flag that we
would set for the "dummy" event in addition to this --skip-empty command
line option?

- Arnaldo
 
>   $ perf mem record -a -- perf test -w noploop
> 
>   $ perf evlist
>   cpu/mem-loads,ldlat=30/P
>   cpu/mem-stores/P
>   dummy:u
> 
> Just using perf annotate with --group will show the all 3 events.
> 
>   $ perf annotate --group --stdio | head
>    Percent                 |	Source code & Disassembly of ...
>   --------------------------------------------------------------
>                            : 0     0xe060 <_dl_relocate_object>:
>       0.00    0.00    0.00 :    e060:       pushq   %rbp
>       0.00    0.00    0.00 :    e061:       movq    %rsp, %rbp
>       0.00    0.00    0.00 :    e064:       pushq   %r15
>       0.00    0.00    0.00 :    e066:       movq    %rdi, %r15
>       0.00    0.00    0.00 :    e069:       pushq   %r14
>       0.00    0.00    0.00 :    e06b:       pushq   %r13
>       0.00    0.00    0.00 :    e06d:       movl    %edx, %r13d
> 
> Now with --skip-empty, it'll hide the last dummy event.
> 
>   $ perf annotate --group --stdio --skip-empty | head
>    Percent         |	Source code & Disassembly of ...
>   ------------------------------------------------------
>                    : 0     0xe060 <_dl_relocate_object>:
>       0.00    0.00 :    e060:       pushq   %rbp
>       0.00    0.00 :    e061:       movq    %rsp, %rbp
>       0.00    0.00 :    e064:       pushq   %r15
>       0.00    0.00 :    e066:       movq    %rdi, %r15
>       0.00    0.00 :    e069:       pushq   %r14
>       0.00    0.00 :    e06b:       pushq   %r13
>       0.00    0.00 :    e06d:       movl    %edx, %r13d
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/Documentation/perf-annotate.txt |  3 +++
>  tools/perf/builtin-annotate.c              |  2 ++
>  tools/perf/util/annotate.c                 | 22 +++++++++++++++++-----
>  3 files changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
> index b95524bea021..156c5f37b051 100644
> --- a/tools/perf/Documentation/perf-annotate.txt
> +++ b/tools/perf/Documentation/perf-annotate.txt
> @@ -165,6 +165,9 @@ include::itrace.txt[]
>  --type-stat::
>  	Show stats for the data type annotation.
>  
> +--skip-empty::
> +	Do not display empty (or dummy) events.
> +
>  
>  SEE ALSO
>  --------
> diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
> index cf60392b1c19..efcadb7620b8 100644
> --- a/tools/perf/builtin-annotate.c
> +++ b/tools/perf/builtin-annotate.c
> @@ -795,6 +795,8 @@ int cmd_annotate(int argc, const char **argv)
>  		    "Show stats for the data type annotation"),
>  	OPT_BOOLEAN(0, "insn-stat", &annotate.insn_stat,
>  		    "Show instruction stats for the data type annotation"),
> +	OPT_BOOLEAN(0, "skip-empty", &symbol_conf.skip_empty,
> +		    "Do not display empty (or dummy) events in the output"),
>  	OPT_END()
>  	};
>  	int ret;
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index 917897fe44a2..eafe8d65052e 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -848,6 +848,10 @@ static void annotation__calc_percent(struct annotation *notes,
>  
>  			BUG_ON(i >= al->data_nr);
>  
> +			if (symbol_conf.skip_empty &&
> +			    evsel__hists(evsel)->stats.nr_samples == 0)
> +				continue;
> +
>  			data = &al->data[i++];
>  
>  			calc_percent(notes, evsel, data, al->offset, end);
> @@ -901,7 +905,7 @@ int symbol__annotate(struct map_symbol *ms, struct evsel *evsel,
>  		.options	= &annotate_opts,
>  	};
>  	struct arch *arch = NULL;
> -	int err;
> +	int err, nr;
>  
>  	err = evsel__get_arch(evsel, &arch);
>  	if (err < 0)
> @@ -922,10 +926,18 @@ int symbol__annotate(struct map_symbol *ms, struct evsel *evsel,
>  			return -1;
>  	}
>  
> -	if (evsel__is_group_event(evsel))
> -		notes->src->nr_events = evsel->core.nr_members;
> -	else
> -		notes->src->nr_events = 1;
> +	nr = 0;
> +	if (evsel__is_group_event(evsel)) {
> +		struct evsel *pos;
> +
> +		for_each_group_evsel(pos, evsel) {
> +			if (symbol_conf.skip_empty &&
> +			    evsel__hists(pos)->stats.nr_samples == 0)
> +				continue;
> +			nr++;
> +		}
> +	}
> +	notes->src->nr_events = nr ? nr : 1;
>  
>  	if (annotate_opts.full_addr)
>  		notes->src->start = map__objdump_2mem(ms->map, ms->sym->start);
> -- 
> 2.46.0.rc2.264.g509ed76dc8-goog

  parent reply	other threads:[~2024-08-05 19:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-03 21:13 [PATCHSET 0/5] perf annotate: Add --skip-empty option (v1) Namhyung Kim
2024-08-03 21:13 ` [PATCH 1/5] perf annotate: Use al->data_nr if possible Namhyung Kim
2024-08-03 21:13 ` [PATCH 2/5] perf annotate: Set notes->src->nr_events early Namhyung Kim
2024-08-03 21:13 ` [PATCH 3/5] perf annotate: Use annotation__pcnt_width() consistently Namhyung Kim
2024-08-03 21:13 ` [PATCH 4/5] perf annotate: Set al->data_nr using the notes->src->nr_events Namhyung Kim
2024-08-03 21:13 ` [PATCH 5/5] perf annotate: Add --skip-empty option Namhyung Kim
2024-08-05 19:22   ` Arnaldo Carvalho de Melo
2024-08-05 20:14     ` Namhyung Kim
2024-08-05 20:23       ` Arnaldo Carvalho de Melo
2024-08-05 20:50         ` Namhyung Kim
2024-08-06 13:12           ` Arnaldo Carvalho de Melo
2024-08-07  6:12             ` Namhyung Kim
2024-08-07  6:15               ` [PATCH] perf annotate: Fix --group behavior when leader has no samples Namhyung Kim
2024-08-09 21:15                 ` Arnaldo Carvalho de Melo
2024-08-05 19:26   ` Arnaldo Carvalho de Melo [this message]
2024-08-05 19:26 ` [PATCHSET 0/5] perf annotate: Add --skip-empty option (v1) Arnaldo Carvalho de Melo

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=ZrEnU6_MMEYY4GMU@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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 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).