selftests/bpf: trampoline_count: use dedicated target function
Subsystems (5)
PATCH 1/1 selftests/bpf: trampoline_count: use dedicated target function
trampoline_count fills all trampoline attachment slots for a single target function and verifies that one extra attach fails with -E2BIG.
It currently targets bpf_modify_return_test, which is also used by modify_return and get_func_ip_test. When those tests run in parallel, they can contend for the same per-function trampoline quota and cause unexpected attach failures. This issue is currently masked by harness serialization.
Add a dedicated bpf_trampoline_count_test target and switch trampoline_count to use it. This keeps the test semantics unchanged while isolating it from other modify_return-based selftests, so it no longer needs to run in serial mode. Remove the TODO comment as well.
Tested:
./test_progs -t trampoline_count -vv ./test_progs -t modify_return -vv ./test_progs -t get_func_ip_test -vv ./test_progs -j$(nproc) -t trampoline_count -vv ./test_progs -j$(nproc) -t
trampoline_count,modify_return,get_func_ip_test -vv
--- net/bpf/test_run.c | 7 +++++++ tools/testing/selftests/bpf/prog_tests/trampoline_count.c | 3 +-- tools/testing/selftests/bpf/progs/test_trampoline_count.c | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-)
net/bpf/test_run.c +7 -0
@@ -580,6 +580,12 @@ __bpf_kfunc int bpf_modify_return_test2(int a, int *b, short c, int d,return a + *b + c + d + (long )e + f + g; } +__bpf_kfunc int bpf_trampoline_count_test(int a, int *b) +{ + *b +=1 ; +return a + *b; +} + __bpf_kfunc int bpf_modify_return_test_tp(int nonce) {trace_bpf_trigger_tp (nonce);
@@ -635,6 +641,7 @@ BTF_KFUNCS_START(bpf_test_modify_return_ids) BTF_ID_FLAGS(func, bpf_modify_return_test) BTF_ID_FLAGS(func, bpf_modify_return_test2) BTF_ID_FLAGS(func, bpf_modify_return_test_tp) +BTF_ID_FLAGS(func, bpf_trampoline_count_test) BTF_ID_FLAGS(func, bpf_fentry_test1, KF_SLEEPABLE)BTF_KFUNCS_END (bpf_test_modify_return_ids)
tools/testing/selftests/bpf/prog_tests/trampoline_count.c +1 -2
@@ -30,8 +30,7 @@ static struct bpf_program *load_prog(char *file, char *name, struct inst *inst)return prog; } -/* TODO: use different target function to run in concurrent mode */ -void serial_test_trampoline_count (void ) +void test_trampoline_count (void ) {char *file ="test_trampoline_count.bpf.o" ;char *const progs[] = {"fentry_test" ,"fmod_ret_test" ,"fexit_test" };
tools/testing/selftests/bpf/progs/test_trampoline_count.c +3 -3
@@ -3,19 +3,19 @@#include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> -SEC("fentry/bpf_modify_return_test") +SEC("fentry/bpf_trampoline_count_test")int BPF_PROG (fentry_test ,int a,int *b) {return 0 ; } -SEC("fmod_ret/bpf_modify_return_test") +SEC("fmod_ret/bpf_trampoline_count_test")int BPF_PROG (fmod_ret_test ,int a,int *b,int ret) {return 0 ; } -SEC("fexit/bpf_modify_return_test") +SEC("fexit/bpf_trampoline_count_test")int BPF_PROG (fexit_test ,int a,int *b,int ret) {return 0 ;
base-commit: 267594792a71018788af69e836c52e34bb8054af
Signature · 1 line
2.43.0
Quoted 15 lines · Sun Jian
trampoline_countfills all trampoline attachment slots for a single target function and verifies that one extra attach fails with-E2BIG.It currently targets
bpf_modify_return_test, which is also used bymodify_returnandget_func_ip_test. When those tests run in parallel, they can contend for the same per-function trampoline quota and cause unexpected attach failures. This issue is currently masked by harness serialization.Add a dedicated
bpf_trampoline_count_testtarget and switchtrampoline_countto use it. This keeps the test semantics unchanged while isolating it from other modify_return-based selftests, so it no longer needs to run in serial mode. Remove the TODO comment as well.
Quoted 7 lines
Tested:
./test_progs -ttrampoline_count-vv ./test_progs -tmodify_return-vv ./test_progs -tget_func_ip_test-vv ./test_progs -j$(nproc) -ttrampoline_count-vv ./test_progs -j$(nproc) -t
trampoline_count,modify_return,get_func_ip_test -vv
I was able to reproduce the issue here then validate the fix. I however had to include several more tests that use bpf_modify_return_test (get_func_args_test, kprobe_multi_test, missed, and bpf_cookie) before I could reliably reproduce (in a loop that runs until it fails with an unexpected E2BIG).
[...]
PATCH v2 1/1 selftests/bpf: trampoline_count: use dedicated target function
In reply to Sun Jiantrampoline_count fills all trampoline attachment slots for a single target function and verifies that one extra attach fails with -E2BIG.
It currently targets bpf_modify_return_test, which is also used by modify_return and get_func_ip_test. When those tests run in parallel, they can contend for the same per-function trampoline quota and cause unexpected attach failures. This issue is currently masked by harness serialization.
Add a dedicated bpf_trampoline_count_test target and switch trampoline_count to use it. This keeps the test semantics unchanged while isolating it from other modify_return-based selftests, so it no longer needs to run in serial mode. Remove the TODO comment as well.
Tested:
./test_progs -t trampoline_count -vv ./test_progs -t modify_return -vv ./test_progs -t get_func_ip_test -vv ./test_progs -j$(nproc) -t trampoline_count -vv ./test_progs -j$(nproc) -t
trampoline_count,modify_return,get_func_ip_test -vv
---
v2:
- add Paul's Tested-by
net/bpf/test_run.c | 7 +++++++ tools/testing/selftests/bpf/prog_tests/trampoline_count.c | 3 +-- tools/testing/selftests/bpf/progs/test_trampoline_count.c | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-)
net/bpf/test_run.c +7 -0
@@ -580,6 +580,12 @@ __bpf_kfunc int bpf_modify_return_test2(int a, int *b, short c, int d,return a + *b + c + d + (long )e + f + g; } +__bpf_kfunc int bpf_trampoline_count_test(int a, int *b) +{ + *b +=1 ; +return a + *b; +} + __bpf_kfunc int bpf_modify_return_test_tp(int nonce) {trace_bpf_trigger_tp (nonce);
@@ -635,6 +641,7 @@ BTF_KFUNCS_START(bpf_test_modify_return_ids) BTF_ID_FLAGS(func, bpf_modify_return_test) BTF_ID_FLAGS(func, bpf_modify_return_test2) BTF_ID_FLAGS(func, bpf_modify_return_test_tp) +BTF_ID_FLAGS(func, bpf_trampoline_count_test) BTF_ID_FLAGS(func, bpf_fentry_test1, KF_SLEEPABLE)BTF_KFUNCS_END (bpf_test_modify_return_ids)
tools/testing/selftests/bpf/prog_tests/trampoline_count.c +1 -2
@@ -30,8 +30,7 @@ static struct bpf_program *load_prog(char *file, char *name, struct inst *inst)return prog; } -/* TODO: use different target function to run in concurrent mode */ -void serial_test_trampoline_count (void ) +void test_trampoline_count (void ) {char *file ="test_trampoline_count.bpf.o" ;char *const progs[] = {"fentry_test" ,"fmod_ret_test" ,"fexit_test" };
tools/testing/selftests/bpf/progs/test_trampoline_count.c +3 -3
@@ -3,19 +3,19 @@#include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> -SEC("fentry/bpf_modify_return_test") +SEC("fentry/bpf_trampoline_count_test")int BPF_PROG (fentry_test ,int a,int *b) {return 0 ; } -SEC("fmod_ret/bpf_modify_return_test") +SEC("fmod_ret/bpf_trampoline_count_test")int BPF_PROG (fmod_ret_test ,int a,int *b,int ret) {return 0 ; } -SEC("fexit/bpf_modify_return_test") +SEC("fexit/bpf_trampoline_count_test")int BPF_PROG (fexit_test ,int a,int *b,int ret) {return 0 ;
base-commit: 267594792a71018788af69e836c52e34bb8054af
Signature · 1 line
2.43.0
Quoted 23 lines · Sun Jian
trampoline_countfills all trampoline attachment slots for a single target function and verifies that one extra attach fails with-E2BIG.It currently targets
bpf_modify_return_test, which is also used bymodify_returnandget_func_ip_test. When those tests run in parallel, they can contend for the same per-function trampoline quota and cause unexpected attach failures. This issue is currently masked by harness serialization.Add a dedicated
bpf_trampoline_count_testtarget and switchtrampoline_countto use it. This keeps the test semantics unchanged while isolating it from other modify_return-based selftests, so it no longer needs to run in serial mode. Remove the TODO comment as well.Tested:
./test_progs -ttrampoline_count-vv ./test_progs -tmodify_return-vv ./test_progs -tget_func_ip_test-vv ./test_progs -j$(nproc) -ttrampoline_count-vv ./test_progs -j$(nproc) -t
trampoline_count,modify_return,get_func_ip_test -vv
Quoted 6 lines
Tested-by Paul Chaignon <[email protected]>Signed-off-by Sun Jian <[email protected]>---
v2:
- add Paul's Tested-by
FYI, in general, unless there are merge conflicts, you don't need to resend just for the tags. Maintainers can apply those when they merge.
[...]
Quoted 36 lines · Sun Jian
trampoline_countfills all trampoline attachment slots for a single target function and verifies that one extra attach fails with-E2BIG.It currently targets
bpf_modify_return_test, which is also used bymodify_returnandget_func_ip_test. When those tests run in parallel, they can contend for the same per-function trampoline quota and cause unexpected attach failures. This issue is currently masked by harness serialization.Add a dedicated
bpf_trampoline_count_testtarget and switchtrampoline_countto use it. This keeps the test semantics unchanged while isolating it from other modify_return-based selftests, so it no longer needs to run in serial mode. Remove the TODO comment as well.Tested:
./test_progs -ttrampoline_count-vv ./test_progs -tmodify_return-vv ./test_progs -tget_func_ip_test-vv ./test_progs -j$(nproc) -ttrampoline_count-vv ./test_progs -j$(nproc) -t
trampoline_count,modify_return,get_func_ip_test -vvSigned-off-by Sun Jian <[email protected]>--- net/bpf/test_run.c | 7 +++++++ tools/testing/selftests/bpf/prog_tests/trampoline_count.c | 3 +-- tools/testing/selftests/bpf/progs/test_trampoline_count.c | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-)net/bpf/test_run.c +0
-0
net/bpf/test_run.c __bpf_kfunc int bpf_modify_return_test2(int a, int *b, short c, int d, · line 587
Quoted 8 lines
net/bpf/test_run.c +5
-0@@ -580,6 +580,12 @@ __bpf_kfunc int bpf_modify_return_test2(int a, int *b, short c, int d,return a + *b + c + d + (long )e + f + g; } +__bpf_kfunc int bpf_trampoline_count_test(int a, int *b) +{ + *b +=1 ; +return a + *b; +}
No. We're not adding test code to the kernel anymore. That's what test_kmod is for.
pw-bot: cr