linux-stable/tools/perf
Dmitrii Dolgov e50996c159 perf stat: Separate bperf from bpf_profiler
[ Upstream commit ecc68ee216 ]

It seems that perf stat -b <prog id> doesn't produce any results:

    $ perf stat -e cycles -b 4 -I 10000 -vvv
    Control descriptor is not initialized
    cycles: 0 0 0
                time        counts unit      events
	10.007641640    <not supported>      cycles

Looks like this happens because fentry/fexit progs are getting loaded, but the
corresponding perf event is not enabled and not added into the events bpf map.
I think there is some mixing up between two type of bpf support, one for bperf
and one for bpf_profiler. Both are identified via evsel__is_bpf, based on which
perf events are enabled, but for the latter (bpf_profiler) a perf event is
required. Using evsel__is_bperf to check only bperf produces expected results:

    $ perf stat -e cycles -b 4 -I 10000 -vvv
    Control descriptor is not initialized
    ------------------------------------------------------------
    perf_event_attr:
      size                             136
      sample_type                      IDENTIFIER
      read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
      disabled                         1
      exclude_guest                    1
    ------------------------------------------------------------
    sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 3
    ------------------------------------------------------------
    [...perf_event_attr for other CPUs...]
    ------------------------------------------------------------
    cycles: 309426 169009 169009
		time             counts unit events
	10.010091271             309426      cycles

The final numbers correspond (at least in the level of magnitude) to the
same metric obtained via bpftool.

Fixes: 112cb56164 ("perf stat: Introduce config stat.bpf-counter-events")
Reviewed-by: Song Liu <song@kernel.org>
Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com>
Tested-by: Song Liu <song@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230412182316.11628-1-9erthalion6@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-17 13:58:54 +02:00
..
Documentation perf intel-pt: Do not try to queue auxtrace data on pipe 2023-03-10 09:28:44 +01:00
arch perf tools riscv: Fix build error on riscv due to missing header for 'struct perf_sample' 2023-01-02 11:47:22 -03:00
bench parisc architecture fixes for kernel v6.2-rc1: 2022-12-20 08:43:53 -06:00
dlfilters perf tools: Fix usage of the verbose variable 2022-12-20 15:16:33 -03:00
examples/bpf perf trace: Remove unused bpf map 'syscalls' 2022-11-23 10:30:00 -03:00
include/perf perf bpf: Remove now unused BPF headers 2022-11-04 11:41:48 -03:00
jvmti
pmu-events perf vendor events power9: Remove UTF-8 characters from JSON files 2023-05-17 13:58:52 +02:00
python
scripts perf script: Fix Python support when no libtraceevent 2023-05-17 13:58:52 +02:00
tests perf tests record_offcpu.sh: Fix redirection of stderr to stdin 2023-05-17 13:58:52 +02:00
trace perf beauty: Update copy of linux/socket.h with the kernel sources 2023-01-18 10:12:23 -03:00
ui perf tools: Fix "kernel lock contention analysis" test by not printing warnings in quiet mode 2022-10-27 16:37:26 -03:00
util perf stat: Separate bperf from bpf_profiler 2023-05-17 13:58:54 +02:00
.gitignore perf build: Install libsymbol locally when building 2022-11-16 12:17:15 -03:00
Build perf script: Fix Python support when no libtraceevent 2023-05-17 13:58:52 +02:00
CREDITS
MANIFEST tools lib traceevent: Remove libtraceevent 2022-12-14 11:16:12 -03:00
Makefile perf tools: Use "grep -E" instead of "egrep" 2022-12-14 15:28:19 -03:00
Makefile.config perf bpf: Avoid build breakage with libbpf < 0.8.0 + LIBBPF_DYNAMIC=1 2023-01-10 12:11:09 -03:00
Makefile.perf perf build: Support python/perf.so testing 2023-05-17 13:58:51 +02:00
builtin-annotate.c perf build: Use libtraceevent from the system 2022-12-14 11:16:12 -03:00
builtin-bench.c
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c perf tools: Use dedicated non-atomic clear/set bit helpers 2022-12-05 09:29:06 -03:00
builtin-config.c
builtin-daemon.c perf daemon: Use sig_atomic_t to avoid UB 2022-11-03 09:35:44 -03:00
builtin-data.c perf build: Use libtraceevent from the system 2022-12-14 11:16:12 -03:00
builtin-diff.c perf tools: Make quiet mode consistent between tools 2022-10-27 16:37:26 -03:00
builtin-evlist.c
builtin-ftrace.c perf ftrace: Make system wide the default target for latency subcommand 2023-05-17 13:58:52 +02:00
builtin-help.c
builtin-inject.c perf inject: Fix --buildid-all not to eat up MMAP2 2023-03-17 08:57:46 +01:00
builtin-kallsyms.c
builtin-kmem.c perf kmem: Support field "node" in evsel__process_alloc_event() coping with recent tracepoint restructuring 2023-01-10 10:52:49 -03:00
builtin-kvm.c perf build: Use libtraceevent from the system 2022-12-14 11:16:12 -03:00
builtin-kwork.c perf build: Use libtraceevent from the system 2022-12-14 11:16:12 -03:00
builtin-list.c perf list: JSON escape encoding improvements 2022-11-24 10:03:03 -03:00
builtin-lock.c perf lock contention: Fix core dump related to not finding the "__sched_text_end" symbol on s/390 2023-01-03 15:48:23 -03:00
builtin-mem.c perf tools: Move 'struct perf_sample' to a separate header file to disentangle headers 2022-10-31 11:06:41 -03:00
builtin-probe.c perf probe: Check -v and -q options in the right place 2022-12-20 15:16:33 -03:00
builtin-record.c perf record: Fix "read LOST count failed" msg with sample read 2023-05-17 13:58:51 +02:00
builtin-report.c perf build: Use libtraceevent from the system 2022-12-14 11:16:12 -03:00
builtin-sched.c perf tools: Use dedicated non-atomic clear/set bit helpers 2022-12-05 09:29:06 -03:00
builtin-script.c perf script: Fix Python support when no libtraceevent 2023-05-17 13:58:52 +02:00
builtin-stat.c perf stat: Separate bperf from bpf_profiler 2023-05-17 13:58:54 +02:00
builtin-timechart.c perf build: Use libtraceevent from the system 2022-12-14 11:16:12 -03:00
builtin-top.c perf evlist: Remove group option. 2022-12-14 15:28:18 -03:00
builtin-trace.c perf build: Properly guard libbpf includes 2023-01-10 10:51:39 -03:00
builtin-version.c perf build: Use libtraceevent from the system 2022-12-14 11:16:12 -03:00
builtin.h
check-headers.sh tools headers: Update the copy of x86's memcpy_64.S used in 'perf bench' 2022-10-25 17:40:48 -03:00
command-list.txt perf help: Use HAVE_LIBTRACEEVENT to filter out unsupported commands 2023-01-02 11:51:53 -03:00
design.txt
perf-archive.sh
perf-completion.sh perf tools: Fix auto-complete on aarch64 2023-03-10 09:28:44 +01:00
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c perf build: Use libtraceevent from the system 2022-12-14 11:16:12 -03:00
perf.h