mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: acme@kernel.org
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
	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	[thread overview]
Message-ID: <20171205213414.14641-1-andi@firstfloor.org> (raw)

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

                 reply	other threads:[~2017-12-05 21:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20171205213414.14641-1-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome