[PATCH bpf-next] bpf: Change value of MAX_TAIL_CALL_CNT from 32 to 33
Andrii Nakryiko
andrii.nakryiko at gmail.com
Wed Sep 8 22:50:24 PDT 2021
On Wed, Sep 8, 2021 at 8:33 PM Tiezhu Yang <yangtiezhu at loongson.cn> wrote:
>
> In the current code, the actual max tail call count is 33 which is greater
> than MAX_TAIL_CALL_CNT (defined as 32), the actual limit is not consistent
> with the meaning of MAX_TAIL_CALL_CNT, there is some confusion and need to
> spend some time to think the reason at the first glance.
think *about* the reason
>
> We can see the historical evolution from commit 04fd61ab36ec ("bpf: allow
> bpf programs to tail-call other bpf programs") and commit f9dabe016b63
> ("bpf: Undo off-by-one in interpreter tail call count limit").
>
> In order to avoid changing existing behavior, the actual limit is 33 now,
> this is resonable.
typo: reasonable
>
> After commit 874be05f525e ("bpf, tests: Add tail call test suite"), we can
> see there exists failed testcase.
>
> On all archs when CONFIG_BPF_JIT_ALWAYS_ON is not set:
> # echo 0 > /proc/sys/net/core/bpf_jit_enable
> # modprobe test_bpf
> # dmesg | grep -w FAIL
> Tail call error path, max count reached jited:0 ret 34 != 33 FAIL
>
> On some archs:
> # echo 1 > /proc/sys/net/core/bpf_jit_enable
> # modprobe test_bpf
> # dmesg | grep -w FAIL
> Tail call error path, max count reached jited:1 ret 34 != 33 FAIL
>
> So it is necessary to change the value of MAX_TAIL_CALL_CNT from 32 to 33,
> then do some small changes of the related code.
>
> With this patch, it does not change the current limit, MAX_TAIL_CALL_CNT
> can reflect the actual max tail call count, and the above failed testcase
> can be fixed.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu at loongson.cn>
> ---
This change breaks selftests ([0]), please fix them at the same time
as you are changing the kernel behavior:
test_tailcall_2:PASS:tailcall 128 nsec
test_tailcall_2:PASS:tailcall 128 nsec
test_tailcall_2:FAIL:tailcall err 0 errno 2 retval 4
#135/2 tailcalls/tailcall_2:FAIL
test_tailcall_3:PASS:tailcall 128 nsec
test_tailcall_3:FAIL:tailcall count err 0 errno 2 count 34
test_tailcall_3:PASS:tailcall 128 nsec
#135/3 tailcalls/tailcall_3:FAIL
#135/4 tailcalls/tailcall_4:OK
#135/5 tailcalls/tailcall_5:OK
#135/6 tailcalls/tailcall_bpf2bpf_1:OK
test_tailcall_bpf2bpf_2:PASS:tailcall 128 nsec
test_tailcall_bpf2bpf_2:FAIL:tailcall count err 0 errno 2 count 34
test_tailcall_bpf2bpf_2:PASS:tailcall 128 nsec
#135/7 tailcalls/tailcall_bpf2bpf_2:FAIL
#135/8 tailcalls/tailcall_bpf2bpf_3:OK
test_tailcall_bpf2bpf_4:PASS:tailcall 54 nsec
test_tailcall_bpf2bpf_4:FAIL:tailcall count err 0 errno 2 count 32
#135/9 tailcalls/tailcall_bpf2bpf_4:FAIL
test_tailcall_bpf2bpf_4:PASS:tailcall 54 nsec
test_tailcall_bpf2bpf_4:FAIL:tailcall count err 0 errno 2 count 32
#135/10 tailcalls/tailcall_bpf2bpf_5:FAIL
#135 tailcalls:FAIL
[0] https://github.com/kernel-patches/bpf/pull/1747/checks?check_run_id=3552002906
> arch/arm/net/bpf_jit_32.c | 11 ++++++-----
> arch/arm64/net/bpf_jit_comp.c | 7 ++++---
> arch/mips/net/ebpf_jit.c | 4 ++--
> arch/powerpc/net/bpf_jit_comp32.c | 4 ++--
> arch/powerpc/net/bpf_jit_comp64.c | 12 ++++++------
> arch/riscv/net/bpf_jit_comp32.c | 4 ++--
> arch/riscv/net/bpf_jit_comp64.c | 4 ++--
> arch/sparc/net/bpf_jit_comp_64.c | 8 ++++----
> include/linux/bpf.h | 2 +-
> kernel/bpf/core.c | 4 ++--
> 10 files changed, 31 insertions(+), 29 deletions(-)
>
[...]
More information about the linux-arm-kernel
mailing list