lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed,  1 May 2013 17:15:40 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Jiri Olsa <jolsa@...hat.com>, Andi Kleen <andi@...stfloor.org>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...e.hu>,
	Namhyung Kim <namhyung@...nel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Ulrich Drepper <drepper@...il.com>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Will Deacon <will.deacon@....com>,
	Stephane Eranian <eranian@...gle.com>
Subject: [PATCH 2/8] perf tools: Factorize event parsing to be more general

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@...hat.com>
Cc: Andi Kleen <andi@...stfloor.org>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Ulrich Drepper <drepper@...il.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Will Deacon <will.deacon@....com>
Cc: Stephane Eranian <eranian@...gle.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists