From: tip-bot for Jiri Olsa <jolsa@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
a.p.zijlstra@chello.nl, tglx@linutronix.de, jolsa@redhat.com
Subject: [tip:perf/core] perf/tool: Use data struct for arg passing in event parse function
Date: Wed, 20 Jun 2012 03:57:51 -0700 [thread overview]
Message-ID: <tip-46010ab2607aed9484816a8f1679c2ec3c8e7dcf@git.kernel.org> (raw)
In-Reply-To: <1339741902-8449-10-git-send-email-zheng.z.yan@intel.com>
Commit-ID: 46010ab2607aed9484816a8f1679c2ec3c8e7dcf
Gitweb: http://git.kernel.org/tip/46010ab2607aed9484816a8f1679c2ec3c8e7dcf
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Fri, 15 Jun 2012 14:31:38 +0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 18 Jun 2012 12:13:24 +0200
perf/tool: Use data struct for arg passing in event parse function
Moving all the bison arguments into the structure. In upcomming
patches we are going to:
- add more arguments
- reuse the grammer for term parsing
so it's more clear to pack/separate related arguments.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1339741902-8449-10-git-send-email-zheng.z.yan@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/perf/util/parse-events.c | 16 +++++++-----
tools/perf/util/parse-events.h | 8 ++++-
tools/perf/util/parse-events.y | 52 +++++++++++++++++++++++++++-------------
3 files changed, 50 insertions(+), 26 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 05dbc8b..c71b29a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -26,7 +26,7 @@ struct event_symbol {
#ifdef PARSER_DEBUG
extern int parse_events_debug;
#endif
-int parse_events_parse(struct list_head *list, int *idx);
+int parse_events_parse(void *data);
#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
@@ -789,25 +789,27 @@ int parse_events_modifier(struct list_head *list, char *str)
int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
{
- LIST_HEAD(list);
- LIST_HEAD(list_tmp);
+ struct parse_events_data__events data = {
+ .list = LIST_HEAD_INIT(data.list),
+ .idx = evlist->nr_entries,
+ };
YY_BUFFER_STATE buffer;
- int ret, idx = evlist->nr_entries;
+ int ret;
buffer = parse_events__scan_string(str);
#ifdef PARSER_DEBUG
parse_events_debug = 1;
#endif
- ret = parse_events_parse(&list, &idx);
+ ret = parse_events_parse(&data);
parse_events__flush_buffer(buffer);
parse_events__delete_buffer(buffer);
parse_events_lex_destroy();
if (!ret) {
- int entries = idx - evlist->nr_entries;
- perf_evlist__splice_list_tail(evlist, &list, entries);
+ int entries = data.idx - evlist->nr_entries;
+ perf_evlist__splice_list_tail(evlist, &data.list, entries);
return 0;
}
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 8cac57a..dc3c83a 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -63,6 +63,11 @@ struct parse_events__term {
struct list_head list;
};
+struct parse_events_data__events {
+ struct list_head list;
+ int idx;
+};
+
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, long num);
@@ -83,8 +88,7 @@ int parse_events_add_pmu(struct list_head **list, int *idx,
char *pmu , struct list_head *head_config);
void parse_events_update_lists(struct list_head *list_event,
struct list_head *list_all);
-void parse_events_error(struct list_head *list_all,
- int *idx, char const *msg);
+void parse_events_error(void *data, char const *msg);
int parse_events__test(void);
void print_events(const char *event_glob);
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 362cc59..e533bf7 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -1,7 +1,6 @@
%name-prefix "parse_events_"
-%parse-param {struct list_head *list_all}
-%parse-param {int *idx}
+%parse-param {void *_data}
%{
@@ -64,18 +63,22 @@ events ',' event | event
event:
event_def PE_MODIFIER_EVENT
{
+ struct parse_events_data__events *data = _data;
+
/*
* Apply modifier on all events added by single event definition
* (there could be more events added for multiple tracepoint
* definitions via '*?'.
*/
ABORT_ON(parse_events_modifier($1, $2));
- parse_events_update_lists($1, list_all);
+ parse_events_update_lists($1, &data->list);
}
|
event_def
{
- parse_events_update_lists($1, list_all);
+ struct parse_events_data__events *data = _data;
+
+ parse_events_update_lists($1, &data->list);
}
event_def: event_pmu |
@@ -89,9 +92,10 @@ event_def: event_pmu |
event_pmu:
PE_NAME '/' event_config '/'
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_pmu(&list, idx, $1, $3));
+ ABORT_ON(parse_events_add_pmu(&list, &data->idx, $1, $3));
parse_events__free_terms($3);
$$ = list;
}
@@ -99,91 +103,106 @@ PE_NAME '/' event_config '/'
event_legacy_symbol:
PE_VALUE_SYM '/' event_config '/'
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
int type = $1 >> 16;
int config = $1 & 255;
- ABORT_ON(parse_events_add_numeric(&list, idx, type, config, $3));
+ ABORT_ON(parse_events_add_numeric(&list, &data->idx,
+ type, config, $3));
parse_events__free_terms($3);
$$ = list;
}
|
PE_VALUE_SYM sep_slash_dc
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
int type = $1 >> 16;
int config = $1 & 255;
- ABORT_ON(parse_events_add_numeric(&list, idx, type, config, NULL));
+ ABORT_ON(parse_events_add_numeric(&list, &data->idx,
+ type, config, NULL));
$$ = list;
}
event_legacy_cache:
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, $5));
+ ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, $5));
$$ = list;
}
|
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_cache(&list, idx, $1, $3, NULL));
+ ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, $3, NULL));
$$ = list;
}
|
PE_NAME_CACHE_TYPE
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_cache(&list, idx, $1, NULL, NULL));
+ ABORT_ON(parse_events_add_cache(&list, &data->idx, $1, NULL, NULL));
$$ = list;
}
event_legacy_mem:
PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, $4));
+ ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
+ (void *) $2, $4));
$$ = list;
}
|
PE_PREFIX_MEM PE_VALUE sep_dc
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_breakpoint(&list, idx, (void *) $2, NULL));
+ ABORT_ON(parse_events_add_breakpoint(&list, &data->idx,
+ (void *) $2, NULL));
$$ = list;
}
event_legacy_tracepoint:
PE_NAME ':' PE_NAME
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_tracepoint(&list, idx, $1, $3));
+ ABORT_ON(parse_events_add_tracepoint(&list, &data->idx, $1, $3));
$$ = list;
}
event_legacy_numeric:
PE_VALUE ':' PE_VALUE
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_numeric(&list, idx, $1, $3, NULL));
+ ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
$$ = list;
}
event_legacy_raw:
PE_RAW
{
+ struct parse_events_data__events *data = _data;
struct list_head *list = NULL;
- ABORT_ON(parse_events_add_numeric(&list, idx, PERF_TYPE_RAW, $1, NULL));
+ ABORT_ON(parse_events_add_numeric(&list, &data->idx,
+ PERF_TYPE_RAW, $1, NULL));
$$ = list;
}
@@ -267,8 +286,7 @@ sep_slash_dc: '/' | ':' |
%%
-void parse_events_error(struct list_head *list_all __used,
- int *idx __used,
+void parse_events_error(void *data __used,
char const *msg __used)
{
}
next prev parent reply other threads:[~2012-06-20 10:58 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 6:31 [PATCH V6 0/13] perf: Intel uncore pmu counting support Yan, Zheng
2012-06-15 6:31 ` [PATCH V6 01/13] perf: Export perf_assign_events Yan, Zheng
2012-06-20 10:49 ` [tip:perf/core] perf: Export perf_assign_events() tip-bot for Yan, Zheng
2012-06-15 6:31 ` [PATCH V6 02/13] perf: Avoid race between cpu hotplug and installing event Yan, Zheng
2012-06-20 10:50 ` [tip:perf/core] " tip-bot for Yan, Zheng
2012-06-15 6:31 ` [PATCH V6 03/13] perf: Allow pmu to choose cpu on which to install event Yan, Zheng
2012-06-20 10:51 ` [tip:perf/core] perf: Allow the PMU driver to choose the CPU on which to install events tip-bot for Yan, Zheng
2012-06-15 6:31 ` [PATCH V6 04/13] perf: Introduce perf_pmu_migrate_context Yan, Zheng
2012-06-20 10:52 ` [tip:perf/core] perf: Introduce perf_pmu_migrate_context() tip-bot for Yan, Zheng
2012-06-15 6:31 ` [PATCH V6 05/13] perf: Generic intel uncore support Yan, Zheng
2012-06-20 10:54 ` [tip:perf/core] perf/x86: Add generic Intel uncore PMU support tip-bot for Yan, Zheng
2012-06-21 22:43 ` Andrew Morton
2012-06-21 22:46 ` Andrew Morton
2012-06-21 22:47 ` H. Peter Anvin
2012-06-21 22:51 ` Andrew Morton
2012-06-21 23:10 ` H. Peter Anvin
2012-06-21 23:15 ` Andrew Morton
2012-06-21 23:18 ` Andrew Morton
2012-06-21 23:22 ` H. Peter Anvin
2012-06-21 23:29 ` Andrew Morton
2012-06-22 8:05 ` Peter Zijlstra
2012-07-24 3:27 ` [PATCH V6 05/13] perf: Generic intel uncore support Stephane Eranian
2012-07-24 6:00 ` Yan, Zheng
2012-07-24 6:21 ` Stephane Eranian
2012-06-15 6:31 ` [PATCH V6 06/13] perf: Add Nehalem and Sandy Bridge " Yan, Zheng
2012-06-15 15:28 ` Peter Zijlstra
2012-06-15 16:31 ` Peter Zijlstra
2012-06-15 18:43 ` Andi Kleen
2012-06-15 17:18 ` Peter Zijlstra
2012-06-15 18:46 ` Stephane Eranian
2012-06-16 12:46 ` Peter Zijlstra
2012-06-16 12:52 ` Peter Zijlstra
2012-06-18 9:23 ` Stephane Eranian
2012-06-19 1:39 ` Yan, Zheng
2012-06-15 17:29 ` Peter Zijlstra
2012-06-15 18:47 ` Stephane Eranian
2012-06-16 12:46 ` Peter Zijlstra
2012-06-20 10:55 ` [tip:perf/core] perf/x86: Add Intel Nehalem and Sandy Bridge uncore PMU support tip-bot for Yan, Zheng
2012-06-15 6:31 ` [PATCH V6 07/13] perf: Generic pci uncore device support Yan, Zheng
2012-06-15 16:02 ` Peter Zijlstra
2012-06-18 3:06 ` Yan, Zheng
2012-06-18 7:43 ` Peter Zijlstra
2012-06-20 10:56 ` [tip:perf/core] perf: Add generic PCI uncore PMU " tip-bot for Yan, Zheng
2012-06-20 16:39 ` [PATCH] perf, x86: Fix section mismatch in uncore_pci_init() Robert Richter
2012-06-25 11:40 ` [tip:perf/core] perf/x86: Fix section mismatch in uncore_pci_init( ) tip-bot for Robert Richter
2012-08-13 17:10 ` [tip:perf/urgent] perf, x86: Fix uncore_types_exit section mismatch tip-bot for Borislav Petkov
2012-06-15 6:31 ` [PATCH V6 08/13] perf: Add Sandy Bridge-EP uncore support Yan, Zheng
2012-06-15 17:10 ` Peter Zijlstra
2012-06-18 1:47 ` Yan, Zheng
2012-06-18 7:42 ` Peter Zijlstra
2012-06-18 15:28 ` Stephane Eranian
2012-06-19 0:59 ` Yan, Zheng
2012-06-19 7:18 ` Stephane Eranian
2012-06-19 8:17 ` Yan, Zheng
2012-06-20 10:56 ` [tip:perf/core] perf/x86: Add Intel Nehalem and " tip-bot for Yan, Zheng
2012-07-22 19:37 ` [PATCH V6 08/13] perf: Add " Stephane Eranian
2012-06-15 6:31 ` [PATCH V6 09/13] perf, tool: Use data struct for arg passing in event parse function Yan, Zheng
2012-06-20 10:57 ` tip-bot for Jiri Olsa [this message]
2012-06-15 6:31 ` [PATCH V6 10/13] perf, tool: Make the event parser reentrantable Yan, Zheng
2012-06-20 10:58 ` [tip:perf/core] perf/tool: Make the event parser re-entrant tip-bot for Zheng Yan
2012-06-15 6:31 ` [PATCH V6 11/13] perf, tool: Add support to reuse event grammar to parse out terms Yan, Zheng
2012-06-20 10:59 ` [tip:perf/core] perf/tool: " tip-bot for Jiri Olsa
2012-06-15 6:31 ` [PATCH V6 12/13] perf, tool: Add pmu event alias support Yan, Zheng
2012-06-20 11:00 ` [tip:perf/core] perf/tool: Add PMU " tip-bot for Zheng Yan
2012-06-15 6:31 ` [PATCH V6 13/13] perf, tool: Add automated test for pure terms parsing Yan, Zheng
2012-06-20 11:01 ` [tip:perf/core] perf/tool: " tip-bot for Jiri Olsa
2012-06-20 16:01 ` [PATCH V6 0/13] perf: Intel uncore pmu counting support Peter Zijlstra
2012-06-21 2:34 ` Yan, Zheng
2012-06-21 8:10 ` Stephane Eranian
2012-06-21 8:43 ` Yan, Zheng
2012-06-21 9:13 ` Stephane Eranian
2012-06-21 11:40 ` Peter Zijlstra
2012-06-21 11:48 ` Stephane Eranian
2012-06-21 13:08 ` Yan, Zheng
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=tip-46010ab2607aed9484816a8f1679c2ec3c8e7dcf@git.kernel.org \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.