mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-09 14:14:00 +08:00
selftests/bpf: convert bpf_verif_scale.c to sub-tests API
Expose each BPF verifier scale test as individual sub-test to allow independent results output and test selection. Test run results now look like this: $ sudo ./test_progs -t verif/ #3/1 loop3.o:OK #3/2 test_verif_scale1.o:OK #3/3 test_verif_scale2.o:OK #3/4 test_verif_scale3.o:OK #3/5 pyperf50.o:OK #3/6 pyperf100.o:OK #3/7 pyperf180.o:OK #3/8 pyperf600.o:OK #3/9 pyperf600_nounroll.o:OK #3/10 loop1.o:OK #3/11 loop2.o:OK #3/12 strobemeta.o:OK #3/13 strobemeta_nounroll1.o:OK #3/14 strobemeta_nounroll2.o:OK #3/15 test_sysctl_loop1.o:OK #3/16 test_sysctl_loop2.o:OK #3/17 test_xdp_loop.o:OK #3/18 test_seg6_loop.o:OK #3 bpf_verif_scale:OK Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
3a516a0a3a
commit
51436ed78d
@ -33,14 +33,25 @@ static int check_load(const char *file, enum bpf_prog_type type)
|
||||
return err;
|
||||
}
|
||||
|
||||
struct scale_test_def {
|
||||
const char *file;
|
||||
enum bpf_prog_type attach_type;
|
||||
bool fails;
|
||||
};
|
||||
|
||||
void test_bpf_verif_scale(void)
|
||||
{
|
||||
const char *sched_cls[] = {
|
||||
"./test_verif_scale1.o", "./test_verif_scale2.o", "./test_verif_scale3.o",
|
||||
};
|
||||
const char *raw_tp[] = {
|
||||
struct scale_test_def tests[] = {
|
||||
{ "loop3.o", BPF_PROG_TYPE_RAW_TRACEPOINT, true /* fails */ },
|
||||
|
||||
{ "test_verif_scale1.o", BPF_PROG_TYPE_SCHED_CLS },
|
||||
{ "test_verif_scale2.o", BPF_PROG_TYPE_SCHED_CLS },
|
||||
{ "test_verif_scale3.o", BPF_PROG_TYPE_SCHED_CLS },
|
||||
|
||||
/* full unroll by llvm */
|
||||
"./pyperf50.o", "./pyperf100.o", "./pyperf180.o",
|
||||
{ "pyperf50.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
{ "pyperf100.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
{ "pyperf180.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
|
||||
/* partial unroll. llvm will unroll loop ~150 times.
|
||||
* C loop count -> 600.
|
||||
@ -48,7 +59,7 @@ void test_bpf_verif_scale(void)
|
||||
* 16k insns in loop body.
|
||||
* Total of 5 such loops. Total program size ~82k insns.
|
||||
*/
|
||||
"./pyperf600.o",
|
||||
{ "pyperf600.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
|
||||
/* no unroll at all.
|
||||
* C loop count -> 600.
|
||||
@ -56,22 +67,26 @@ void test_bpf_verif_scale(void)
|
||||
* ~110 insns in loop body.
|
||||
* Total of 5 such loops. Total program size ~1500 insns.
|
||||
*/
|
||||
"./pyperf600_nounroll.o",
|
||||
{ "pyperf600_nounroll.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
|
||||
"./loop1.o", "./loop2.o",
|
||||
{ "loop1.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
{ "loop2.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
|
||||
/* partial unroll. 19k insn in a loop.
|
||||
* Total program size 20.8k insn.
|
||||
* ~350k processed_insns
|
||||
*/
|
||||
"./strobemeta.o",
|
||||
{ "strobemeta.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
|
||||
/* no unroll, tiny loops */
|
||||
"./strobemeta_nounroll1.o",
|
||||
"./strobemeta_nounroll2.o",
|
||||
};
|
||||
const char *cg_sysctl[] = {
|
||||
"./test_sysctl_loop1.o", "./test_sysctl_loop2.o",
|
||||
{ "strobemeta_nounroll1.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
{ "strobemeta_nounroll2.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
|
||||
|
||||
{ "test_sysctl_loop1.o", BPF_PROG_TYPE_CGROUP_SYSCTL },
|
||||
{ "test_sysctl_loop2.o", BPF_PROG_TYPE_CGROUP_SYSCTL },
|
||||
|
||||
{ "test_xdp_loop.o", BPF_PROG_TYPE_XDP },
|
||||
{ "test_seg6_loop.o", BPF_PROG_TYPE_LWT_SEG6LOCAL },
|
||||
};
|
||||
libbpf_print_fn_t old_print_fn = NULL;
|
||||
int err, i;
|
||||
@ -81,33 +96,21 @@ void test_bpf_verif_scale(void)
|
||||
old_print_fn = libbpf_set_print(libbpf_debug_print);
|
||||
}
|
||||
|
||||
err = check_load("./loop3.o", BPF_PROG_TYPE_RAW_TRACEPOINT);
|
||||
test__printf("test_scale:loop3:%s\n",
|
||||
err ? (error_cnt--, "OK") : "FAIL");
|
||||
for (i = 0; i < ARRAY_SIZE(tests); i++) {
|
||||
const struct scale_test_def *test = &tests[i];
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(sched_cls); i++) {
|
||||
err = check_load(sched_cls[i], BPF_PROG_TYPE_SCHED_CLS);
|
||||
test__printf("test_scale:%s:%s\n", sched_cls[i],
|
||||
err ? "FAIL" : "OK");
|
||||
if (!test__start_subtest(test->file))
|
||||
continue;
|
||||
|
||||
err = check_load(test->file, test->attach_type);
|
||||
if (test->fails) { /* expected to fail */
|
||||
if (err)
|
||||
error_cnt--;
|
||||
else
|
||||
error_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(raw_tp); i++) {
|
||||
err = check_load(raw_tp[i], BPF_PROG_TYPE_RAW_TRACEPOINT);
|
||||
test__printf("test_scale:%s:%s\n", raw_tp[i],
|
||||
err ? "FAIL" : "OK");
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cg_sysctl); i++) {
|
||||
err = check_load(cg_sysctl[i], BPF_PROG_TYPE_CGROUP_SYSCTL);
|
||||
test__printf("test_scale:%s:%s\n", cg_sysctl[i],
|
||||
err ? "FAIL" : "OK");
|
||||
}
|
||||
err = check_load("./test_xdp_loop.o", BPF_PROG_TYPE_XDP);
|
||||
test__printf("test_scale:test_xdp_loop:%s\n", err ? "FAIL" : "OK");
|
||||
|
||||
err = check_load("./test_seg6_loop.o", BPF_PROG_TYPE_LWT_SEG6LOCAL);
|
||||
test__printf("test_scale:test_seg6_loop:%s\n", err ? "FAIL" : "OK");
|
||||
|
||||
if (env.verifier_stats)
|
||||
libbpf_set_print(old_print_fn);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user