aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Henschel <jackdev@mailbox.org>2018-07-04 08:13:45 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-08-20 07:54:58 -0400
commit49836f7811f383d8613661fff110ce74f4710d52 (patch)
tree06cb98ace9b919e0ffeefa7acc409f38dd08df73
parentda15fc2fa9c07b23db8f5e479bd8a9f0d741ca07 (diff)
perf parser: Improve error message for PMU address filters
This is the second version of a patch that improves the error message of the perf events parser when the PMU hardware does not support address filters. Previously, the perf returned the following error: $ perf record -e intel_pt// --filter 'filter sys_write' --filter option should follow a -e tracepoint or HW tracer option This implies there is some syntax error present in the command line, which is not true. Rather, notify the user that the CPU does not have support for this feature. For example, Intel chips based on the Broadwell micro-archticture have the Intel PT PMU, but do not support address filtering. Now, perf prints the following error message: $ perf record -e intel_pt// --filter 'filter sys_write' This CPU does not support address filtering Signed-off-by: Jack Henschel <jackdev@mailbox.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20180704121345.19025-1-jackdev@mailbox.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/parse-events.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 15eec49e71a1..f8cd3e7c9186 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1991,8 +1991,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
1991 int nr_addr_filters = 0; 1991 int nr_addr_filters = 0;
1992 struct perf_pmu *pmu = NULL; 1992 struct perf_pmu *pmu = NULL;
1993 1993
1994 if (evsel == NULL) 1994 if (evsel == NULL) {
1995 goto err; 1995 fprintf(stderr,
1996 "--filter option should follow a -e tracepoint or HW tracer option\n");
1997 return -1;
1998 }
1996 1999
1997 if (evsel->attr.type == PERF_TYPE_TRACEPOINT) { 2000 if (evsel->attr.type == PERF_TYPE_TRACEPOINT) {
1998 if (perf_evsel__append_tp_filter(evsel, str) < 0) { 2001 if (perf_evsel__append_tp_filter(evsel, str) < 0) {
@@ -2014,8 +2017,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
2014 perf_pmu__scan_file(pmu, "nr_addr_filters", 2017 perf_pmu__scan_file(pmu, "nr_addr_filters",
2015 "%d", &nr_addr_filters); 2018 "%d", &nr_addr_filters);
2016 2019
2017 if (!nr_addr_filters) 2020 if (!nr_addr_filters) {
2018 goto err; 2021 fprintf(stderr,
2022 "This CPU does not support address filtering\n");
2023 return -1;
2024 }
2019 2025
2020 if (perf_evsel__append_addr_filter(evsel, str) < 0) { 2026 if (perf_evsel__append_addr_filter(evsel, str) < 0) {
2021 fprintf(stderr, 2027 fprintf(stderr,
@@ -2024,12 +2030,6 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
2024 } 2030 }
2025 2031
2026 return 0; 2032 return 0;
2027
2028err:
2029 fprintf(stderr,
2030 "--filter option should follow a -e tracepoint or HW tracer option\n");
2031
2032 return -1;
2033} 2033}
2034 2034
2035int parse_filter(const struct option *opt, const char *str, 2035int parse_filter(const struct option *opt, const char *str,