Skip to content

Commit

Permalink
perf trace: Filter out 'sshd' in the tracer ancestry in syswide tracing
Browse files Browse the repository at this point in the history
Avoiding a loop, so now its quite convenient to ssh to a machine and
then simply do:

	# perf trace

To trace all syscalls without causing a loop.

This was possible using --filter-pids, i.e. once you noticed the loop,
get the sshd pid and add it to --filter-pids, restarting the 'perf
trace'.

Now to figure out how to do that in a X terminal, the other common
scenario, which is way more involved, as there are multiple processes
communicating to process terminal activity...

Using --filter-pids + '-e \!syscall,names,you,dont,need' may be a good
approximation when having to do syswide tracing on your workstation.

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-68rjeao9wnpylla41htk7xps@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 dd1a503 commit 082ab9a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,10 +2241,24 @@ static int trace__set_ev_qualifier_filter(struct trace *trace)

static int trace__set_filter_loop_pids(struct trace *trace)
{
int nr = 1;
unsigned int nr = 1;
pid_t pids[32] = {
getpid(),
};
struct thread *thread = machine__find_thread(trace->host, pids[0], pids[0]);

while (thread && nr < ARRAY_SIZE(pids)) {
struct thread *parent = machine__find_thread(trace->host, thread->ppid, thread->ppid);

if (parent == NULL)
break;

if (!strcmp(thread__comm_str(parent), "sshd")) {
pids[nr++] = parent->tid;
break;
}
thread = parent;
}

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

0 comments on commit 082ab9a

Please sign in to comment.