mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: acme@redhat.com
Cc: jolsa@redhat.com, eranian@google.com, a.p.zijlstra@chello.nl,
	linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 2/3] perf, tools: Default to cpu// for events
Date: Wed,  3 Oct 2012 14:22:42 -0700	[thread overview]
Message-ID: <1349299363-30714-3-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1349299363-30714-1-git-send-email-andi@firstfloor.org>

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

When an event fails to parse and it's not in a new style format,
try to parse it again as a cpu event.

This allows to use sysfs exported events directly without //, so I can use

perf record -e tx-aborts ...

instead of

perf record -e cpu/tx-aborts/

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/util/parse-events.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index de1cb9e..4e7117f 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -785,6 +785,16 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
 	parse_events__flush_buffer(buffer, scanner);
 	parse_events__delete_buffer(buffer, scanner);
 	parse_events_lex_destroy(scanner);
+
+	if (ret && !strchr(str, '/')) {
+		char *s = malloc(strlen(str) + strlen("cpu/") + 2);
+
+		if (!s)
+			return ret;
+		sprintf(s, "cpu/%s/", str);
+		str = s;
+		return parse_events__scanner(str, data, start_token);
+	}
 	return ret;
 }
 
-- 
1.7.7.6


  parent reply	other threads:[~2012-10-03 21:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-03 21:22 Tie lose "perf, tools" ends in Haswell PMU patchkit Andi Kleen
2012-10-03 21:22 ` [PATCH 1/3] perf, tools: Support generic events as pmu event names Andi Kleen
2012-10-03 21:22 ` Andi Kleen [this message]
2012-10-03 21:22 ` [PATCH 3/3] perf, tools: List kernel supplied event aliases in perf list Andi Kleen
2012-10-06 14:57 ` Tie lose "perf, tools" ends in Haswell PMU patchkit Jan Ceuleers
2012-10-06 17:34   ` Andi Kleen

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=1349299363-30714-3-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --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