• Leo Yan's avatar
    perf trace: Exit when failing to build eBPF program · 012749ca
    Leo Yan authored
    On my Juno board with ARM64 CPUs, perf trace command reports the eBPF
    program building failure but the command will not exit and continue to
    run.  If we define an eBPF event in config file, the event will be
    parsed with below flow:
    
      perf_config()
        `> trace__config()
             `> parse_events_option()
                  `> parse_events__scanner()
                       `-> parse_events_parse()
                             `> parse_events_load_bpf()
                                  `> llvm__compile_bpf()
    
    Though the low level functions return back error values when detect eBPF
    building failure, but parse_events_option() returns 1 for this case and
    trace__config() passes 1 to perf_config(); perf_config() doesn't treat
    the returned value 1 as failure and it continues to parse other
    configurations.  Thus the perf command continues to run even without
    enabling eBPF event successfully.
    
    This patch changes error handling in trace__config(), when it detects
    failure it will return -1 rather than directly pass error value (1);
    finally, perf_config() will directly bail out and perf will exit for
    this case.
    
    Committer notes:
    
    Simplified the patch to just check directly the return of
    parse_events_option() and it it is non-zero, change err from its initial
    zero value to -1.
    Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
    Cc: Mike Leach <mike.leach@linaro.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
    Cc: Yonghong Song <yhs@fb.com>
    Fixes: ac96287c ("perf trace: Allow specifying a set of events to add in perfconfig")
    Link: https://lkml.kernel.org/n/tip-x4i63f5kscykfok0hqim3zma@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    012749ca
builtin-trace.c 115 KB