From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
bpf@vger.kernel.org, Arnaldo Carvalho de Melo <acme@redhat.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.5 074/285] perf parse-events: Additional error reporting
Date: Sun, 17 Sep 2023 21:11:14 +0200 [thread overview]
Message-ID: <20230917191054.280992183@linuxfoundation.org> (raw)
In-Reply-To: <20230917191051.639202302@linuxfoundation.org>
6.5-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <irogers@google.com>
[ Upstream commit b30d4f0b695428f513c561eeaea52e042ef48550 ]
When no events or PMUs match report an error for event_pmu:
Before:
```
$ perf stat -e 'asdfasdf' -a sleep 1
Run 'perf list' for a list of valid events
Usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events
```
After:
```
$ perf stat -e 'asdfasdf' -a sleep 1
event syntax error: 'asdfasdf'
\___ Bad event name
Unabled to find PMU or event on a PMU of 'asdfasdf'
Run 'perf list' for a list of valid events
Usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events
```
Fixes the inadvertent removal when hybrid parsing was modified.
Fixes: 70c90e4a6b2fbe77 ("perf parse-events: Avoid scanning PMUs before parsing")
Signed-off-by: Ian 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: Ian Rogers <irogers@google.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-11-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/perf/util/parse-events.y | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 24274c6cf85f1..c590cf7f02a45 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -293,7 +293,6 @@ PE_NAME opt_pmu_config
{
struct parse_events_state *parse_state = _parse_state;
struct list_head *list = NULL, *orig_terms = NULL, *terms= NULL;
- struct parse_events_error *error = parse_state->error;
char *pattern = NULL;
#define CLEANUP \
@@ -305,9 +304,6 @@ PE_NAME opt_pmu_config
free(pattern); \
} while(0)
- if (error)
- error->idx = @1.first_column;
-
if (parse_events_copy_term_list($2, &orig_terms)) {
CLEANUP;
YYNOMEM;
@@ -362,6 +358,14 @@ PE_NAME opt_pmu_config
$2 = NULL;
}
if (!ok) {
+ struct parse_events_error *error = parse_state->error;
+ char *help;
+
+ if (asprintf(&help, "Unabled to find PMU or event on a PMU of '%s'", $1) < 0)
+ help = NULL;
+ parse_events_error__handle(error, @1.first_column,
+ strdup("Bad event or PMU"),
+ help);
CLEANUP;
YYABORT;
}
@@ -390,9 +394,18 @@ PE_NAME sep_dc
int err;
err = parse_events_multi_pmu_add(_parse_state, $1, NULL, &list);
- free($1);
- if (err < 0)
+ if (err < 0) {
+ struct parse_events_state *parse_state = _parse_state;
+ struct parse_events_error *error = parse_state->error;
+ char *help;
+
+ if (asprintf(&help, "Unabled to find PMU or event on a PMU of '%s'", $1) < 0)
+ help = NULL;
+ parse_events_error__handle(error, @1.first_column, strdup("Bad event name"), help);
+ free($1);
PE_ABORT(err);
+ }
+ free($1);
$$ = list;
}
|
--
2.40.1
next prev parent reply other threads:[~2023-09-17 19:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230917191051.639202302@linuxfoundation.org>
2023-09-17 19:11 ` [PATCH 6.5 071/285] perf parse-events: Separate YYABORT and YYNOMEM cases Greg Kroah-Hartman
2023-09-17 19:11 ` [PATCH 6.5 072/285] perf parse-events: Move instances of YYABORT to YYNOMEM Greg Kroah-Hartman
2023-09-17 19:11 ` [PATCH 6.5 073/285] perf parse-events: Separate ENOMEM memory handling Greg Kroah-Hartman
2023-09-17 19:11 ` Greg Kroah-Hartman [this message]
2023-09-17 19:11 ` [PATCH 6.5 098/285] perf test stat_bpf_counters_cgrp: Enhance perf stat cgroup BPF counter test Greg Kroah-Hartman
2023-09-17 19:13 ` [PATCH 6.5 234/285] perf test shell stat_bpf_counters: Fix test on Intel Greg Kroah-Hartman
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=20230917191054.280992183@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox