From: Andi Kleen <[email protected]>
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: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
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