public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: kan.liang@linux.intel.com
To: acme@kernel.org, mingo@redhat.com, peterz@infradead.org,
	linux-kernel@vger.kernel.org
Cc: jolsa@redhat.com, namhyung@kernel.org,
	ganapatrao.kulkarni@cavium.com, zhangshaokun@hisilicon.com,
	yao.jin@linux.intel.com, will.deacon@arm.com, ak@linux.intel.com,
	agustinv@codeaurora.org, Kan Liang <kan.liang@linux.intel.com>
Subject: [PATCH 2/5] perf stat: Print out hint for mixed PMU group error
Date: Tue, 24 Apr 2018 11:20:11 -0700	[thread overview]
Message-ID: <1524594014-79243-2-git-send-email-kan.liang@linux.intel.com> (raw)
In-Reply-To: <1524594014-79243-1-git-send-email-kan.liang@linux.intel.com>

From: Kan Liang <kan.liang@linux.intel.com>

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 <kan.liang@linux.intel.com>
---
 tools/perf/builtin-stat.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 147a27e..30e6b37 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -172,6 +172,7 @@ static bool			interval_count;
 static const char		*output_name;
 static int			output_fd;
 static int			print_free_counters_hint;
+static int			print_mixed_hw_group_error;
 
 struct perf_stat {
 	bool			 record;
@@ -1126,6 +1127,30 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
 		fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
 }
 
+static bool is_mixed_hw_group(struct perf_evsel *counter)
+{
+	struct perf_evlist *evlist = counter->evlist;
+	u32 pmu_type = counter->attr.type;
+	struct perf_evsel *pos;
+
+	if (counter->nr_members < 2)
+		return false;
+
+	evlist__for_each_entry(evlist, pos) {
+		/* software events can be part of any hardware group */
+		if (pos->attr.type == PERF_TYPE_SOFTWARE)
+			continue;
+		if (pmu_type == PERF_TYPE_SOFTWARE) {
+			pmu_type = pos->attr.type;
+			continue;
+		}
+		if (pmu_type != pos->attr.type)
+			return true;
+	}
+
+	return false;
+}
+
 static void printout(int id, int nr, struct perf_evsel *counter, double uval,
 		     char *prefix, u64 run, u64 ena, double noise,
 		     struct runtime_stat *st)
@@ -1178,8 +1203,11 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,
 			counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED,
 			csv_sep);
 
-		if (counter->supported)
+		if (counter->supported) {
 			print_free_counters_hint = 1;
+			if (is_mixed_hw_group(counter))
+				print_mixed_hw_group_error = 1;
+		}
 
 		fprintf(stat_config.output, "%-*s%s",
 			csv_output ? 0 : unit_width,
@@ -1757,6 +1785,11 @@ static void print_footer(void)
 "	echo 0 > /proc/sys/kernel/nmi_watchdog\n"
 "	perf stat ...\n"
 "	echo 1 > /proc/sys/kernel/nmi_watchdog\n");
+
+	if (print_mixed_hw_group_error)
+		fprintf(output,
+			"The events in group usually have to be from "
+			"the same PMU. Try reorganizing the group.\n");
 }
 
 static void print_counters(struct timespec *ts, int argc, const char **argv)
-- 
2.7.4

  reply	other threads:[~2018-04-24 18:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 18:20 [PATCH 1/5] perf pmu: Fix core PMU alias list for X86 platform kan.liang
2018-04-24 18:20 ` kan.liang [this message]
2018-04-26  5:56   ` [tip:perf/urgent] perf stat: Print out hint for mixed PMU group error tip-bot for Kan Liang
2018-04-24 18:20 ` [PATCH 3/5] perf evsel: Only fall back group read for leader kan.liang
2018-04-26  5:57   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-24 18:20 ` [PATCH 4/5] perf parse-events: Specially handle uncore event alias in small groups kan.liang
2018-04-24 19:17   ` Arnaldo Carvalho de Melo
2018-04-24 19:23     ` Liang, Kan
2018-04-24 19:29       ` Arnaldo Carvalho de Melo
2018-04-25 12:27         ` Liang, Kan
2018-04-25 12:59           ` Arnaldo Carvalho de Melo
2018-04-25 13:39             ` Liang, Kan
2018-04-24 18:20 ` [PATCH 5/5] perf stat: Fix duplicate PMU name for interval print kan.liang
2018-04-24 18:53   ` Arnaldo Carvalho de Melo
2018-04-24 19:18     ` Liang, Kan
2018-04-24 19:29       ` Arnaldo Carvalho de Melo
2018-04-26  5:57   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-26  5:56 ` [tip:perf/urgent] perf pmu: Fix core PMU alias list for X86 platform tip-bot for Kan Liang

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=1524594014-79243-2-git-send-email-kan.liang@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=agustinv@codeaurora.org \
    --cc=ak@linux.intel.com \
    --cc=ganapatrao.kulkarni@cavium.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    --cc=yao.jin@linux.intel.com \
    --cc=zhangshaokun@hisilicon.com \
    /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