Skip to content

Commit 30060ea

Browse files
Kan Liangacmel
authored andcommitted
perf stat: Print out hint for mixed PMU group error
Perf doesn't support mixed events from different PMUs (except software event) in a group. For this case, only "<not counted>" or "<not supported>" are printed out. There is no hint which guides users to fix the issue. Checking the PMU type of events to determine if they are from the same PMU. There may be false alarm for the checking. E.g. the core PMU has different PMU type. But it should not happen often. The false alarm can also be tolerated, because: - It only happens on error path. - It just provides a possible solution for the issue. Signed-off-by: Kan Liang <[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]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 292c34c commit 30060ea

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

tools/perf/builtin-stat.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ static bool interval_count;
172172
static const char *output_name;
173173
static int output_fd;
174174
static int print_free_counters_hint;
175+
static int print_mixed_hw_group_error;
175176

176177
struct perf_stat {
177178
bool record;
@@ -1126,6 +1127,30 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
11261127
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
11271128
}
11281129

1130+
static bool is_mixed_hw_group(struct perf_evsel *counter)
1131+
{
1132+
struct perf_evlist *evlist = counter->evlist;
1133+
u32 pmu_type = counter->attr.type;
1134+
struct perf_evsel *pos;
1135+
1136+
if (counter->nr_members < 2)
1137+
return false;
1138+
1139+
evlist__for_each_entry(evlist, pos) {
1140+
/* software events can be part of any hardware group */
1141+
if (pos->attr.type == PERF_TYPE_SOFTWARE)
1142+
continue;
1143+
if (pmu_type == PERF_TYPE_SOFTWARE) {
1144+
pmu_type = pos->attr.type;
1145+
continue;
1146+
}
1147+
if (pmu_type != pos->attr.type)
1148+
return true;
1149+
}
1150+
1151+
return false;
1152+
}
1153+
11291154
static void printout(int id, int nr, struct perf_evsel *counter, double uval,
11301155
char *prefix, u64 run, u64 ena, double noise,
11311156
struct runtime_stat *st)
@@ -1178,8 +1203,11 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,
11781203
counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED,
11791204
csv_sep);
11801205

1181-
if (counter->supported)
1206+
if (counter->supported) {
11821207
print_free_counters_hint = 1;
1208+
if (is_mixed_hw_group(counter))
1209+
print_mixed_hw_group_error = 1;
1210+
}
11831211

11841212
fprintf(stat_config.output, "%-*s%s",
11851213
csv_output ? 0 : unit_width,
@@ -1757,6 +1785,11 @@ static void print_footer(void)
17571785
" echo 0 > /proc/sys/kernel/nmi_watchdog\n"
17581786
" perf stat ...\n"
17591787
" echo 1 > /proc/sys/kernel/nmi_watchdog\n");
1788+
1789+
if (print_mixed_hw_group_error)
1790+
fprintf(output,
1791+
"The events in group usually have to be from "
1792+
"the same PMU. Try reorganizing the group.\n");
17601793
}
17611794

17621795
static void print_counters(struct timespec *ts, int argc, const char **argv)

0 commit comments

Comments
 (0)