From: Riccardo Mancini Date: Sat, 21 Aug 2021 09:19:29 +0000 (+0200) Subject: perf evsel: Move bpf_counter__install_pe() to success path in evsel__open_cpu() X-Git-Tag: howlett/maple/20220722_2~2377^2~17 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=91233d003b0906f146765fbef3572509c99d9386;p=users%2Fjedix%2Flinux-maple.git perf evsel: Move bpf_counter__install_pe() to success path in evsel__open_cpu() I don't see why bpf_counter__install_pe() should get called even if fd = -1, so I'm moving it to the success path. This will be useful in following patches to separate the actual open and the related operations from the fallback mechanisms. Signed-off-by: Riccardo Mancini Cc: Ian Rogers Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Link: http://lore.kernel.org/lkml/64f8a1b0a838a6e6049cd43c1beafd432999ae57.1629490974.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 8dc70dd045f3..a576d985a7a7 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2009,8 +2009,6 @@ retry_open: FD(evsel, cpu, thread) = fd; - bpf_counter__install_pe(evsel, cpu, fd); - if (fd < 0) { err = -errno; @@ -2019,6 +2017,8 @@ retry_open: goto try_fallback; } + bpf_counter__install_pe(evsel, cpu, fd); + if (unlikely(test_attr__enabled)) { test_attr__open(&evsel->core.attr, pid, cpus->map[cpu], fd, group_fd, evsel->open_flags);