perf, tools: Fix perf stat for old kernels w/o PERF_SAMPLE_IDENTIFIER
PATCH 1/1 perf, tools: Fix perf stat for old kernels w/o PERF_SAMPLE_IDENTIFIER
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")
Signed-off-by Andi Kleen <[email protected]>
--- tools/perf/builtin-stat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-stat.c +4 -1
@@ -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 ;/*
Signature · 1 line
2.13.6