loop1.c (557B)
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> 11 12char _license[] SEC("license") = "GPL"; 13 14SEC("raw_tracepoint/kfree_skb") 15int nested_loops(volatile struct pt_regs* ctx) 16{ 17 int i, j, sum = 0, m; 18 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; 26 } 27 28 return sum; 29}