From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751711AbdLEVeV (ORCPT ); Tue, 5 Dec 2017 16:34:21 -0500 Received: from mga02.intel.com ([134.134.136.20]:37977 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751066AbdLEVeU (ORCPT ); Tue, 5 Dec 2017 16:34:20 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,365,1508828400"; d="scan'208";a="9877080" From: Andi Kleen To: acme@kernel.org Cc: linux-kernel@vger.kernel.org, Andi Kleen , jolsa@kernel.org Subject: [PATCH] perf, tools: Fix perf stat for old kernels w/o PERF_SAMPLE_IDENTIFIER Date: Tue, 5 Dec 2017 13:34:14 -0800 Message-Id: <20171205213414.14641-1-andi@firstfloor.org> X-Mailer: git-send-email 2.13.6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen 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 --- 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