~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 // Copyright (c) 2019 Facebook
  3 #include <test_progs.h>
  4 static int libbpf_debug_print(enum libbpf_print_level level,
  5                               const char *format, va_list args)
  6 {
  7         if (level != LIBBPF_DEBUG) {
  8                 vprintf(format, args);
  9                 return 0;
 10         }
 11 
 12         if (!strstr(format, "verifier log"))
 13                 return 0;
 14         vprintf("%s", args);
 15         return 0;
 16 }
 17 
 18 extern int extra_prog_load_log_flags;
 19 
 20 static int check_load(const char *file, enum bpf_prog_type type)
 21 {
 22         struct bpf_object *obj = NULL;
 23         struct bpf_program *prog;
 24         int err;
 25 
 26         obj = bpf_object__open_file(file, NULL);
 27         err = libbpf_get_error(obj);
 28         if (err)
 29                 return err;
 30 
 31         prog = bpf_object__next_program(obj, NULL);
 32         if (!prog) {
 33                 err = -ENOENT;
 34                 goto err_out;
 35         }
 36 
 37         bpf_program__set_type(prog, type);
 38         bpf_program__set_flags(prog, testing_prog_flags());
 39         bpf_program__set_log_level(prog, 4 | extra_prog_load_log_flags);
 40 
 41         err = bpf_object__load(obj);
 42 
 43 err_out:
 44         bpf_object__close(obj);
 45         return err;
 46 }
 47 
 48 static void scale_test(const char *file,
 49                        enum bpf_prog_type attach_type,
 50                        bool should_fail)
 51 {
 52         libbpf_print_fn_t old_print_fn = NULL;
 53         int err;
 54 
 55         if (env.verifier_stats) {
 56                 test__force_log();
 57                 old_print_fn = libbpf_set_print(libbpf_debug_print);
 58         }
 59 
 60         err = check_load(file, attach_type);
 61         if (should_fail)
 62                 ASSERT_ERR(err, "expect_error");
 63         else
 64                 ASSERT_OK(err, "expect_success");
 65 
 66         if (env.verifier_stats)
 67                 libbpf_set_print(old_print_fn);
 68 }
 69 
 70 void test_verif_scale1()
 71 {
 72         scale_test("test_verif_scale1.bpf.o", BPF_PROG_TYPE_SCHED_CLS, false);
 73 }
 74 
 75 void test_verif_scale2()
 76 {
 77         scale_test("test_verif_scale2.bpf.o", BPF_PROG_TYPE_SCHED_CLS, false);
 78 }
 79 
 80 void test_verif_scale3()
 81 {
 82         scale_test("test_verif_scale3.bpf.o", BPF_PROG_TYPE_SCHED_CLS, false);
 83 }
 84 
 85 void test_verif_scale_pyperf_global()
 86 {
 87         scale_test("pyperf_global.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
 88 }
 89 
 90 void test_verif_scale_pyperf_subprogs()
 91 {
 92         scale_test("pyperf_subprogs.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
 93 }
 94 
 95 void test_verif_scale_pyperf50()
 96 {
 97         /* full unroll by llvm */
 98         scale_test("pyperf50.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
 99 }
100 
101 void test_verif_scale_pyperf100()
102 {
103         /* full unroll by llvm */
104         scale_test("pyperf100.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
105 }
106 
107 void test_verif_scale_pyperf180()
108 {
109         /* full unroll by llvm */
110         scale_test("pyperf180.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
111 }
112 
113 void test_verif_scale_pyperf600()
114 {
115         /* partial unroll. llvm will unroll loop ~150 times.
116          * C loop count -> 600.
117          * Asm loop count -> 4.
118          * 16k insns in loop body.
119          * Total of 5 such loops. Total program size ~82k insns.
120          */
121         scale_test("pyperf600.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
122 }
123 
124 void test_verif_scale_pyperf600_bpf_loop(void)
125 {
126         /* use the bpf_loop helper*/
127         scale_test("pyperf600_bpf_loop.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
128 }
129 
130 void test_verif_scale_pyperf600_nounroll()
131 {
132         /* no unroll at all.
133          * C loop count -> 600.
134          * ASM loop count -> 600.
135          * ~110 insns in loop body.
136          * Total of 5 such loops. Total program size ~1500 insns.
137          */
138         scale_test("pyperf600_nounroll.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
139 }
140 
141 void test_verif_scale_pyperf600_iter()
142 {
143         /* open-coded BPF iterator version */
144         scale_test("pyperf600_iter.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
145 }
146 
147 void test_verif_scale_loop1()
148 {
149         scale_test("loop1.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
150 }
151 
152 void test_verif_scale_loop2()
153 {
154         scale_test("loop2.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
155 }
156 
157 void test_verif_scale_loop3_fail()
158 {
159         scale_test("loop3.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, true /* fails */);
160 }
161 
162 void test_verif_scale_loop4()
163 {
164         scale_test("loop4.bpf.o", BPF_PROG_TYPE_SCHED_CLS, false);
165 }
166 
167 void test_verif_scale_loop5()
168 {
169         scale_test("loop5.bpf.o", BPF_PROG_TYPE_SCHED_CLS, false);
170 }
171 
172 void test_verif_scale_loop6()
173 {
174         scale_test("loop6.bpf.o", BPF_PROG_TYPE_KPROBE, false);
175 }
176 
177 void test_verif_scale_strobemeta()
178 {
179         /* partial unroll. 19k insn in a loop.
180          * Total program size 20.8k insn.
181          * ~350k processed_insns
182          */
183         scale_test("strobemeta.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
184 }
185 
186 void test_verif_scale_strobemeta_bpf_loop(void)
187 {
188         /* use the bpf_loop helper*/
189         scale_test("strobemeta_bpf_loop.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
190 }
191 
192 void test_verif_scale_strobemeta_nounroll1()
193 {
194         /* no unroll, tiny loops */
195         scale_test("strobemeta_nounroll1.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
196 }
197 
198 void test_verif_scale_strobemeta_nounroll2()
199 {
200         /* no unroll, tiny loops */
201         scale_test("strobemeta_nounroll2.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
202 }
203 
204 void test_verif_scale_strobemeta_subprogs()
205 {
206         /* non-inlined subprogs */
207         scale_test("strobemeta_subprogs.bpf.o", BPF_PROG_TYPE_RAW_TRACEPOINT, false);
208 }
209 
210 void test_verif_scale_sysctl_loop1()
211 {
212         scale_test("test_sysctl_loop1.bpf.o", BPF_PROG_TYPE_CGROUP_SYSCTL, false);
213 }
214 
215 void test_verif_scale_sysctl_loop2()
216 {
217         scale_test("test_sysctl_loop2.bpf.o", BPF_PROG_TYPE_CGROUP_SYSCTL, false);
218 }
219 
220 void test_verif_scale_xdp_loop()
221 {
222         scale_test("test_xdp_loop.bpf.o", BPF_PROG_TYPE_XDP, false);
223 }
224 
225 void test_verif_scale_seg6_loop()
226 {
227         scale_test("test_seg6_loop.bpf.o", BPF_PROG_TYPE_LWT_SEG6LOCAL, false);
228 }
229 
230 void test_verif_twfw()
231 {
232         scale_test("twfw.bpf.o", BPF_PROG_TYPE_CGROUP_SKB, false);
233 }
234 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php