diff options
author | Namhyung Kim <namhyung@kernel.org> | 2024-06-07 22:29:18 +0200 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2024-06-16 06:04:04 +0200 |
commit | eae7044b67a606f10d245ff2866ee04f235e1722 (patch) | |
tree | 1a637f13ef91d10852a3fbc5f1acb03df1a000b7 /tools/perf/ui/hist.c | |
parent | perf hist: Add symbol_conf.skip_empty (diff) | |
download | linux-eae7044b67a606f10d245ff2866ee04f235e1722.tar.xz linux-eae7044b67a606f10d245ff2866ee04f235e1722.zip |
perf hist: Honor symbol_conf.skip_empty
So that it can skip events with no sample according to the config value.
This can omit the dummy event in the output of perf report --group.
An example output:
$ sudo perf mem record -a sleep 1
$ sudo perf report --group
Before)
#
# Samples: 232 of events 'cpu/mem-loads,ldlat=30/P, cpu/mem-stores/P, dummy:u'
# Event count (approx.): 3089861
#
# Overhead Command Shared Object Symbol
# ........................ ........... ................. .....................................
#
9.29% 0.00% 0.00% swapper [kernel.kallsyms] [k] update_blocked_averages
5.26% 0.15% 0.00% swapper [kernel.kallsyms] [k] __update_load_avg_se
4.15% 0.00% 0.00% perf-exec [kernel.kallsyms] [k] slab_update_freelist.isra.0
3.87% 0.00% 0.00% perf-exec [kernel.kallsyms] [k] memcg_slab_post_alloc_hook
3.79% 0.17% 0.00% swapper [kernel.kallsyms] [k] enqueue_task_fair
3.63% 0.00% 0.00% sleep [kernel.kallsyms] [k] next_uptodate_page
2.86% 0.00% 0.00% swapper [kernel.kallsyms] [k] __update_load_avg_cfs_rq
2.78% 0.00% 0.00% swapper [kernel.kallsyms] [k] __schedule
2.34% 0.00% 0.00% swapper [kernel.kallsyms] [k] intel_idle
2.32% 0.97% 0.00% swapper [kernel.kallsyms] [k] psi_group_change
After)
#
# Samples: 232 of events 'cpu/mem-loads,ldlat=30/P, cpu/mem-stores/P'
# Event count (approx.): 3089861
#
# Overhead Command Shared Object Symbol
# ................ ........... ................. .....................................
#
9.29% 0.00% swapper [kernel.kallsyms] [k] update_blocked_averages
5.26% 0.15% swapper [kernel.kallsyms] [k] __update_load_avg_se
4.15% 0.00% perf-exec [kernel.kallsyms] [k] slab_update_freelist.isra.0
3.87% 0.00% perf-exec [kernel.kallsyms] [k] memcg_slab_post_alloc_hook
3.79% 0.17% swapper [kernel.kallsyms] [k] enqueue_task_fair
3.63% 0.00% sleep [kernel.kallsyms] [k] next_uptodate_page
2.86% 0.00% swapper [kernel.kallsyms] [k] __update_load_avg_cfs_rq
2.78% 0.00% swapper [kernel.kallsyms] [k] __schedule
2.34% 0.00% swapper [kernel.kallsyms] [k] intel_idle
2.32% 0.97% swapper [kernel.kallsyms] [k] psi_group_change
Now it doesn't have a column for the dummy event.
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240607202918.2357459-5-namhyung@kernel.org
Diffstat (limited to 'tools/perf/ui/hist.c')
-rw-r--r-- | tools/perf/ui/hist.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 7e863cd92781..5d1f04f66a5a 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -95,6 +95,10 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, } for (i = 0; i < nr_members; i++) { + if (symbol_conf.skip_empty && + values[i].hists->stats.nr_samples == 0) + continue; + ret += __hpp__fmt_print(hpp, values[i].hists, values[i].val, values[i].samples, fmt, len, print_fn, fmtype); @@ -296,8 +300,18 @@ static int hpp__width_fn(struct perf_hpp_fmt *fmt, int len = fmt->user_len ?: fmt->len; struct evsel *evsel = hists_to_evsel(hists); - if (symbol_conf.event_group) - len = max(len, evsel->core.nr_members * fmt->len); + if (symbol_conf.event_group) { + int nr = 0; + struct evsel *pos; + + for_each_group_evsel(pos, evsel) { + if (!symbol_conf.skip_empty || + evsel__hists(pos)->stats.nr_samples) + nr++; + } + + len = max(len, nr * fmt->len); + } if (len < (int)strlen(fmt->name)) len = strlen(fmt->name); |