public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [HELP] failed to resolve CO-RE relocation
@ 2023-04-27  0:14 Namhyung Kim
  2023-04-27  1:19 ` Andrii Nakryiko
  0 siblings, 1 reply; 10+ messages in thread
From: Namhyung Kim @ 2023-04-27  0:14 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Yonghong Song
  Cc: bpf, Song Liu, Jiri Olsa, Arnaldo Carvalho de Melo, Hao Luo,
	Ian Rogers

Hello,

I'm having a problem of loading perf lock contention BPF program [1]
on old kernels.  It has collect_lock_syms() to get the address of each
CPU's run-queue lock.  The kernel 5.14 changed the name of the field
so there's bpf_core_field_exists to check the name like below.

	if (bpf_core_field_exists(rq_new->__lock))
		lock_addr = (__u64)&rq_new->__lock;
	else
		lock_addr = (__u64)&rq_old->lock;

Note that I've applied a patch [2] to fix an issue with this code.

It works fine on my machine (with a newer kernel), but failed on the
old kernels.  I guess it'd go to the else part without a problem but
it didn't for some reason.

Then I change the code to check the rq_old first.  It works well on
the old kernels but fails on newer kernels.. :(

    libbpf: prog 'collect_lock_syms': BPF program load failed: Invalid argument
    libbpf: prog 'collect_lock_syms': -- BEGIN PROG LOAD LOG --
    reg type unsupported for arg#0 function collect_lock_syms#380
    0: R1=ctx(off=0,imm=0) R10=fp0
    ; int BPF_PROG(collect_lock_syms)
    0: (b7) r6 = 0                        ; R6_w=0
    1: (b7) r7 = 0                        ; R7_w=0
    2: (b7) r9 = 1                        ; R9_w=1
    3: <invalid CO-RE relocation>
    failed to resolve CO-RE relocation <byte_off> [381] struct rq___old.lock (0:0 @ offset 0)
    processed 4 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0

I'm curious what went wrong with this.  I guess it's supposed to work
on any kernel verions by definition.  Not sure the compiler generated
a wrong reloc or something.  Maybe I just made silly mistakes..

Do you see anything wrong?  Any hints to debug this issue?

Thanks,
Namhyung


[1] file://linux/tools/perf/util/bpf_skel/lock_contention.bpf.c
[2] https://lore.kernel.org/lkml/20230423215650.287812-1-namhyung@kernel.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-04-27 23:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-27  0:14 [HELP] failed to resolve CO-RE relocation Namhyung Kim
2023-04-27  1:19 ` Andrii Nakryiko
2023-04-27  2:21   ` Namhyung Kim
2023-04-27  4:19     ` Hengqi Chen
2023-04-27  4:27       ` Namhyung Kim
2023-04-27  4:26     ` Andrii Nakryiko
2023-04-27  4:53       ` Namhyung Kim
2023-04-27 22:15         ` Andrii Nakryiko
2023-04-27 23:27           ` Namhyung Kim
2023-04-27 23:38             ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox