[PATCH 2/3] perf, tools: Default to cpu// for events
From: Andi Kleen
Date: Wed Oct 03 2012 - 17:23:00 EST
From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/