Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Fix selftest btf_tag/btf_type_tag_percpu_vmlinux_helper failure

Ihor Solodrai reported selftest 'btf_tag/btf_type_tag_percpu_vmlinux_helper'
failure ([1]) during 6.16 merge window. The failure log:

...
7: (15) if r0 == 0x0 goto pc+1 ; R0=ptr_css_rstat_cpu()
; *(volatile int *)rstat; @ btf_type_tag_percpu.c:68
8: (61) r1 = *(u32 *)(r0 +0)
cannot access ptr member updated_children with moff 0 in struct css_rstat_cpu with off 0 size 4

Two changes are needed. First, 'struct cgroup_rstat_cpu' needs to be
replaced with 'struct css_rstat_cpu' to be consistent with new data
structure. Second, layout of 'css_rstat_cpu' is changed compared
to 'cgroup_rstat_cpu'. The first member becomes a pointer so
the bpf prog needs to do 8-byte load instead of 4-byte load.

[1] https://lore.kernel.org/bpf/6f688f2e-7d26-423a-9029-d1b1ef1c938a@linux.dev/

Cc: Ihor Solodrai <ihor.solodrai@linux.dev>
Cc: JP Kobryn <inwardvessel@gmail.com>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Acked-by: JP Kobryn <inwardvessel@gmail.com>
Link: https://lore.kernel.org/r/20250529201151.1787575-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Yonghong Song and committed by
Alexei Starovoitov
baa39c16 4b65d5ae

+3 -3
+3 -3
tools/testing/selftests/bpf/progs/btf_type_tag_percpu.c
··· 57 57 SEC("tp_btf/cgroup_mkdir") 58 58 int BPF_PROG(test_percpu_helper, struct cgroup *cgrp, const char *path) 59 59 { 60 - struct cgroup_rstat_cpu *rstat; 60 + struct css_rstat_cpu *rstat; 61 61 __u32 cpu; 62 62 63 63 cpu = bpf_get_smp_processor_id(); 64 - rstat = (struct cgroup_rstat_cpu *)bpf_per_cpu_ptr( 64 + rstat = (struct css_rstat_cpu *)bpf_per_cpu_ptr( 65 65 cgrp->self.rstat_cpu, cpu); 66 66 if (rstat) { 67 67 /* READ_ONCE */ 68 - *(volatile int *)rstat; 68 + *(volatile long *)rstat; 69 69 } 70 70 71 71 return 0;