Skip to content

Commit

Permalink
perf trace: Introduce filter_loop_pids()
Browse files Browse the repository at this point in the history
No change in functionality, just to make clearer that what we want when
filtering the tracer pid in a system wide tracing session is to avoid a
feedback loop.

This also paves the way for a more interesting loop avoidance algorithm,
one that tries to figure out if we are in a ssh session, xterm, etc.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-5fcttc5kdjkcyp9404ezkuy9@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jul 20, 2017
1 parent 15bed27 commit dd1a503
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,16 @@ static int trace__set_ev_qualifier_filter(struct trace *trace)
goto out;
}

static int trace__set_filter_loop_pids(struct trace *trace)
{
int nr = 1;
pid_t pids[32] = {
getpid(),
};

return perf_evlist__set_filter_pids(trace->evlist, nr, pids);
}

static int trace__run(struct trace *trace, int argc, const char **argv)
{
struct perf_evlist *evlist = trace->evlist;
Expand Down Expand Up @@ -2362,7 +2372,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
if (trace->filter_pids.nr > 0)
err = perf_evlist__set_filter_pids(evlist, trace->filter_pids.nr, trace->filter_pids.entries);
else if (thread_map__pid(evlist->threads, 0) == -1)
err = perf_evlist__set_filter_pid(evlist, getpid());
err = trace__set_filter_loop_pids(trace);

if (err < 0)
goto out_error_mem;
Expand Down

0 comments on commit dd1a503

Please sign in to comment.