linux-stable/tools/perf
Dmitrii Dolgov b13e20cc58 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 11:50:21 +02:00
..
arch perf intel-pt: pkt-decoder: Add CFE and EVD packets 2023-03-10 09:40:14 +01:00
bench parisc: Align parisc MADV_XXX constants with all other architectures 2023-01-14 10:23:27 +01:00
dlfilters
Documentation perf intel-pt: Do not try to queue auxtrace data on pipe 2023-03-10 09:39:33 +01:00
examples/bpf
include
jvmti
pmu-events perf vendor events power9: Remove UTF-8 characters from JSON files 2023-05-17 11:50:19 +02:00
python
scripts perf scripts intel-pt-events.py: Fix IPC output for Python 2 2023-05-17 11:50:19 +02:00
tests perf tests: Fix Track with sched_switch test for hybrid case 2022-08-25 11:40:16 +02:00
trace perf beauty: Cover more flags in the move_mount syscall argument beautifier 2021-09-10 18:15:22 -03:00
ui perf annotate: Avoid TUI crash when navigating in the annotation of recursive functions 2022-01-20 09:13:15 +01:00
util perf stat: Separate bperf from bpf_profiler 2023-05-17 11:50:21 +02:00
.gitignore perf tools: Add the include/perf/ directory to .gitignore 2022-11-16 09:58:20 +01:00
Build
builtin-annotate.c
builtin-bench.c
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c perf c2c: Fix sorting in percent_rmt_hitm_cmp() 2022-06-14 18:36:13 +02:00
builtin-config.c
builtin-daemon.c
builtin-data.c
builtin-diff.c
builtin-evlist.c
builtin-ftrace.c
builtin-help.c
builtin-inject.c perf inject: Fix --buildid-all not to eat up MMAP2 2023-03-17 08:48:47 +01:00
builtin-kallsyms.c
builtin-kmem.c
builtin-kvm.c
builtin-list.c
builtin-lock.c
builtin-mem.c
builtin-probe.c
builtin-record.c Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
builtin-report.c perf report: Set PERF_SAMPLE_DATA_SRC bit for Arm SPE event 2022-04-27 14:38:59 +02:00
builtin-sched.c
builtin-script.c perf script: Fix Cannot print 'iregs' field for hybrid systems 2022-09-15 11:30:06 +02:00
builtin-stat.c perf stat: Separate bperf from bpf_profiler 2023-05-17 11:50:21 +02:00
builtin-timechart.c
builtin-top.c
builtin-trace.c perf build: Properly guard libbpf includes 2023-01-18 11:48:56 +01:00
builtin-version.c
builtin.h
check-headers.sh perf report: Add tools/arch/x86/include/asm/amd-ibs.h 2021-09-10 18:13:20 -03:00
command-list.txt
CREDITS
design.txt
Makefile
Makefile.config tools perf: Fix compilation error with new binutils 2023-03-17 08:49:04 +01:00
Makefile.perf perf build: Suppress 'rm dlfilter' build message 2021-10-31 12:51:41 -03:00
MANIFEST
perf-archive.sh
perf-completion.sh perf tools: Fix auto-complete on aarch64 2023-03-10 09:39:33 +01:00
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf-with-kcore.sh
perf.c perf tools: Fix perf's libperf_print callback 2022-04-13 20:59:20 +02:00
perf.h