Skip to contentSkip to conversation

perf parser: Improve error message for PMU address filters

PATCH In review Jack Henschel 2 participants 3 messages Sep 5, 2017 – Oct 19, 2017 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf parser: Improve error message for PMU address filters

This patch 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:

Quoted 1 line

--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.

---
 tools/perf/util/parse-events.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tools/perf/util/parse-events.c +10 -10
index f44aeba51d1f..672b6d9423e9 100644
@@ -1833,8 +1833,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 	int nr_addr_filters = 0;
 	struct perf_pmu *pmu = NULL;
 
-	if (evsel == NULL)
-		goto err;
+	if (evsel == NULL) {
+		fprintf(stderr,
+			"--filter option should follow a -e tracepoint or HW tracer option\n");
+		return -1;
+	}
 
 	if (evsel->attr.type == PERF_TYPE_TRACEPOINT) {
 		if (perf_evsel__append_tp_filter(evsel, str) < 0) {
@@ -1856,8 +1859,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 		perf_pmu__scan_file(pmu, "nr_addr_filters",
 				    "%d", &nr_addr_filters);
 
-	if (!nr_addr_filters)
-		goto err;
+	if (!nr_addr_filters) {
+		fprintf(stderr,
+			"This CPU does not support address filtering\n");
+		return -1;
+	}
 
 	if (perf_evsel__append_addr_filter(evsel, str) < 0) {
 		fprintf(stderr,
@@ -1866,12 +1872,6 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 	}
 
 	return 0;
-
-err:
-	fprintf(stderr,
-		"--filter option should follow a -e tracepoint or HW tracer option\n");
-
-	return -1;
 }
 
 int parse_filter(const struct option *opt, const char *str,
Signature · 1 line
2.14.1
#1 lore raw
Quoted 53 lines · Jack Henschel

This patch 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:

Quoted 1 line

--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.

---
 tools/perf/util/parse-events.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tools/perf/util/parse-events.c +10 -4
index f44aeba51d1f..672b6d9423e9 100644
@@ -1833,8 +1833,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 	int nr_addr_filters = 0;
 	struct perf_pmu *pmu = NULL;
 
-	if (evsel == NULL)
-		goto err;
+	if (evsel == NULL) {
+		fprintf(stderr,
+			"--filter option should follow a -e tracepoint or HW tracer option\n");
+		return -1;
+	}
 
 	if (evsel->attr.type == PERF_TYPE_TRACEPOINT) {
 		if (perf_evsel__append_tp_filter(evsel, str) < 0) {
@@ -1856,8 +1859,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 		perf_pmu__scan_file(pmu, "nr_addr_filters",
 				    "%d", &nr_addr_filters);
 
-	if (!nr_addr_filters)
-		goto err;
+	if (!nr_addr_filters) {
+		fprintf(stderr,
+			"This CPU does not support address filtering\n");
+		return -1;
+	}
 
 	if (perf_evsel__append_addr_filter(evsel, str) < 0) {
 		fprintf(stderr,
@@ -1866,12 +1872,6 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 	}
 

tools/perf/util/parse-events.c static int set_filter(struct perf_evsel *evsel, const void *arg) · line 1877

Quoted 10 lines
tools/perf/util/parse-events.c +0 -6
 	return 0;
-
-err:
-	fprintf(stderr,
-		"--filter option should follow a -e tracepoint or HW tracer option\n");
-
-	return -1;
 }
 
 int parse_filter(const struct option *opt, const char *str,

Is there any interest in this patch? Did it get lost?

Greetings
Jack

#2 lore raw

Em Thu, Oct 19, 2017 at 09:37:13PM +0200, Jack Henschel escreveu:

Quoted 62 lines · Jack Henschel
Quoted 61 lines

This patch 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:

Quoted 1 line

--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.

---
 tools/perf/util/parse-events.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tools/perf/util/parse-events.c +10 -10
index f44aeba51d1f..672b6d9423e9 100644
@@ -1833,8 +1833,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 	int nr_addr_filters = 0;
 	struct perf_pmu *pmu = NULL;
 
-	if (evsel == NULL)
-		goto err;
+	if (evsel == NULL) {
+		fprintf(stderr,
+			"--filter option should follow a -e tracepoint or HW tracer option\n");
+		return -1;
+	}
 
 	if (evsel->attr.type == PERF_TYPE_TRACEPOINT) {
 		if (perf_evsel__append_tp_filter(evsel, str) < 0) {
@@ -1856,8 +1859,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 		perf_pmu__scan_file(pmu, "nr_addr_filters",
 				    "%d", &nr_addr_filters);
 
-	if (!nr_addr_filters)
-		goto err;
+	if (!nr_addr_filters) {
+		fprintf(stderr,
+			"This CPU does not support address filtering\n");
+		return -1;
+	}
 
 	if (perf_evsel__append_addr_filter(evsel, str) < 0) {
 		fprintf(stderr,
@@ -1866,12 +1872,6 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
 	}
 
 	return 0;
-
-err:
-	fprintf(stderr,
-		"--filter option should follow a -e tracepoint or HW tracer option\n");
-
-	return -1;
 }
 
Quoted 7 lines

tools/perf/util/parse-events.c static int set_filter(struct perf_evsel *evsel, const void *arg) · line 1877

Quoted 2 lines
tools/perf/util/parse-events.c +0 -0
 int parse_filter(const struct option *opt, const char *str,

Is there any interest in this patch? Did it get lost?

Quoted 2 lines

For example, Intel chips based on the Broadwell micro-archticture have the Intel PT PMU, but do not support address filtering.

Can you provide this example with the tool output before and after? I happen to have a Broadwell machine as my current notebook and would just use this to test your patch.

And generally before/after command lines + output is good to quickly show, in more concrete terms what the problem is and how it gets fixed.

- Arnaldo