linux-stable/tools/perf/util/bpf_skel
Jiri Olsa 760ebc4574 perf lock contention: Add empty 'struct rq' to satisfy libbpf 'runqueue' type verification
If 'struct rq' isn't defined in lock_contention.bpf.c then the type for
the 'runqueue' variable ends up being a forward declaration
(BTF_KIND_FWD) while the kernel has it defined (BTF_KIND_STRUCT).

This makes libbpf decide it has incompatible types and then fails to
load the BPF skeleton:

  # perf lock con -ab sleep 1
  libbpf: extern (var ksym) 'runqueues': incompatible types, expected [95] fwd rq, but kernel has [55509] struct rq
  libbpf: failed to load object 'lock_contention_bpf'
  libbpf: failed to load BPF skeleton 'lock_contention_bpf': -22
  Failed to load lock-contention BPF skeleton
  lock contention BPF setup failed
  #

Add it as an empty struct to satisfy that type verification:

  # perf lock con -ab sleep 1
   contended   total wait     max wait     avg wait         type   caller

           2     50.64 us     25.38 us     25.32 us     spinlock   tick_do_update_jiffies64+0x25
           1     26.18 us     26.18 us     26.18 us     spinlock   tick_do_update_jiffies64+0x25
  #

Committer notes:

Extracted from a larger patch as Namhyung had already fixed the other
issues in e53de7b65a ("perf lock contention: Fix struct rq lock
access").

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <song@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/lkml/ZFVqeKLssg7uzxzI@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-05-10 16:15:04 -03:00
..
.gitignore perf bpf skels: Stop using vmlinux.h generated from BTF, use subset of used structs + CO-RE 2023-05-05 19:18:39 -03:00
bperf_cgroup.bpf.c perf stat: Support old kernels for bperf cgroup counting 2022-10-14 10:29:05 -03:00
bperf_follower.bpf.c perf bpf_skel: Do not use typedef to avoid error on old clang 2021-12-06 21:57:53 -03:00
bperf_leader.bpf.c perf bpf_skel: Do not use typedef to avoid error on old clang 2021-12-06 21:57:53 -03:00
bperf_u.h perf stat: Introduce 'bperf' to share hardware PMCs with BPF 2021-03-23 17:46:44 -03:00
bpf_prog_profiler.bpf.c perf bpf: Fix building perf with BUILD_BPF_SKEL=1 by default in more distros 2021-12-06 21:57:53 -03:00
func_latency.bpf.c perf ftrace latency: Add -n/--use-nsec option 2022-03-22 17:43:46 -03:00
kwork_trace.bpf.c perf kwork: Add workqueue trace BPF support 2022-07-26 16:31:54 -03:00
lock_contention.bpf.c perf lock contention: Add empty 'struct rq' to satisfy libbpf 'runqueue' type verification 2023-05-10 16:15:04 -03:00
lock_data.h perf lock contention: Update default map size to 16384 2023-04-06 21:52:27 -03:00
off_cpu.bpf.c perf test: Fix offcpu test prev_state check 2023-02-19 07:58:23 -03:00
sample-filter.h perf bpf filter: Add logical OR operator 2023-03-15 11:08:36 -03:00
sample_filter.bpf.c perf bpf filter: Support pre-5.16 kernels where 'mem_hops' isn't in 'union perf_mem_data_src' 2023-04-10 18:57:17 -03:00
vmlinux.h perf bpf skels: Make vmlinux.h use bpf.h and perf_event.h in source directory 2023-05-10 14:20:49 -03:00