Skip to content

Commit 3bf91aa

Browse files
committed
perf parse: Provide a way to pass a fake_pmu to parse_events()
This is an alternative patch to what Jiri sent that instead of changing all callers to parse_events() for allowing to pass a fake_pmu, provide another function specifically for that. From Jiri's patch: This way it's possible to parse events from PMUs which are not present in the system. It's available only for testing purposes coming in following changes, so all the current users set fake_pmu argument as false. Based-on-a-patch-by: Jiri Olsa <jolsa@kernel.org> Link: http://lore.kernel.org/lkml/20200602214741.1218986-3-jolsa@kernel.org Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 34bacc9 commit 3bf91aa

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎tools/perf/util/parse-events.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,15 +2088,16 @@ int parse_events_terms(struct list_head *terms, const char *str)
20882088
return ret;
20892089
}
20902090

2091-
int parse_events(struct evlist *evlist, const char *str,
2092-
struct parse_events_error *err)
2091+
int __parse_events(struct evlist *evlist, const char *str,
2092+
struct parse_events_error *err, struct perf_pmu *fake_pmu)
20932093
{
20942094
struct parse_events_state parse_state = {
2095-
.list = LIST_HEAD_INIT(parse_state.list),
2096-
.idx = evlist->core.nr_entries,
2097-
.error = err,
2098-
.evlist = evlist,
2099-
.stoken = PE_START_EVENTS,
2095+
.list = LIST_HEAD_INIT(parse_state.list),
2096+
.idx = evlist->core.nr_entries,
2097+
.error = err,
2098+
.evlist = evlist,
2099+
.stoken = PE_START_EVENTS,
2100+
.fake_pmu = fake_pmu,
21002101
};
21012102
int ret;
21022103

‎tools/perf/util/parse-events.h‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ const char *event_type(int type);
3333

3434
int parse_events_option(const struct option *opt, const char *str, int unset);
3535
int parse_events_option_new_evlist(const struct option *opt, const char *str, int unset);
36-
int parse_events(struct evlist *evlist, const char *str,
37-
struct parse_events_error *error);
36+
int __parse_events(struct evlist *evlist, const char *str, struct parse_events_error *error,
37+
struct perf_pmu *fake_pmu);
38+
39+
static inline int parse_events(struct evlist *evlist, const char *str,
40+
struct parse_events_error *err)
41+
{
42+
return __parse_events(evlist, str, err, NULL);
43+
}
44+
3845
int parse_events_terms(struct list_head *terms, const char *str);
3946
int parse_filter(const struct option *opt, const char *str, int unset);
4047
int exclude_perf(const struct option *opt, const char *arg, int unset);

0 commit comments

Comments
 (0)