aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/loop3.c
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2019-06-15 12:12:24 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2019-06-19 02:22:52 +0200
commitb061017f8b4d0e05d4c11486581a702fb2a975b2 (patch)
tree8c8ba40095dc1d4aeb480c454df2abb683925d80 /tools/testing/selftests/bpf/progs/loop3.c
parentselftests/bpf: add basic verifier tests for loops (diff)
downloadlinux-dev-b061017f8b4d0e05d4c11486581a702fb2a975b2.tar.xz
linux-dev-b061017f8b4d0e05d4c11486581a702fb2a975b2.zip
selftests/bpf: add realistic loop tests
Add a bunch of loop tests. Most of them are created by replacing '#pragma unroll' with '#pragma clang loop unroll(disable)' Several tests are artificially large: /* partial unroll. llvm will unroll loop ~150 times. * C loop count -> 600. * Asm loop count -> 4. * 16k insns in loop body. * Total of 5 such loops. Total program size ~82k insns. */ "./pyperf600.o", /* no unroll at all. * C loop count -> 600. * ASM loop count -> 600. * ~110 insns in loop body. * Total of 5 such loops. Total program size ~1500 insns. */ "./pyperf600_nounroll.o", /* partial unroll. 19k insn in a loop. * Total program size 20.8k insn. * ~350k processed_insns */ "./strobemeta.o", Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/loop3.c')
-rw-r--r--tools/testing/selftests/bpf/progs/loop3.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/loop3.c b/tools/testing/selftests/bpf/progs/loop3.c
new file mode 100644
index 000000000000..30a0f6cba080
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/loop3.c
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019 Facebook
+#include <linux/sched.h>
+#include <linux/ptrace.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+#include <linux/bpf.h>
+#include "bpf_helpers.h"
+
+char _license[] SEC("license") = "GPL";
+
+SEC("raw_tracepoint/consume_skb")
+int while_true(volatile struct pt_regs* ctx)
+{
+ __u64 i = 0, sum = 0;
+ do {
+ i++;
+ sum += ctx->rax;
+ } while (i < 0x100000000ULL);
+ return sum;
+}