[PATCH 21/59] perf tools: Pass parse_state all the way down to add_tracepoint
From: Jiri Olsa <hidden>
Date: 2021-11-08 13:39:33
Subsystem:
performance events subsystem, the rest · Maintainers:
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Linus Torvalds
So we can provide event allocation callbacks. Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- tools/perf/util/parse-events.c | 30 ++++++++++++++++++------------ tools/perf/util/parse-events.h | 3 ++- tools/perf/util/parse-events.y | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index d3ad2c89c7a2..8f8151738a78 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c@@ -595,11 +595,13 @@ static void tracepoint_error(struct parse_events_error *e, int err, parse_events__handle_error(e, 0, strdup(str), strdup(help)); } -static int add_tracepoint(struct list_head *list, int *idx, +static int add_tracepoint(struct parse_events_state *parse_state, + struct list_head *list, const char *sys_name, const char *evt_name, struct parse_events_error *err, struct list_head *head_config) { + int *idx = &parse_state->idx; struct evsel *evsel = evsel__newtp_idx(sys_name, evt_name, (*idx)++); if (IS_ERR(evsel)) {
@@ -619,7 +621,8 @@ static int add_tracepoint(struct list_head *list, int *idx, return 0; } -static int add_tracepoint_multi_event(struct list_head *list, int *idx, +static int add_tracepoint_multi_event(struct parse_events_state *parse_state, + struct list_head *list, const char *sys_name, const char *evt_name, struct parse_events_error *err, struct list_head *head_config)
@@ -653,7 +656,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx, found++; - ret = add_tracepoint(list, idx, sys_name, evt_ent->d_name, + ret = add_tracepoint(parse_state, list, sys_name, evt_ent->d_name, err, head_config); }
@@ -667,19 +670,21 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx, return ret; } -static int add_tracepoint_event(struct list_head *list, int *idx, +static int add_tracepoint_event(struct parse_events_state *parse_state, + struct list_head *list, const char *sys_name, const char *evt_name, struct parse_events_error *err, struct list_head *head_config) { return strpbrk(evt_name, "*?") ? - add_tracepoint_multi_event(list, idx, sys_name, evt_name, + add_tracepoint_multi_event(parse_state, list, sys_name, evt_name, err, head_config) : - add_tracepoint(list, idx, sys_name, evt_name, + add_tracepoint(parse_state, list, sys_name, evt_name, err, head_config); } -static int add_tracepoint_multi_sys(struct list_head *list, int *idx, +static int add_tracepoint_multi_sys(struct parse_events_state *parse_state, + struct list_head *list, const char *sys_name, const char *evt_name, struct parse_events_error *err, struct list_head *head_config)
@@ -705,7 +710,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx, if (!strglobmatch(events_ent->d_name, sys_name)) continue; - ret = add_tracepoint_event(list, idx, events_ent->d_name, + ret = add_tracepoint_event(parse_state, list, events_ent->d_name, evt_name, err, head_config); }
@@ -742,7 +747,7 @@ static int add_bpf_event(const char *group, const char *event, int fd, struct bp pr_debug("add bpf event %s:%s and attach bpf program %d\n", group, event, fd); - err = parse_events_add_tracepoint(&new_evsels, &parse_state->idx, group, + err = parse_events_add_tracepoint(parse_state, &new_evsels, group, event, parse_state->error, param->head_config); if (err) {
@@ -1440,7 +1445,8 @@ static int get_config_chgs(struct perf_pmu *pmu, struct list_head *head_config, return 0; } -int parse_events_add_tracepoint(struct list_head *list, int *idx, +int parse_events_add_tracepoint(struct parse_events_state *parse_state, + struct list_head *list, const char *sys, const char *event, struct parse_events_error *err, struct list_head *head_config)
@@ -1454,10 +1460,10 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx, } if (strpbrk(sys, "*?")) - return add_tracepoint_multi_sys(list, idx, sys, event, + return add_tracepoint_multi_sys(parse_state, list, sys, event, err, head_config); else - return add_tracepoint_event(list, idx, sys, event, + return add_tracepoint_event(parse_state, list, sys, event, err, head_config); }
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 218a282d8b3d..aedb1153a1a1 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h@@ -164,7 +164,8 @@ void parse_events__clear_array(struct parse_events_array *a); int parse_events__modifier_event(struct list_head *list, char *str, bool add); int parse_events__modifier_group(struct list_head *list, char *event_mod); int parse_events_name(struct list_head *list, const char *name); -int parse_events_add_tracepoint(struct list_head *list, int *idx, +int parse_events_add_tracepoint(struct parse_events_state *parse_state, + struct list_head *list, const char *sys, const char *event, struct parse_events_error *error, struct list_head *head_config);
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 30c382d4a605..7d7bffed0dd7 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y@@ -605,7 +605,7 @@ tracepoint_name opt_event_config if (error) error->idx = @1.first_column; - err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event, + err = parse_events_add_tracepoint(parse_state, list, $1.sys, $1.event, error, $2); parse_events_terms__delete($2);
--
2.31.1