Commit 51436ed7 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

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: default avatarAndrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 3a516a0a
...@@ -33,14 +33,25 @@ static int check_load(const char *file, enum bpf_prog_type type) ...@@ -33,14 +33,25 @@ static int check_load(const char *file, enum bpf_prog_type type)
return err; return err;
} }
struct scale_test_def {
const char *file;
enum bpf_prog_type attach_type;
bool fails;
};
void test_bpf_verif_scale(void) void test_bpf_verif_scale(void)
{ {
const char *sched_cls[] = { struct scale_test_def tests[] = {
"./test_verif_scale1.o", "./test_verif_scale2.o", "./test_verif_scale3.o", { "loop3.o", BPF_PROG_TYPE_RAW_TRACEPOINT, true /* fails */ },
};
const char *raw_tp[] = { { "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 */ /* 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. /* partial unroll. llvm will unroll loop ~150 times.
* C loop count -> 600. * C loop count -> 600.
...@@ -48,7 +59,7 @@ void test_bpf_verif_scale(void) ...@@ -48,7 +59,7 @@ void test_bpf_verif_scale(void)
* 16k insns in loop body. * 16k insns in loop body.
* Total of 5 such loops. Total program size ~82k insns. * Total of 5 such loops. Total program size ~82k insns.
*/ */
"./pyperf600.o", { "pyperf600.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
/* no unroll at all. /* no unroll at all.
* C loop count -> 600. * C loop count -> 600.
...@@ -56,22 +67,26 @@ void test_bpf_verif_scale(void) ...@@ -56,22 +67,26 @@ void test_bpf_verif_scale(void)
* ~110 insns in loop body. * ~110 insns in loop body.
* Total of 5 such loops. Total program size ~1500 insns. * 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. /* partial unroll. 19k insn in a loop.
* Total program size 20.8k insn. * Total program size 20.8k insn.
* ~350k processed_insns * ~350k processed_insns
*/ */
"./strobemeta.o", { "strobemeta.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
/* no unroll, tiny loops */ /* no unroll, tiny loops */
"./strobemeta_nounroll1.o", { "strobemeta_nounroll1.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
"./strobemeta_nounroll2.o", { "strobemeta_nounroll2.o", BPF_PROG_TYPE_RAW_TRACEPOINT },
};
const char *cg_sysctl[] = { { "test_sysctl_loop1.o", BPF_PROG_TYPE_CGROUP_SYSCTL },
"./test_sysctl_loop1.o", "./test_sysctl_loop2.o", { "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; libbpf_print_fn_t old_print_fn = NULL;
int err, i; int err, i;
...@@ -81,32 +96,20 @@ void test_bpf_verif_scale(void) ...@@ -81,32 +96,20 @@ void test_bpf_verif_scale(void)
old_print_fn = libbpf_set_print(libbpf_debug_print); old_print_fn = libbpf_set_print(libbpf_debug_print);
} }
err = check_load("./loop3.o", BPF_PROG_TYPE_RAW_TRACEPOINT); for (i = 0; i < ARRAY_SIZE(tests); i++) {
test__printf("test_scale:loop3:%s\n", const struct scale_test_def *test = &tests[i];
err ? (error_cnt--, "OK") : "FAIL");
for (i = 0; i < ARRAY_SIZE(sched_cls); i++) { if (!test__start_subtest(test->file))
err = check_load(sched_cls[i], BPF_PROG_TYPE_SCHED_CLS); continue;
test__printf("test_scale:%s:%s\n", sched_cls[i],
err ? "FAIL" : "OK");
}
for (i = 0; i < ARRAY_SIZE(raw_tp); i++) { err = check_load(test->file, test->attach_type);
err = check_load(raw_tp[i], BPF_PROG_TYPE_RAW_TRACEPOINT); if (test->fails) { /* expected to fail */
test__printf("test_scale:%s:%s\n", raw_tp[i], if (err)
err ? "FAIL" : "OK"); error_cnt--;
else
error_cnt++;
} }
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) if (env.verifier_stats)
libbpf_set_print(old_print_fn); libbpf_set_print(old_print_fn);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment