BPF arena atomic example not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks,

I have not found BPF arena documentation, beyond the patches and selftests.
I'm using the arena_atomics selftest as reference to create a simple BPF program
that increments a value atomically.

bpf: https://github.com/jfernandez/bpf-playground/blob/main/arena.bpf.c
userspace: https://github.com/jfernandez/bpf-playground/blob/main/arena.c
common header: https://github.com/jfernandez/bpf-playground/blob/main/bpf_arena_common.h

I'm using the 6.10.2 kernel and libbpf 1.4.3.

The program does not load when I use the `__arena_global` macro. If fails with:

libbpf: map 'arena': at sec_idx 7, offset 0.
libbpf: map 'arena': found type = 33.
libbpf: map 'arena': found max_entries = 10.
libbpf: map 'arena': found map_flags = 0x400.
libbpf: map 'arena': found map_extra = 0x100000000000.
libbpf: sec '.relraw_tp/sys_enter': collecting relocation for section(3) 'raw_tp/sys_enter'
libbpf: sec '.relraw_tp/sys_enter': relo #0: insn #1 against 'add64_value'
libbpf: sec '.relraw_tp/sys_enter': relo #1: insn #4 against 'add64_result'
libbpf: object 'arena': failed (-95) to create BPF token from '/sys/fs/bpf', skipping optional step...
libbpf: map 'arena': created successfully, fd=3
libbpf: prog 'add': BPF program load failed: Permission denied
libbpf: prog 'add': -- BEGIN PROG LOAD LOG --
arg#0 reference type('UNKNOWN ') size cannot be determined: -22
0: R1=ctx() R10=fp0
; int add(const void *ctx) @ arena.bpf.c:17
0: (b7) r1 = 2                        ; R1_w=2
; add64_result = __sync_fetch_and_add(&add64_value, 2); @ arena.bpf.c:19
1: (18) r2 = 0x100000000000           ; R2_w=scalar()
3: (db) r1 = atomic64_fetch_add((u64 *)(r2 +0), r1)
misaligned access off (0x0; 0xffffffffffffffff)+0+0 size 8
processed 3 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
-- END PROG LOAD LOG --
libbpf: prog 'add': failed to load: -13
libbpf: failed to load object 'arena'
libbpf: failed to load BPF skeleton 'arena': -13
Failed to open BPF skeleton

I found Yonghong Song's patch that appears to address a similar issue. But I'm
using a return value and not getting the `lock` instruction:
https://lore.kernel.org/bpf/20240803025928.4184433-1-yonghong.song@xxxxxxxxx/

I have compared with code with the selftest and I can't spot any signifcant
differences that may cause this issue. I would appreciate any help or guidance.

Thanks,
Jose




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux