Skip to content

Commit 80ee8c5

Browse files
Kan Liangacmel
authored andcommitted
perf stat: Fix duplicate PMU name for interval print
PMU name is printed repeatedly for interval print, for example: perf stat --no-merge -e 'unc_m_clockticks' -a -I 1000 # time counts unit events 1.001053069 243,702,144 unc_m_clockticks [uncore_imc_4] 1.001053069 244,268,304 unc_m_clockticks [uncore_imc_2] 1.001053069 244,427,386 unc_m_clockticks [uncore_imc_0] 1.001053069 244,583,760 unc_m_clockticks [uncore_imc_5] 1.001053069 244,738,971 unc_m_clockticks [uncore_imc_3] 1.001053069 244,880,309 unc_m_clockticks [uncore_imc_1] 2.002024821 240,818,200 unc_m_clockticks [uncore_imc_4] [uncore_imc_4] 2.002024821 240,767,812 unc_m_clockticks [uncore_imc_2] [uncore_imc_2] 2.002024821 240,764,215 unc_m_clockticks [uncore_imc_0] [uncore_imc_0] 2.002024821 240,759,504 unc_m_clockticks [uncore_imc_5] [uncore_imc_5] 2.002024821 240,755,992 unc_m_clockticks [uncore_imc_3] [uncore_imc_3] 2.002024821 240,750,403 unc_m_clockticks [uncore_imc_1] [uncore_imc_1] For each print, the PMU name is unconditionally appended to the counter->name. Need to check the counter->name first. If the PMU name is already appended, do nothing. Committer notes: Add and use perf_evsel->uniquified_name bool instead of doing the more expensive strstr(event->name, pmu->name). Signed-off-by: Kan Liang <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Agustin Vega-Frias <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ganapatrao Kulkarni <[email protected]> Cc: Jin Yao <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Shaokun Zhang <[email protected]> Cc: Will Deacon <[email protected]> Fixes: 8c5421c ("perf pmu: Display pmu name when printing unmerged events in stat") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 121f325 commit 80ee8c5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

tools/perf/builtin-stat.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,8 @@ static void uniquify_event_name(struct perf_evsel *counter)
12841284
char *new_name;
12851285
char *config;
12861286

1287-
if (!counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
1287+
if (counter->uniquified_name ||
1288+
!counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
12881289
strlen(counter->pmu_name)))
12891290
return;
12901291

@@ -1302,6 +1303,8 @@ static void uniquify_event_name(struct perf_evsel *counter)
13021303
counter->name = new_name;
13031304
}
13041305
}
1306+
1307+
counter->uniquified_name = true;
13051308
}
13061309

13071310
static void collect_all_aliases(struct perf_evsel *counter,

tools/perf/util/evsel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct perf_evsel {
115115
unsigned int sample_size;
116116
int id_pos;
117117
int is_pos;
118+
bool uniquified_name;
118119
bool snapshot;
119120
bool supported;
120121
bool needs_swap;

0 commit comments

Comments
 (0)