Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1530413 > unrolled thread

[PATCH] perf trace: Update tid/pid filtering option to leverage symbol_conf

Started byDavid Ahern <dsa@cumulusnetworks.com>
First post2016-11-25 17:40 +0100
Last post2016-12-02 11:40 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf trace: Update tid/pid filtering option to leverage symbol_conf David Ahern <dsa@cumulusnetworks.com> - 2016-11-25 17:40 +0100
    Re: [PATCH] perf trace: Update tid/pid filtering option to leverage  symbol_conf Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-11-25 20:10 +0100
    [tip:perf/core] perf trace: Update tid/pid filtering option to  leverage symbol_conf tip-bot for David Ahern <tipbot@zytor.com> - 2016-12-02 11:40 +0100

#1530413 — [PATCH] perf trace: Update tid/pid filtering option to leverage symbol_conf

FromDavid Ahern <dsa@cumulusnetworks.com>
Date2016-11-25 17:40 +0100
Subject[PATCH] perf trace: Update tid/pid filtering option to leverage symbol_conf
Message-ID<sHrHz-2XN-1@gated-at.bofh.it>
From: David Ahern <dsahern@gmail.com>

Leverage pid/tid filtering done by symbol_conf hooks.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 tools/perf/builtin-trace.c | 49 +++++++++-------------------------------------
 1 file changed, 9 insertions(+), 40 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 5f45166c892d..206bf72b77fc 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -74,8 +74,6 @@ struct trace {
 		size_t		nr;
 		int		*entries;
 	}			ev_qualifier_ids;
-	struct intlist		*tid_list;
-	struct intlist		*pid_list;
 	struct {
 		size_t		nr;
 		pid_t		*entries;
@@ -1890,18 +1888,6 @@ static int trace__pgfault(struct trace *trace,
 	return err;
 }
 
-static bool skip_sample(struct trace *trace, struct perf_sample *sample)
-{
-	if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) ||
-	    (trace->tid_list && intlist__find(trace->tid_list, sample->tid)))
-		return false;
-
-	if (trace->pid_list || trace->tid_list)
-		return true;
-
-	return false;
-}
-
 static void trace__set_base_time(struct trace *trace,
 				 struct perf_evsel *evsel,
 				 struct perf_sample *sample)
@@ -1926,11 +1912,13 @@ static int trace__process_sample(struct perf_tool *tool,
 				 struct machine *machine __maybe_unused)
 {
 	struct trace *trace = container_of(tool, struct trace, tool);
+	struct thread *thread;
 	int err = 0;
 
 	tracepoint_handler handler = evsel->handler;
 
-	if (skip_sample(trace, sample))
+	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
+	if (thread && thread__is_filtered(thread))
 		return 0;
 
 	trace__set_base_time(trace, evsel, sample);
@@ -1943,27 +1931,6 @@ static int trace__process_sample(struct perf_tool *tool,
 	return err;
 }
 
-static int parse_target_str(struct trace *trace)
-{
-	if (trace->opts.target.pid) {
-		trace->pid_list = intlist__new(trace->opts.target.pid);
-		if (trace->pid_list == NULL) {
-			pr_err("Error parsing process id string\n");
-			return -EINVAL;
-		}
-	}
-
-	if (trace->opts.target.tid) {
-		trace->tid_list = intlist__new(trace->opts.target.tid);
-		if (trace->tid_list == NULL) {
-			pr_err("Error parsing thread id string\n");
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-
 static int trace__record(struct trace *trace, int argc, const char **argv)
 {
 	unsigned int rec_argc, i, j;
@@ -2460,6 +2427,12 @@ static int trace__replay(struct trace *trace)
 	if (session == NULL)
 		return -1;
 
+	if (trace->opts.target.pid)
+		symbol_conf.pid_list_str = strdup(trace->opts.target.pid);
+
+	if (trace->opts.target.tid)
+		symbol_conf.tid_list_str = strdup(trace->opts.target.tid);
+
 	if (symbol__init(&session->header.env) < 0)
 		goto out;
 
@@ -2503,10 +2476,6 @@ static int trace__replay(struct trace *trace)
 			evsel->handler = trace__pgfault;
 	}
 
-	err = parse_target_str(trace);
-	if (err != 0)
-		goto out;
-
 	setup_pager();
 
 	err = perf_session__process_events(session);
-- 
2.7.4 (Apple Git-66)

[toc] | [next] | [standalone]


#1530494 — Re: [PATCH] perf trace: Update tid/pid filtering option to leverage symbol_conf

FromArnaldo Carvalho de Melo <acme@redhat.com>
Date2016-11-25 20:10 +0100
SubjectRe: [PATCH] perf trace: Update tid/pid filtering option to leverage symbol_conf
Message-ID<sHu2K-4ya-19@gated-at.bofh.it>
In reply to#1530413
Em Fri, Nov 25, 2016 at 09:29:52AM -0700, David Ahern escreveu:
> From: David Ahern <dsahern@gmail.com>
> 
> Leverage pid/tid filtering done by symbol_conf hooks.

Thanks, tested and applied.

- Arnaldo
 
> Signed-off-by: David Ahern <dsahern@gmail.com>
> ---
>  tools/perf/builtin-trace.c | 49 +++++++++-------------------------------------
>  1 file changed, 9 insertions(+), 40 deletions(-)
> 
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 5f45166c892d..206bf72b77fc 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -74,8 +74,6 @@ struct trace {
>  		size_t		nr;
>  		int		*entries;
>  	}			ev_qualifier_ids;
> -	struct intlist		*tid_list;
> -	struct intlist		*pid_list;
>  	struct {
>  		size_t		nr;
>  		pid_t		*entries;
> @@ -1890,18 +1888,6 @@ static int trace__pgfault(struct trace *trace,
>  	return err;
>  }
>  
> -static bool skip_sample(struct trace *trace, struct perf_sample *sample)
> -{
> -	if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) ||
> -	    (trace->tid_list && intlist__find(trace->tid_list, sample->tid)))
> -		return false;
> -
> -	if (trace->pid_list || trace->tid_list)
> -		return true;
> -
> -	return false;
> -}
> -
>  static void trace__set_base_time(struct trace *trace,
>  				 struct perf_evsel *evsel,
>  				 struct perf_sample *sample)
> @@ -1926,11 +1912,13 @@ static int trace__process_sample(struct perf_tool *tool,
>  				 struct machine *machine __maybe_unused)
>  {
>  	struct trace *trace = container_of(tool, struct trace, tool);
> +	struct thread *thread;
>  	int err = 0;
>  
>  	tracepoint_handler handler = evsel->handler;
>  
> -	if (skip_sample(trace, sample))
> +	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
> +	if (thread && thread__is_filtered(thread))
>  		return 0;
>  
>  	trace__set_base_time(trace, evsel, sample);
> @@ -1943,27 +1931,6 @@ static int trace__process_sample(struct perf_tool *tool,
>  	return err;
>  }
>  
> -static int parse_target_str(struct trace *trace)
> -{
> -	if (trace->opts.target.pid) {
> -		trace->pid_list = intlist__new(trace->opts.target.pid);
> -		if (trace->pid_list == NULL) {
> -			pr_err("Error parsing process id string\n");
> -			return -EINVAL;
> -		}
> -	}
> -
> -	if (trace->opts.target.tid) {
> -		trace->tid_list = intlist__new(trace->opts.target.tid);
> -		if (trace->tid_list == NULL) {
> -			pr_err("Error parsing thread id string\n");
> -			return -EINVAL;
> -		}
> -	}
> -
> -	return 0;
> -}
> -
>  static int trace__record(struct trace *trace, int argc, const char **argv)
>  {
>  	unsigned int rec_argc, i, j;
> @@ -2460,6 +2427,12 @@ static int trace__replay(struct trace *trace)
>  	if (session == NULL)
>  		return -1;
>  
> +	if (trace->opts.target.pid)
> +		symbol_conf.pid_list_str = strdup(trace->opts.target.pid);
> +
> +	if (trace->opts.target.tid)
> +		symbol_conf.tid_list_str = strdup(trace->opts.target.tid);
> +
>  	if (symbol__init(&session->header.env) < 0)
>  		goto out;
>  
> @@ -2503,10 +2476,6 @@ static int trace__replay(struct trace *trace)
>  			evsel->handler = trace__pgfault;
>  	}
>  
> -	err = parse_target_str(trace);
> -	if (err != 0)
> -		goto out;
> -
>  	setup_pager();
>  
>  	err = perf_session__process_events(session);
> -- 
> 2.7.4 (Apple Git-66)

[toc] | [prev] | [next] | [standalone]


#1534812 — [tip:perf/core] perf trace: Update tid/pid filtering option to leverage symbol_conf

Fromtip-bot for David Ahern <tipbot@zytor.com>
Date2016-12-02 11:40 +0100
Subject[tip:perf/core] perf trace: Update tid/pid filtering option to leverage symbol_conf
Message-ID<sJTq2-2EV-13@gated-at.bofh.it>
In reply to#1530413
Commit-ID:  aa07df6eb5061eed3f5d0820dc646d7f6ddface2
Gitweb:     http://git.kernel.org/tip/aa07df6eb5061eed3f5d0820dc646d7f6ddface2
Author:     David Ahern <dsahern@gmail.com>
AuthorDate: Fri, 25 Nov 2016 09:29:52 -0700
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 25 Nov 2016 16:04:22 -0300

perf trace: Update tid/pid filtering option to leverage symbol_conf

Leverage pid/tid filtering done by symbol_conf hooks.

Signed-off-by: David Ahern <dsahern@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: http://lkml.kernel.org/r/1480091392-35645-1-git-send-email-dsa@cumulusnetworks.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-trace.c | 49 +++++++++-------------------------------------
 1 file changed, 9 insertions(+), 40 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 5f45166..206bf72 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -74,8 +74,6 @@ struct trace {
 		size_t		nr;
 		int		*entries;
 	}			ev_qualifier_ids;
-	struct intlist		*tid_list;
-	struct intlist		*pid_list;
 	struct {
 		size_t		nr;
 		pid_t		*entries;
@@ -1890,18 +1888,6 @@ out_put:
 	return err;
 }
 
-static bool skip_sample(struct trace *trace, struct perf_sample *sample)
-{
-	if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) ||
-	    (trace->tid_list && intlist__find(trace->tid_list, sample->tid)))
-		return false;
-
-	if (trace->pid_list || trace->tid_list)
-		return true;
-
-	return false;
-}
-
 static void trace__set_base_time(struct trace *trace,
 				 struct perf_evsel *evsel,
 				 struct perf_sample *sample)
@@ -1926,11 +1912,13 @@ static int trace__process_sample(struct perf_tool *tool,
 				 struct machine *machine __maybe_unused)
 {
 	struct trace *trace = container_of(tool, struct trace, tool);
+	struct thread *thread;
 	int err = 0;
 
 	tracepoint_handler handler = evsel->handler;
 
-	if (skip_sample(trace, sample))
+	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
+	if (thread && thread__is_filtered(thread))
 		return 0;
 
 	trace__set_base_time(trace, evsel, sample);
@@ -1943,27 +1931,6 @@ static int trace__process_sample(struct perf_tool *tool,
 	return err;
 }
 
-static int parse_target_str(struct trace *trace)
-{
-	if (trace->opts.target.pid) {
-		trace->pid_list = intlist__new(trace->opts.target.pid);
-		if (trace->pid_list == NULL) {
-			pr_err("Error parsing process id string\n");
-			return -EINVAL;
-		}
-	}
-
-	if (trace->opts.target.tid) {
-		trace->tid_list = intlist__new(trace->opts.target.tid);
-		if (trace->tid_list == NULL) {
-			pr_err("Error parsing thread id string\n");
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-
 static int trace__record(struct trace *trace, int argc, const char **argv)
 {
 	unsigned int rec_argc, i, j;
@@ -2460,6 +2427,12 @@ static int trace__replay(struct trace *trace)
 	if (session == NULL)
 		return -1;
 
+	if (trace->opts.target.pid)
+		symbol_conf.pid_list_str = strdup(trace->opts.target.pid);
+
+	if (trace->opts.target.tid)
+		symbol_conf.tid_list_str = strdup(trace->opts.target.tid);
+
 	if (symbol__init(&session->header.env) < 0)
 		goto out;
 
@@ -2503,10 +2476,6 @@ static int trace__replay(struct trace *trace)
 			evsel->handler = trace__pgfault;
 	}
 
-	err = parse_target_str(trace);
-	if (err != 0)
-		goto out;
-
 	setup_pager();
 
 	err = perf_session__process_events(session);

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web