Subject: Re: [bpf-next 0/6] bpf,powerpc: Add support for bpf arena and arena atomics

From: Saket Kumar Bhaskar <[email-masked]>
Date: Thu, 7 Aug 2025 18:47:16 +0530

On Tue, Aug 05, 2025 at 05:37:00PM +0530, Venkat Rao Bagalkote wrote:
> 
> On 05/08/25 11:57 am, Saket Kumar Bhaskar wrote:
> > This patch series introduces support for the PROBE_MEM32,
> > bpf_addr_space_cast and PROBE_ATOMIC instructions in the powerpc BPF JIT,
> > facilitating the implementation of BPF arena and arena atomics.
> > 
> > The last patch in the series has fix for arena spinlock selftest
> > failure.
> > 
> > This series is rebased on top of:
> > https://lore.kernel.org/bpf/[email-masked]/
> > 
> > All selftests related to bpf_arena, bpf_arena_atomic(except
> > load_acquire/store_release) enablement are passing:
> 
> 
> Hello Saket,
> 
> 
> I see couple of selftests are failing on my set up.
> 
> > 
> > # ./test_progs -t arena_list
> > #5/1     arena_list/arena_list_1:OK
> > #5/2     arena_list/arena_list_1000:OK
> > #5       arena_list:OK
> > Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
> > 
> > # ./test_progs -t arena_htab
> > #4/1     arena_htab/arena_htab_llvm:OK
> > #4/2     arena_htab/arena_htab_asm:OK
> > #4       arena_htab:OK
> > Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
> > 
> > # ./test_progs -t verifier_arena
> > #464/1   verifier_arena/basic_alloc1:OK
> > #464/2   verifier_arena/basic_alloc2:OK
> > #464/3   verifier_arena/basic_alloc3:OK
> > #464/4   verifier_arena/iter_maps1:OK
> > #464/5   verifier_arena/iter_maps2:OK
> > #464/6   verifier_arena/iter_maps3:OK
> > #464     verifier_arena:OK
> > #465/1   verifier_arena_large/big_alloc1:OK
> > #465/2   verifier_arena_large/big_alloc2:OK
> > #465     verifier_arena_large:OK
> > Summary: 2/8 PASSED, 0 SKIPPED, 0 FAILED
> 
> 
> All error logs:
> tester_init:PASS:tester_log_buf 0 nsec
> process_subtest:PASS:obj_open_mem 0 nsec
> process_subtest:PASS:specs_alloc 0 nsec
> run_subtest:PASS:obj_open_mem 0 nsec
> run_subtest:PASS:unexpected_load_failure 0 nsec
> do_prog_test_run:PASS:bpf_prog_test_run 0 nsec
> run_subtest:FAIL:1103 Unexpected retval: 4 != 0
> #513/7   verifier_arena/reserve_invalid_region:FAIL
> #513     verifier_arena:FAIL
> Summary: 1/14 PASSED, 0 SKIPPED, 1 FAILED
> 
> 
Hi Venkat,

It is known failure. This selftest was added recently. We are working on it to
fix this. Will post the fix for this selftest separately.
> > 
> > # ./test_progs -t arena_atomics
> > #3/1     arena_atomics/add:OK
> > #3/2     arena_atomics/sub:OK
> > #3/3     arena_atomics/and:OK
> > #3/4     arena_atomics/or:OK
> > #3/5     arena_atomics/xor:OK
> > #3/6     arena_atomics/cmpxchg:OK
> > #3/7     arena_atomics/xchg:OK
> > #3/8     arena_atomics/uaf:OK
> > #3/9     arena_atomics/load_acquire:SKIP
> > #3/10    arena_atomics/store_release:SKIP
> > #3       arena_atomics:OK (SKIP: 2/10)
> > Summary: 1/8 PASSED, 2 SKIPPED, 0 FAILED
> > 
> > All selftests related to arena_spin_lock are passing:
> > 
> > # ./test_progs -t arena_spin_lock
> > #6/1     arena_spin_lock/arena_spin_lock_1:OK
> > #6/2     arena_spin_lock/arena_spin_lock_1000:OK
> > #6/3     arena_spin_lock/arena_spin_lock_50000:OK
> > #6       arena_spin_lock:OK
> > Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED
> test_arena_spin_lock_size:FAIL:check counter value unexpected check counter
> value: actual 15999 != expected 16000
> #6/1     arena_spin_lock/arena_spin_lock_1:FAIL
> #6       arena_spin_lock:FAIL
> Summary: 0/2 PASSED, 0 SKIPPED, 1 FAILED

This too, with llvm-19 the failure is known to us, where llvm doesn't have support for
may_goto insn https://github.com/llvm/llvm-project/commit/0e0bfacff71859d1f9212205f8f873d47029d3fb.
Though, there is else condition which is envoked incase llvm doesn't have support for may_goto insn,
which we are looking into.

Since llvm-20 has support for may_goto, we are not seeing this failure there(the selftest passes).
So we are planning to fix this in separate patch for llvm-19 for now.

Regards,
Saket
> > Saket Kumar Bhaskar (6):
> >    bpf,powerpc: Introduce bpf_jit_emit_probe_mem_store() to emit store
> >      instructions
> >    bpf,powerpc: Implement PROBE_MEM32 pseudo instructions
> >    bpf,powerpc: Implement bpf_addr_space_cast instruction
> >    bpf,powerpc: Introduce bpf_jit_emit_atomic_ops() to emit atomic
> >      instructions
> >    bpf,powerpc: Implement PROBE_ATOMIC instructions
> >    selftests/bpf: Fix arena_spin_lock selftest failure
> > 
> >   arch/powerpc/net/bpf_jit.h                    |   6 +-
> >   arch/powerpc/net/bpf_jit_comp.c               |  32 +-
> >   arch/powerpc/net/bpf_jit_comp32.c             |   2 +-
> >   arch/powerpc/net/bpf_jit_comp64.c             | 378 +++++++++++++-----
> >   .../bpf/prog_tests/arena_spin_lock.c          |  23 +-
> >   .../selftests/bpf/progs/arena_spin_lock.c     |   8 +-
> >   .../selftests/bpf/progs/bpf_arena_spin_lock.h |   4 +-
> >   7 files changed, 348 insertions(+), 105 deletions(-)
> > 
> > base-commit: ea2aecdf7a954a8c0015e185cc870c4191d1d93f
> 
> 
> Regards,
> 
> Venkat.
>