From: Jiri Olsa <jolsa@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Jiri Olsa <jolsa@redhat.com>, Andi Kleen <andi@firstfloor.org>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>, Namhyung Kim <namhyung@kernel.org>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ulrich Drepper <drepper@gmail.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Will Deacon <will.deacon@arm.com>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 2/8] perf tools: Factorize event parsing to be more general
Date: Wed, 1 May 2013 17:15:40 +0200 [thread overview]
Message-ID: <1367421346-18257-3-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1367421346-18257-1-git-send-email-jolsa@redhat.com>
Making the event parsing processing more general so we
can plug in strings with special processing like formula
definition.
The formula changes are coming in following patches.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ulrich Drepper <drepper@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Stephane Eranian <eranian@google.com>
---
tools/perf/util/parse-events.c | 21 ++++++++++++++++++
tools/perf/util/parse-events.h | 17 +++++++++++++++
tools/perf/util/parse-events.y | 48 +++++++++++++++++++++++++++++++-----------
3 files changed, 74 insertions(+), 12 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6c8bb0f..e8e9dc8 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1238,3 +1238,24 @@ void parse_events__free_terms(struct list_head *terms)
free(terms);
}
+
+int parse_events_config_process(struct parse_events_evlist *data,
+ struct list_head *head)
+{
+ struct parse_events_config *cfg, *h;
+
+ list_for_each_entry_safe(cfg, h, head, list) {
+ switch (cfg->type) {
+ case PARSE_EVENTS_CONFIG_EVENTS:
+ parse_events_update_lists(cfg->events, &data->list);
+ break;
+ default:
+ break;
+ }
+
+ list_del(&cfg->list);
+ free(cfg);
+ }
+
+ return 0;
+}
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 8a48593..98810f1 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -71,6 +71,23 @@ struct parse_events_terms {
struct list_head *terms;
};
+enum parse_events_config_type {
+ PARSE_EVENTS_CONFIG_EVENTS,
+};
+
+struct parse_events_config {
+ enum parse_events_config_type type;
+
+ union {
+ struct list_head *events;
+ void *val;
+ };
+
+ struct list_head list;
+};
+
+int parse_events_config_process(struct parse_events_evlist *data,
+ struct list_head *head);
int parse_events__is_hardcoded_term(struct parse_events_term *term);
int parse_events_term__num(struct parse_events_term **_term,
int type_term, char *config, u64 num);
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index afc44c1..bae1879 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -30,6 +30,21 @@ static inc_group_count(struct list_head *list,
data->nr_groups++;
}
+#define CONFIG(t, v) ({ \
+ struct parse_events_config *c = zalloc(sizeof(*c)); \
+ ABORT_ON(!c); \
+ c->type = PARSE_EVENTS_CONFIG_ ## t; \
+ c->val = v; \
+ c; \
+})
+
+#define HEAD() ({ \
+ struct list_head *h = zalloc(sizeof(*h)); \
+ ABORT_ON(!h); \
+ INIT_LIST_HEAD(h); \
+ h; \
+})
+
%}
%token PE_START_EVENTS PE_START_TERMS
@@ -69,6 +84,7 @@ static inc_group_count(struct list_head *list,
%type <head> group_def
%type <head> group
%type <head> groups
+%type <cfg> groups_config
%union
{
@@ -76,6 +92,7 @@ static inc_group_count(struct list_head *list,
u64 num;
struct list_head *head;
struct parse_events_term *term;
+ struct parse_events_config *cfg;
}
%%
@@ -88,31 +105,38 @@ start_events: groups
{
struct parse_events_evlist *data = _data;
- parse_events_update_lists($1, &data->list);
+ ABORT_ON(parse_events_config_process(data, $1));
}
groups:
-groups ',' group
+groups ',' groups_config
{
- struct list_head *list = $1;
- struct list_head *group = $3;
+ struct list_head *head = $1;
+ struct parse_events_config *cfg = $3;
- parse_events_update_lists(group, list);
- $$ = list;
+ list_add_tail(&cfg->list, head);
+ $$ = head;
}
|
-groups ',' event
+groups_config
{
- struct list_head *list = $1;
- struct list_head *event = $3;
+ struct list_head *head = HEAD();
+ struct parse_events_config *cfg = $1;
- parse_events_update_lists(event, list);
- $$ = list;
+ list_add_tail(&cfg->list, head);
+ $$ = head;
}
-|
+
+groups_config:
group
+{
+ $$ = CONFIG(EVENTS, $1);
+}
|
event
+{
+ $$ = CONFIG(EVENTS, $1);
+}
group:
group_def ':' PE_MODIFIER_EVENT
--
1.7.11.7
next prev parent reply other threads:[~2013-05-01 15:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-01 15:15 [RFCv2 0/8] perf tools: Adding formula support Jiri Olsa
2013-05-01 15:15 ` [PATCH 1/8] perf tools: Move start conditions to start of the flex file Jiri Olsa
2013-05-01 15:15 ` Jiri Olsa [this message]
2013-05-01 15:15 ` [PATCH 3/8] perf tools: Add formula-* parsing support for events Jiri Olsa
2013-05-03 15:07 ` David Ahern
2013-05-06 17:47 ` Jiri Olsa
2013-05-01 15:15 ` [PATCH 4/8] perf tools: Add formula interface to interface formula definitions Jiri Olsa
2013-05-15 9:13 ` Peter Zijlstra
2013-05-01 15:15 ` [PATCH 5/8] perf tools: Add support to preload default formulas Jiri Olsa
2013-05-03 15:11 ` David Ahern
2013-05-06 17:48 ` Jiri Olsa
2013-05-01 15:15 ` [PATCH 6/8] perf tests: Add automated tests for formula object Jiri Olsa
2013-05-03 15:18 ` David Ahern
2013-05-06 17:54 ` Jiri Olsa
2013-05-06 18:08 ` David Ahern
2013-05-01 15:15 ` [PATCH 7/8] perf stat: Add support to process formulas Jiri Olsa
2013-05-01 15:15 ` [PATCH 8/8] perf list: List formulas counters Jiri Olsa
2013-05-06 17:44 ` [RFCv2 0/8] perf tools: Adding formula support Jiri Olsa
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=1367421346-18257-3-git-send-email-jolsa@redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=andi@firstfloor.org \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=drepper@gmail.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=will.deacon@arm.com \
/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®