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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 24 Sep 2014 13:51:09 -0700
From:	Andi Kleen <andi@...stfloor.org>
To:	jolsa@...hat.com
Cc:	linux-kernel@...r.kernel.org, namhyung@...nel.org, acme@...nel.org,
	Andi Kleen <ak@...ux.intel.com>, brendan.d.gregg@...il.com
Subject: [PATCH 2/2] perf tools: apply -F filter to all previous events

From: Andi Kleen <ak@...ux.intel.com>

Right now you would need to duplicate the filter definition
for every trace point event. Instead apply it to each previous
one that did not have its own filter. If you have some tracepoint
events you don't want to give filter you can put them after the
last one.

Cc: brendan.d.gregg@...il.com
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
---
 tools/perf/util/parse-events.c | 48 +++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 9c4bab8..9bf4173 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -962,23 +962,12 @@ int parse_events_option(const struct option *opt, const char *str,
 	return ret;
 }
 
-int parse_filter(const struct option *opt, const char *str,
-		 int unset __maybe_unused)
+static char *gen_filter(const char *str)
 {
-	struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
-	struct perf_evsel *last = NULL;
 	char *pid, buf[30], *o;
 	int len, plen;
 	const char *p;
-
-	if (evlist->nr_entries > 0)
-		last = perf_evlist__last(evlist);
-
-	if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) {
-		fprintf(stderr,
-			"-F option should follow a -e tracepoint option\n");
-		return -1;
-	}
+	char *filter;
 
 	plen = sprintf(buf, "%d", getpid());
 	len = strlen(str) + 1;
@@ -987,13 +976,13 @@ int parse_filter(const struct option *opt, const char *str,
 		len += plen - 8;
 	}
 
-	last->filter = malloc(len);
-	if (last->filter == NULL) {
+	filter = malloc(len);
+	if (filter == NULL) {
 		fprintf(stderr, "not enough memory to hold filter string\n");
-		return -1;
+		return NULL;
 	}
 
-	o = last->filter;
+	o = filter;
 	for (p = str; *p; ) {
 		if (*p == 'P' && !strncmp(p, "PERF_PID", 8)) {
 			strcpy(o, buf);
@@ -1002,6 +991,31 @@ int parse_filter(const struct option *opt, const char *str,
 		} else
 			*o++ = *p++;
 	}
+	return filter;
+}
+
+int parse_filter(const struct option *opt, const char *str,
+		 int unset __maybe_unused)
+{
+	struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
+	struct perf_evsel *evsel;
+	int nr_tp = 0;
+
+	evlist__for_each(evlist, evsel) {
+		if (evsel->attr.type == PERF_TYPE_TRACEPOINT &&
+			!evsel->filter) {
+			evsel->filter = gen_filter(str);
+			if (!evsel->filter)
+				return -1;
+			nr_tp++;
+		}
+	}
+
+	if (nr_tp == 0) {
+		fprintf(stderr,
+			"-F option should follow a -e tracepoint option\n");
+		return -1;
+	}
 	return 0;
 }
 
-- 
1.9.3

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