WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / loop1.c
blob50e66772c0467c67e18a91cddcb3f4b9745857ce
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
3 #include <linux/sched.h>
4 #include <linux/ptrace.h>
5 #include <stdint.h>
6 #include <stddef.h>
7 #include <stdbool.h>
8 #include <linux/bpf.h>
9 #include <bpf/bpf_helpers.h>
10 #include <bpf/bpf_tracing.h>
12 char _license[] SEC("license") = "GPL";
14 SEC("raw_tracepoint/kfree_skb")
15 int nested_loops(volatile struct pt_regs* ctx)
17 int i, j, sum = 0, m;
19 for (j = 0; j < 300; j++)
20 for (i = 0; i < j; i++) {
21 if (j & 1)
22 m = PT_REGS_RC(ctx);
23 else
24 m = j;
25 sum += i * m;
28 return sum;