From: kan.liang@intel.com
To: acme@kernel.org, jolsa@redhat.com
Cc: linux-kernel@vger.kernel.org, ak@linux.intel.com,
Kan Liang <kan.liang@intel.com>
Subject: [PATCH 2/3] perf tools: parse the pmu event prefix and surfix
Date: Fri, 22 Aug 2014 15:42:28 -0400 [thread overview]
Message-ID: <1408736549-4630-2-git-send-email-kan.liang@intel.com> (raw)
In-Reply-To: <1408736549-4630-1-git-send-email-kan.liang@intel.com>
From: Kan Liang <kan.liang@intel.com>
There are two types of event formats for PMU events. E.g. el-abort OR
cpu/el-abort/. However, the lexer mistakenly recognizes the simple style
format as two events.
The newly introduced function uses bsearch to search the name in known
pmu event list. It can tell the lexer that the name is a PE_NAME or a
PMU event name prefix or a PMU event name suffix. All these information
will be used for accurately parsing kernel PMU events.
The implementation is also extensible. For supporting more PMU events,
we only need to simply add the name in the array.
Signed-off-by: Kan Liang <kan.liang@intel.com>
---
tools/perf/util/parse-events.c | 34 ++++++++++++++++++++++++++++++++++
tools/perf/util/parse-events.h | 12 ++++++++++++
2 files changed, 46 insertions(+)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 7a0aa75..6354648 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -666,6 +666,40 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
return evsel ? 0 : -ENOMEM;
}
+/* The contents of the pmu_events should be in ascending sorted by symbol*/
+static struct pmu_event_symbol pmu_events[] = {
+ { "abort", false},
+ { "capacity", false},
+ { "commit", false},
+ { "conflict", false},
+ { "el", true},
+ { "start", false},
+ { "tx", true},
+};
+
+static int
+comp_pmu(const void *p1, const void *p2)
+{
+ struct pmu_event_symbol *pmu1 = (struct pmu_event_symbol *) p1;
+ struct pmu_event_symbol *pmu2 = (struct pmu_event_symbol *) p2;
+
+ return strcmp(pmu1->symbol, pmu2->symbol);
+}
+
+int parse_events_pmu_check(const char *name)
+{
+ struct pmu_event_symbol p, *r;
+
+ p.symbol = name;
+ r = bsearch(&p, pmu_events, ARRAY_SIZE(pmu_events),
+ sizeof(struct pmu_event_symbol), comp_pmu);
+ if (r == NULL)
+ return NONE_PMU_EVENT_FIX;
+
+ return r->is_prefix ?
+ PMU_EVENT_PREFIX : PMU_EVENT_SUFFIX;
+}
+
int parse_events__modifier_group(struct list_head *list,
char *event_mod)
{
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index df094b4..946249e 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -36,6 +36,17 @@ extern int parse_filter(const struct option *opt, const char *str, int unset);
#define EVENTS_HELP_MAX (128*1024)
enum {
+ NONE_PMU_EVENT_FIX,
+ PMU_EVENT_PREFIX,
+ PMU_EVENT_SUFFIX,
+};
+
+struct pmu_event_symbol {
+ const char *symbol;
+ bool is_prefix; /* the prefix of the pmu event */
+};
+
+enum {
PARSE_EVENTS__TERM_TYPE_NUM,
PARSE_EVENTS__TERM_TYPE_STR,
};
@@ -95,6 +106,7 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx,
void *ptr, char *type);
int parse_events_add_pmu(struct list_head *list, int *idx,
char *pmu , struct list_head *head_config);
+int parse_events_pmu_check(const char *name);
void parse_events__set_leader(char *name, struct list_head *list);
void parse_events_update_lists(struct list_head *list_event,
struct list_head *list_all);
--
1.8.3.2
next prev parent reply other threads:[~2014-08-22 19:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-22 19:42 [PATCH 1/3] Revert "perf tools: Default to cpu// for events v5" kan.liang
2014-08-22 19:42 ` kan.liang [this message]
2014-08-22 20:19 ` [PATCH 2/3] perf tools: parse the pmu event prefix and surfix Andi Kleen
2014-08-22 19:42 ` [PATCH 3/3] perf tools: Add support to new style format of kernel PMU event kan.liang
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=1408736549-4630-2-git-send-email-kan.liang@intel.com \
--to=kan.liang@intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.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
all inboxes | Powered by JetHome®