perf trace: Check if the raw_syscalls:sys_{enter,exit} are setup before setting tp...
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 19 Dec 2018 13:01:20 +0000 (10:01 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 21 Dec 2018 12:42:46 +0000 (09:42 -0300)
While updating 'perf trace' on an machine with an old precompiled
augmented_raw_syscalls.o that didn't setup the syscall map the new 'perf
trace' codebase notices the augmented_raw_syscalls.o eBPF event, decides
to use it instead of the old raw_syscalls:sys_{enter,exit} method, but
then because we don't have the syscall map tries to set the tracepoint
filter on the sys_{enter,exit} evsels, that are NULL, segfaulting.

Make the code more robust by checking it those tracepoints have
their respective evsels in place before trying to set the tp filter.

With this we still get everything to work, just not setting up the
syscall filters, which is better than a segfault. Now to update the
precompiled augmented_raw_syscalls.o and continue development :-)

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-3ft5rjdl05wgz2pwpx2z8btu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c

index ebde59e..6689c1a 100644 (file)
@@ -2686,7 +2686,9 @@ static int trace__set_ev_qualifier_filter(struct trace *trace)
 {
        if (trace->syscalls.map)
                return trace__set_ev_qualifier_bpf_filter(trace);
-       return trace__set_ev_qualifier_tp_filter(trace);
+       if (trace->syscalls.events.sys_enter)
+               return trace__set_ev_qualifier_tp_filter(trace);
+       return 0;
 }
 
 static int bpf_map__set_filter_pids(struct bpf_map *map __maybe_unused,