On Tue, Mar 5, 2024 at 11:57 PM Isaac Khor <contact@xxxxxxxxxxxxx> wrote: > > > Was it compiled with -O0 ? > > clang didn't even inline what was marked as __always_inline which is strange. > > Make sure to use the latest clang with -O2 -target bpf -g -mcpu=v3 > > You're right, the optimisations got disabled somewhere along the road when > I was debugging the problem. Re-tested with the compiler args you listed: > > libbpf: prog 'bpf_iden_max_ra': BPF program load failed: Permission denied > libbpf: prog 'bpf_iden_max_ra': -- BEGIN PROG LOAD LOG -- > 0: R1=ctx() R10=fp0 > ; int BPF_PROG(bpf_iden_max_ra, struct bpf_fs_readahead_state *s) @ readahead_noop.c:7 > 0: (79) r1 = *(u64 *)(r1 +0) ; R1_w=scalar() > ; return s->ra_pages; @ readahead_noop.c:9 > 1: (61) r0 = *(u32 *)(r1 +12) > R1 invalid mem access 'scalar' yeah. it should be ptr_to_btf_id. Check that your kernel has CONFIG_BPF_JIT and CONFIG_DEBUG_INFO_BTF=y CONFIG_PAHOLE_HAS_SPLIT_BTF=y CONFIG_PAHOLE_HAS_LANG_EXCLUDE=y CONFIG_DEBUG_INFO_BTF_MODULES=y CONFIG_PAHOLE_VERSION=125