mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf, tools: Fix perf stat for old kernels w/o PERF_SAMPLE_IDENTIFIER
@ 2017-12-05 21:34 Andi Kleen
  0 siblings, 0 replies; only message in thread
From: Andi Kleen @ 2017-12-05 21:34 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, Andi Kleen, jolsa

From: Andi Kleen <ak@linux.intel.com>

PERF_SAMPLE_IDENTIFIER is a newer kernel feature and not available
on old kernels. Since 4979d0c7d0c7 ("perf stat record: Add record command")
we set it unconditionally for perf stat, which makes perf stat
show all counters as "not supported" on a 3.0 kernel.

Make it conditional on perf stat record. So at least normal perf
stat works again on 3.0, just not record.

Fixes: 4979d0c7d0c7 ("perf stat record: Add record command")
Cc: jolsa@kernel.org
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/builtin-stat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 69523ed55894..b1bc77cfecbb 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -240,12 +240,15 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
 	 * But set sample_type to PERF_SAMPLE_IDENTIFIER, which should be harmless
 	 * while avoiding that older tools show confusing messages.
 	 *
+	 * Avoid doing this for non record because it doesn't work
+	 * on old enough kernels.
+	 *
 	 * However for pipe sessions we need to keep it zero,
 	 * because script's perf_evsel__check_attr is triggered
 	 * by attr->sample_type != 0, and we can't run it on
 	 * stat sessions.
 	 */
-	if (!(STAT_RECORD && perf_stat.file.is_pipe))
+	if (STAT_RECORD && !perf_stat.file.is_pipe)
 		attr->sample_type = PERF_SAMPLE_IDENTIFIER;
 
 	/*
-- 
2.13.6

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-05 21:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 21:34 [PATCH] perf, tools: Fix perf stat for old kernels w/o PERF_SAMPLE_IDENTIFIER Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome