Commit 81a4e31f authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events: Improve location for add pmu

Improve the location for add PMU for cases when PMUs aren't found.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20230627181030.95608-13-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d81fa63b
...@@ -1575,13 +1575,14 @@ static bool config_term_percore(struct list_head *config_terms) ...@@ -1575,13 +1575,14 @@ static bool config_term_percore(struct list_head *config_terms)
int parse_events_add_pmu(struct parse_events_state *parse_state, int parse_events_add_pmu(struct parse_events_state *parse_state,
struct list_head *list, char *name, struct list_head *list, char *name,
struct list_head *head_config, struct list_head *head_config,
bool auto_merge_stats) bool auto_merge_stats, void *loc_)
{ {
struct perf_event_attr attr; struct perf_event_attr attr;
struct perf_pmu_info info; struct perf_pmu_info info;
struct perf_pmu *pmu; struct perf_pmu *pmu;
struct evsel *evsel; struct evsel *evsel;
struct parse_events_error *err = parse_state->error; struct parse_events_error *err = parse_state->error;
YYLTYPE *loc = loc_;
LIST_HEAD(config_terms); LIST_HEAD(config_terms);
pmu = parse_state->fake_pmu ?: perf_pmus__find(name); pmu = parse_state->fake_pmu ?: perf_pmus__find(name);
...@@ -1605,7 +1606,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, ...@@ -1605,7 +1606,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
if (asprintf(&err_str, if (asprintf(&err_str,
"Cannot find PMU `%s'. Missing kernel support?", "Cannot find PMU `%s'. Missing kernel support?",
name) >= 0) name) >= 0)
parse_events_error__handle(err, 0, err_str, NULL); parse_events_error__handle(err, loc->first_column, err_str, NULL);
return -EINVAL; return -EINVAL;
} }
if (head_config) if (head_config)
...@@ -1691,12 +1692,13 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, ...@@ -1691,12 +1692,13 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
int parse_events_multi_pmu_add(struct parse_events_state *parse_state, int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
char *str, struct list_head *head, char *str, struct list_head *head,
struct list_head **listp) struct list_head **listp, void *loc_)
{ {
struct parse_events_term *term; struct parse_events_term *term;
struct list_head *list = NULL; struct list_head *list = NULL;
struct list_head *orig_head = NULL; struct list_head *orig_head = NULL;
struct perf_pmu *pmu = NULL; struct perf_pmu *pmu = NULL;
YYLTYPE *loc = loc_;
int ok = 0; int ok = 0;
char *config; char *config;
...@@ -1743,7 +1745,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state, ...@@ -1743,7 +1745,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
parse_events_copy_term_list(head, &orig_head); parse_events_copy_term_list(head, &orig_head);
if (!parse_events_add_pmu(parse_state, list, if (!parse_events_add_pmu(parse_state, list,
pmu->name, orig_head, pmu->name, orig_head,
auto_merge_stats)) { auto_merge_stats, loc)) {
pr_debug("%s -> %s/%s/\n", str, pr_debug("%s -> %s/%s/\n", str,
pmu->name, alias->str); pmu->name, alias->str);
parse_state->wild_card_pmus = true; parse_state->wild_card_pmus = true;
...@@ -1756,7 +1758,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state, ...@@ -1756,7 +1758,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
if (parse_state->fake_pmu) { if (parse_state->fake_pmu) {
if (!parse_events_add_pmu(parse_state, list, str, head, if (!parse_events_add_pmu(parse_state, list, str, head,
/*auto_merge_stats=*/true)) { /*auto_merge_stats=*/true, loc)) {
pr_debug("%s -> %s/%s/\n", str, "fake_pmu", str); pr_debug("%s -> %s/%s/\n", str, "fake_pmu", str);
ok++; ok++;
} }
......
...@@ -202,7 +202,7 @@ int parse_events_add_breakpoint(struct parse_events_state *parse_state, ...@@ -202,7 +202,7 @@ int parse_events_add_breakpoint(struct parse_events_state *parse_state,
int parse_events_add_pmu(struct parse_events_state *parse_state, int parse_events_add_pmu(struct parse_events_state *parse_state,
struct list_head *list, char *name, struct list_head *list, char *name,
struct list_head *head_config, struct list_head *head_config,
bool auto_merge_stats); bool auto_merge_stats, void *loc);
struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr,
const char *name, const char *metric_id, const char *name, const char *metric_id,
...@@ -211,7 +211,7 @@ struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, ...@@ -211,7 +211,7 @@ struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr,
int parse_events_multi_pmu_add(struct parse_events_state *parse_state, int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
char *str, char *str,
struct list_head *head_config, struct list_head *head_config,
struct list_head **listp); struct list_head **listp, void *loc);
int parse_events_copy_term_list(struct list_head *old, int parse_events_copy_term_list(struct list_head *old,
struct list_head **new); struct list_head **new);
......
...@@ -313,7 +313,7 @@ PE_NAME opt_pmu_config ...@@ -313,7 +313,7 @@ PE_NAME opt_pmu_config
YYNOMEM; YYNOMEM;
} }
/* Attempt to add to list assuming $1 is a PMU name. */ /* Attempt to add to list assuming $1 is a PMU name. */
if (parse_events_add_pmu(parse_state, list, $1, $2, /*auto_merge_stats=*/false)) { if (parse_events_add_pmu(parse_state, list, $1, $2, /*auto_merge_stats=*/false, &@1)) {
struct perf_pmu *pmu = NULL; struct perf_pmu *pmu = NULL;
int ok = 0; int ok = 0;
...@@ -341,7 +341,7 @@ PE_NAME opt_pmu_config ...@@ -341,7 +341,7 @@ PE_NAME opt_pmu_config
YYNOMEM; YYNOMEM;
} }
if (!parse_events_add_pmu(parse_state, list, pmu->name, terms, if (!parse_events_add_pmu(parse_state, list, pmu->name, terms,
auto_merge_stats)) { auto_merge_stats, &@1)) {
ok++; ok++;
parse_state->wild_card_pmus = true; parse_state->wild_card_pmus = true;
} }
...@@ -352,7 +352,7 @@ PE_NAME opt_pmu_config ...@@ -352,7 +352,7 @@ PE_NAME opt_pmu_config
if (!ok) { if (!ok) {
/* Failure to add, assume $1 is an event name. */ /* Failure to add, assume $1 is an event name. */
zfree(&list); zfree(&list);
ok = !parse_events_multi_pmu_add(parse_state, $1, $2, &list); ok = !parse_events_multi_pmu_add(parse_state, $1, $2, &list, &@1);
$2 = NULL; $2 = NULL;
} }
if (!ok) { if (!ok) {
...@@ -379,7 +379,7 @@ PE_NAME sep_dc ...@@ -379,7 +379,7 @@ PE_NAME sep_dc
struct list_head *list; struct list_head *list;
int err; int err;
err = parse_events_multi_pmu_add(_parse_state, $1, NULL, &list); err = parse_events_multi_pmu_add(_parse_state, $1, NULL, &list, &@1);
if (err < 0) { if (err < 0) {
struct parse_events_state *parse_state = _parse_state; struct parse_events_state *parse_state = _parse_state;
struct parse_events_error *error = parse_state->error; struct parse_events_error *error = parse_state->error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment