lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 24 Mar 2015 12:10:17 -0400
From:	David Ahern <david.ahern@...cle.com>
To:	acme@...nel.org
Cc:	linux-kernel@...r.kernel.org, David Ahern <david.ahern@...cle.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>
Subject: [PATCH] perf tool: Add event name to error message for filters

Use of a bad filter currently generates the message:
 Error: failed to set filter with 22 (Invalid argument)

Add the event name to make it clear to which event the filter
failed to apply:
  Error: Failed to set filter on event sched:sg_lb_stats: 22: Invalid argument

Signed-off-by: David Ahern <david.ahern@...cle.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/builtin-record.c |  2 --
 tools/perf/builtin-stat.c   |  5 +----
 tools/perf/util/evsel.c     | 16 +++++++++++++---
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 091868288d29..b4acd0933c7c 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -162,8 +162,6 @@ static int record__open(struct record *rec)
 	}
 
 	if (perf_evlist__apply_filters(evlist)) {
-		error("failed to set filter with %d (%s)\n", errno,
-			strerror_r(errno, msg, sizeof(msg)));
 		rc = -1;
 		goto out;
 	}
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index d4d1b77da0bd..2aceb9296e8f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -684,11 +684,8 @@ static int __run_perf_stat(int argc, const char **argv)
 			unit_width = l;
 	}
 
-	if (perf_evlist__apply_filters(evsel_list)) {
-		error("failed to set filter with %d (%s)\n", errno,
-			strerror_r(errno, msg, sizeof(msg)));
+	if (perf_evlist__apply_filters(evsel_list))
 		return -1;
-	}
 
 	/*
 	 * Enable counters and exec the command:
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bb4eff28869e..daa053d9c638 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -807,9 +807,19 @@ static int perf_evsel__run_ioctl(struct perf_evsel *evsel, int ncpus, int nthrea
 int perf_evsel__set_filter(struct perf_evsel *evsel, int ncpus, int nthreads,
 			   const char *filter)
 {
-	return perf_evsel__run_ioctl(evsel, ncpus, nthreads,
-				     PERF_EVENT_IOC_SET_FILTER,
-				     (void *)filter);
+	int err;
+	char msg[512];
+
+	err = perf_evsel__run_ioctl(evsel, ncpus, nthreads,
+				    PERF_EVENT_IOC_SET_FILTER,
+				    (void *)filter);
+	if (err) {
+		error("Failed to set filter on event %s: %d: %s\n",
+		      perf_evsel__name(evsel), errno,
+		      strerror_r(errno, msg, sizeof(msg)));
+	}
+
+	return err;
 }
 
 int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads)
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ