linux/tools
Namhyung Kim 76d3685400 perf stat: Constify control data for BPF
The control knobs set before loading BPF programs should be declared as
'const volatile' so that it can be optimized by the BPF core.

Committer testing:

  root@x1:~# perf stat --bpf-counters -e cpu_core/cycles/,cpu_core/instructions/ sleep 1

   Performance counter stats for 'sleep 1':

           2,442,583      cpu_core/cycles/
           2,494,425      cpu_core/instructions/

         1.002687372 seconds time elapsed

         0.001126000 seconds user
         0.001166000 seconds sys

  root@x1:~# perf trace -e bpf --max-events 10 perf stat --bpf-counters -e cpu_core/cycles/,cpu_core/instructions/ sleep 1
       0.000 ( 0.019 ms): perf/2944119 bpf(cmd: OBJ_GET, uattr: 0x7fffdf5cdd40, size: 20)            = 5
       0.021 ( 0.002 ms): perf/2944119 bpf(cmd: OBJ_GET_INFO_BY_FD, uattr: 0x7fffdf5cdcd0, size: 16) = 0
       0.030 ( 0.005 ms): perf/2944119 bpf(cmd: MAP_LOOKUP_ELEM, uattr: 0x7fffdf5ceda0, size: 32)    = 0
       0.037 ( 0.004 ms): perf/2944119 bpf(cmd: LINK_GET_FD_BY_ID, uattr: 0x7fffdf5ced80, size: 12)  = -1 ENOENT (No such file or directory)
       0.189 ( 0.004 ms): perf/2944119 bpf(cmd: 36, uattr: 0x7fffdf5cec10, size: 8)                  = -1 EOPNOTSUPP (Operation not supported)
       0.201 ( 0.095 ms): perf/2944119 bpf(cmd: PROG_LOAD, uattr: 0x7fffdf5ce940, size: 148)         = 10
       0.305 ( 0.026 ms): perf/2944119 bpf(cmd: PROG_LOAD, uattr: 0x7fffdf5cea00, size: 148)         = 10
       0.347 ( 0.012 ms): perf/2944119 bpf(cmd: BTF_LOAD, uattr: 0x7fffdf5ce8e0, size: 40)           = 10
       0.364 ( 0.004 ms): perf/2944119 bpf(cmd: BTF_LOAD, uattr: 0x7fffdf5ce950, size: 40)           = 10
       0.376 ( 0.006 ms): perf/2944119 bpf(cmd: BTF_LOAD, uattr: 0x7fffdf5ce730, size: 40)           = 10
  root@x1:~#
   Performance counter stats for 'sleep 1':

             271,221      cpu_core/cycles/
             139,150      cpu_core/instructions/

         1.002881677 seconds time elapsed

         0.001318000 seconds user
         0.001314000 seconds sys

  root@x1:~#

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240902200515.2103769-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-09-03 11:43:16 -03:00
..
accounting
arch tools/include: Sync arm64 headers with the kernel sources 2024-08-07 10:59:07 -07:00
bootconfig
bpf tools/resolve_btfids: Fix comparison of distinct pointer types warning in resolve_btfids 2024-07-22 16:35:30 +02:00
build perf report: Support LLVM for addr2line() 2024-09-03 10:15:16 -03:00
certs
cgroup
counter
crypto
debugging
firewire
firmware
gpio gpio: add sloppy logic analyzer using polling 2024-07-01 10:54:11 +02:00
hv tools: hv: suppress the invalid warning for packed member alignment 2024-05-28 05:27:35 +00:00
iio
include perf: cs-etm: Support version 0.1 of HW_ID packets 2024-08-29 15:56:13 -03:00
kvm/kvm_stat
laptop
leds
lib tools build: Correct bpf fixdep dependencies 2024-08-05 12:19:48 -03:00
memory-model kcsan: Add __data_racy documentation and module description 2024-07-15 15:44:40 -07:00
mm tools/mm: introduce a tool to assess swap entry allocation for thp_swapout 2024-07-10 12:14:51 -07:00
net/ynl tools: ynl: use ident name for Family, too. 2024-07-03 19:13:20 -07:00
objtool - 875fa64577da ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00
pci
pcmcia
perf perf stat: Constify control data for BPF 2024-09-03 11:43:16 -03:00
power turbostat release 2024.07.26 2024-07-28 10:52:15 -07:00
rcu tools/rcu: Add rcu-updaters.sh script 2024-06-06 11:44:42 -07:00
scripts
sound
spi
testing Including fixes from wireless and netfilter 2024-08-15 10:35:20 -07:00
thermal
time
tracing rtla/osnoise: Prevent NULL dereference in error handling 2024-08-09 13:03:15 -04:00
usb
verification tools/verification: Use pkg-config in lib_setup of Makefile.config 2024-07-17 13:14:51 -07:00
virtio tools/virtio: creating pipe assertion in vringh_test 2024-07-04 11:00:31 -04:00
wmi
workqueue
writeback
Makefile