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 3/5] perf evsel: Only fall back group read for leader
Date: Tue, 24 Apr 2018 11:20:12 -0700	[thread overview]
Message-ID: <1524594014-79243-3-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. The perf stat should output <not counted>/<not
supported> for all events, but it doesn't. For example,

  perf stat -e '{cycles,uncore_imc_5/umask=0xF,event=0x4/,instructions}'
       <not counted>      cycles
       <not supported>    uncore_imc_5/umask=0xF,event=0x4/
           1,024,300      instructions

If perf fails to open an event, it doesn't error out directly. It will
disable some features and retry, until the event is opened or all
features are disabled. The disabled features will not be re-enabled. The
group read is one of these features.
For the example as above, the IMC event and the leader event "cycles"
are from different PMUs. Opening the IMC event must fail. The group read
feature must be disabled for IMC event and the followed event
"instructions". The "instructions" event has the same PMU as the leader
"cycles". It can be opened successfully. Since the group read feature
has been disabled, the "instructions" event will be read as a single
event, which definitely has a value.

The group read fallback is still useful for the case which kernel
doesn't support group read. It is good enough to be handled only by the
leader.
For the fallback request from members, it must be caused by an error. The
fallback only breaks the semantics of group.
Limit the group read fallback only for the leader.

Fixes:  82bf311e15d2 ("perf stat: Use group read for event groups")
Reported-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
 tools/perf/util/evsel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 1ac8d92..391ef7c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1922,7 +1922,8 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
 		goto fallback_missing_features;
 	} else if (!perf_missing_features.group_read &&
 		    evsel->attr.inherit &&
-		   (evsel->attr.read_format & PERF_FORMAT_GROUP)) {
+		   (evsel->attr.read_format & PERF_FORMAT_GROUP) &&
+		   perf_evsel__is_group_leader(evsel)) {
 		perf_missing_features.group_read = true;
 		pr_debug2("switching off group read\n");
 		goto fallback_missing_features;
-- 
2.7.4

  parent 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 ` [PATCH 2/5] perf stat: Print out hint for mixed PMU group error kan.liang
2018-04-26  5:56   ` [tip:perf/urgent] " tip-bot for Kan Liang
2018-04-24 18:20 ` kan.liang [this message]
2018-04-26  5:57   ` [tip:perf/urgent] perf evsel: Only fall back group read for leader 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-3-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