perf report: Support --total-cycles --group in the tui mode
PATCH 1/1 perf report: Support --total-cycles --group in the tui mode
From: Kan Liang <[email protected]>
With the --total-cycles, the --group is only supported in the stdio mode, but not supported in the tui mode. The output is inconsistent with different modes.
if symbol_conf.event_group is applied, always output the event group information together in tui mode as well.
$perf record -e "{cycles,instructions}",cache-misses -b sleep 1 $perf report --total-cycles --group --tui
Before the patch,
Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
6.45% 2.0K 0.57% 667 [dl-cacheinfo.h:164 -> dl
5.62% 1.7K 0.74% 871 [dl-cache.c:230 -
5.21% 1.6K 1.37% 1.6K [setup-vdso.h:37 ->
4.92% 1.5K 0.09% 109 [dl-cache.c:367 -Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.62% 1.7K 2.76% 871 [dl-cache.c:230 -
4.92% 1.5K 0.35% 109 [dl-cache.c:367 -
1.12% 346 0.55% 173
0.87% 270 0.43% 135 [rtld.c:5
0.64% 197 0.03% 8 [dl-tunables.c:305 -> d
0.60% 185 0.01% 3 [dl-tunables.c:305 -> dSampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.90% 1.8K 1.28% 1.8K [strtod.c:8
5.70% 1.8K 1.24% 1.8K [strtod_l.c:681 -
5.68% 1.8K 1.24% 1.8K [strtod_l.c:508 -
5.48% 1.7K 1.19% 1.7K [strtod_l.c:1175 ->
5.21% 1.6K 1.13% 1.6K [setup-vdso.h:37 ->With the patch,
Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
6.45% 2.0K 0.57% 667 [dl-cacheinfo.h:164 -> dl
5.62% 1.7K 0.74% 871 [dl-cache.c:230 -
5.21% 1.6K 1.37% 1.6K [setup-vdso.h:37 ->
4.92% 1.5K 0.09% 109 [dl-cache.c:367 -Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.90% 1.8K 1.28% 1.8K [strtod.c:8
5.70% 1.8K 1.24% 1.8K [strtod_l.c:681 -
5.68% 1.8K 1.24% 1.8K [strtod_l.c:508 -
5.48% 1.7K 1.19% 1.7K [strtod_l.c:1175 ->
5.21% 1.6K 1.13% 1.6K [setup-vdso.h:37 ->--- tools/perf/builtin-report.c | 6 +++++- tools/perf/ui/browsers/hists.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-)
tools/perf/builtin-report.c +5 -1
@@ -541,7 +541,11 @@ static int evlist__tui_block_hists_browse(struct evlist *evlist, struct report *int i =0 , ret;evlist__for_each_entry (evlist, pos) { - ret =report__browse_block_hists (&rep->block_reports[i++].hist, + i++; +if (symbol_conf.event_group && !evsel__is_group_leader (pos)) +continue ; + + ret =report__browse_block_hists (&rep->block_reports[i -1 ].hist, rep->min_percent, pos, &rep->session->header.env);if (ret !=0 )
tools/perf/ui/browsers/hists.c +10 -2
@@ -3665,11 +3665,19 @@ single_entry: {static int block_hists_browser__title (struct hist_browser *browser,char *bf,size_t size) { -struct hists *hists =evsel__hists (browser->block_evsel); -const char *evname =evsel__name (browser->block_evsel); +struct evsel *evsel = browser->block_evsel; +struct hists *hists =evsel__hists (evsel);unsigned long nr_samples = hists->stats.nr_samples; +const char *evname; +char buf[512 ];int ret; +if (evsel__is_group_event (evsel)) { +evsel__group_desc (evsel, buf,sizeof (buf)); + evname = buf; + }else + evname =evsel__name (evsel); + ret =scnprintf (bf, size,"# Samples: %lu" , nr_samples);if (evname)scnprintf (bf + ret, size - ret," of event '%s'" , evname);
Signature · 1 line
2.38.1
Namhyung Kim
maintainerHi Kan,
Quoted 36 lines · On Wed, Aug 14, 2024 at 7:19 AM <[email protected]> wrote:
From: Kan Liang <[email protected]>
With the --total-cycles, the --group is only supported in the stdio mode, but not supported in the tui mode. The output is inconsistent with different modes.
if symbol_conf.event_group is applied, always output the event group information together in tui mode as well.
$perf record -e "{cycles,instructions}",cache-misses -b sleep 1 $perf report --total-cycles --group --tui
Before the patch,
Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
6.45% 2.0K 0.57% 667 [dl-cacheinfo.h:164 -> dl 5.62% 1.7K 0.74% 871 [dl-cache.c:230 - 5.21% 1.6K 1.37% 1.6K [setup-vdso.h:37 -> 4.92% 1.5K 0.09% 109 [dl-cache.c:367 -Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.62% 1.7K 2.76% 871 [dl-cache.c:230 - 4.92% 1.5K 0.35% 109 [dl-cache.c:367 - 1.12% 346 0.55% 173 0.87% 270 0.43% 135 [rtld.c:5 0.64% 197 0.03% 8 [dl-tunables.c:305 -> d 0.60% 185 0.01% 3 [dl-tunables.c:305 -> dSampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.90% 1.8K 1.28% 1.8K [strtod.c:8 5.70% 1.8K 1.24% 1.8K [strtod_l.c:681 - 5.68% 1.8K 1.24% 1.8K [strtod_l.c:508 - 5.48% 1.7K 1.19% 1.7K [strtod_l.c:1175 -> 5.21% 1.6K 1.13% 1.6K [setup-vdso.h:37 ->
Quoted 7 lines
With the patch,
Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
6.45% 2.0K 0.57% 667 [dl-cacheinfo.h:164 -> dl 5.62% 1.7K 0.74% 871 [dl-cache.c:230 - 5.21% 1.6K 1.37% 1.6K [setup-vdso.h:37 -> 4.92% 1.5K 0.09% 109 [dl-cache.c:367 -
Hmm.. it seems the output just removed the second one. I guess it should combine the first and second output somehow.
Thanks,
Namhyung
Quoted 62 lines
Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.90% 1.8K 1.28% 1.8K [strtod.c:8 5.70% 1.8K 1.24% 1.8K [strtod_l.c:681 - 5.68% 1.8K 1.24% 1.8K [strtod_l.c:508 - 5.48% 1.7K 1.19% 1.7K [strtod_l.c:1175 -> 5.21% 1.6K 1.13% 1.6K [setup-vdso.h:37 ->Fixes 7fa46cbf20d3 ("perf report: Sort by sampled cycles percent per block for tui")Signed-off-by Kan Liang <[email protected]>--- tools/perf/builtin-report.c | 6 +++++- tools/perf/ui/browsers/hists.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-)tools/perf/builtin-report.c +5
-1@@ -541,7 +541,11 @@ static int evlist__tui_block_hists_browse(struct evlist *evlist, struct report *int i =0 , ret;evlist__for_each_entry (evlist, pos) { - ret =report__browse_block_hists (&rep->block_reports[i++].hist, + i++; +if (symbol_conf.event_group && !evsel__is_group_leader (pos)) +continue ; + + ret =report__browse_block_hists (&rep->block_reports[i -1 ].hist, rep->min_percent, pos, &rep->session->header.env);if (ret !=0 )tools/perf/ui/browsers/hists.c +10
-3@@ -3665,11 +3665,19 @@ single_entry: {static int block_hists_browser__title (struct hist_browser *browser,char *bf,size_t size) { -struct hists *hists =evsel__hists (browser->block_evsel); -const char *evname =evsel__name (browser->block_evsel); +struct evsel *evsel = browser->block_evsel; +struct hists *hists =evsel__hists (evsel);unsigned long nr_samples = hists->stats.nr_samples; +const char *evname; +char buf[512 ];int ret; +if (evsel__is_group_event (evsel)) { +evsel__group_desc (evsel, buf,sizeof (buf)); + evname = buf; + }else + evname =evsel__name (evsel); + ret =scnprintf (bf, size,"# Samples: %lu" , nr_samples);if (evname)scnprintf (bf + ret, size - ret," of event '%s'" , evname); --2.38.1
Quoted 41 lines · Namhyung Kim
Hi Kan,
Quoted 38 lines · On Wed, Aug 14, 2024 at 7:19 AM <[email protected]> wrote:
From: Kan Liang <[email protected]>
With the --total-cycles, the --group is only supported in the stdio mode, but not supported in the tui mode. The output is inconsistent with different modes.
if symbol_conf.event_group is applied, always output the event group information together in tui mode as well.
$perf record -e "{cycles,instructions}",cache-misses -b sleep 1 $perf report --total-cycles --group --tui
Before the patch,
Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
6.45% 2.0K 0.57% 667 [dl-cacheinfo.h:164 -> dl 5.62% 1.7K 0.74% 871 [dl-cache.c:230 - 5.21% 1.6K 1.37% 1.6K [setup-vdso.h:37 -> 4.92% 1.5K 0.09% 109 [dl-cache.c:367 -Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.62% 1.7K 2.76% 871 [dl-cache.c:230 - 4.92% 1.5K 0.35% 109 [dl-cache.c:367 - 1.12% 346 0.55% 173 0.87% 270 0.43% 135 [rtld.c:5 0.64% 197 0.03% 8 [dl-tunables.c:305 -> d 0.60% 185 0.01% 3 [dl-tunables.c:305 -> dSampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.90% 1.8K 1.28% 1.8K [strtod.c:8 5.70% 1.8K 1.24% 1.8K [strtod_l.c:681 - 5.68% 1.8K 1.24% 1.8K [strtod_l.c:508 - 5.48% 1.7K 1.19% 1.7K [strtod_l.c:1175 -> 5.21% 1.6K 1.13% 1.6K [setup-vdso.h:37 ->With the patch,
Quoted 9 lines
Quoted 5 lines
Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
6.45% 2.0K 0.57% 667 [dl-cacheinfo.h:164 -> dl 5.62% 1.7K 0.74% 871 [dl-cache.c:230 - 5.21% 1.6K 1.37% 1.6K [setup-vdso.h:37 -> 4.92% 1.5K 0.09% 109 [dl-cache.c:367 -Hmm.. it seems the output just removed the second one. I guess it should combine the first and second output somehow.
The patch is just to make the behavior/output the same between --stdio and the tui mode for --group. I didn't change the algorithm of calculating the cycles.
Yes, it looks suspicious. I will take a deep look and see how the group information are processed.
Thanks,
Kan
Quoted 66 lines
Thanks,
NamhyungQuoted 62 lines
Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles [Pro
5.90% 1.8K 1.28% 1.8K [strtod.c:8 5.70% 1.8K 1.24% 1.8K [strtod_l.c:681 - 5.68% 1.8K 1.24% 1.8K [strtod_l.c:508 - 5.48% 1.7K 1.19% 1.7K [strtod_l.c:1175 -> 5.21% 1.6K 1.13% 1.6K [setup-vdso.h:37 ->Fixes 7fa46cbf20d3 ("perf report: Sort by sampled cycles percent per block for tui")Signed-off-by Kan Liang <[email protected]>--- tools/perf/builtin-report.c | 6 +++++- tools/perf/ui/browsers/hists.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-)tools/perf/builtin-report.c +5
-1@@ -541,7 +541,11 @@ static int evlist__tui_block_hists_browse(struct evlist *evlist, struct report *int i =0 , ret;evlist__for_each_entry (evlist, pos) { - ret =report__browse_block_hists (&rep->block_reports[i++].hist, + i++; +if (symbol_conf.event_group && !evsel__is_group_leader (pos)) +continue ; + + ret =report__browse_block_hists (&rep->block_reports[i -1 ].hist, rep->min_percent, pos, &rep->session->header.env);if (ret !=0 )tools/perf/ui/browsers/hists.c +10
-3@@ -3665,11 +3665,19 @@ single_entry: {static int block_hists_browser__title (struct hist_browser *browser,char *bf,size_t size) { -struct hists *hists =evsel__hists (browser->block_evsel); -const char *evname =evsel__name (browser->block_evsel); +struct evsel *evsel = browser->block_evsel; +struct hists *hists =evsel__hists (evsel);unsigned long nr_samples = hists->stats.nr_samples; +const char *evname; +char buf[512 ];int ret; +if (evsel__is_group_event (evsel)) { +evsel__group_desc (evsel, buf,sizeof (buf)); + evname = buf; + }else + evname =evsel__name (evsel); + ret =scnprintf (bf, size,"# Samples: %lu" , nr_samples);if (evname)scnprintf (bf + ret, size - ret," of event '%s'" , evname); --2.38.1