Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 // Copyright (c) 2019 Facebook
0003 #include <linux/sched.h>
0004 #include <linux/ptrace.h>
0005 #include <stdint.h>
0006 #include <stddef.h>
0007 #include <stdbool.h>
0008 #include <linux/bpf.h>
0009 #include <bpf/bpf_helpers.h>
0010 #include <bpf/bpf_tracing.h>
0011 
0012 char _license[] SEC("license") = "GPL";
0013 
0014 SEC("raw_tracepoint/kfree_skb")
0015 int nested_loops(volatile struct pt_regs* ctx)
0016 {
0017     int i, j, sum = 0, m;
0018 
0019     for (j = 0; j < 300; j++)
0020         for (i = 0; i < j; i++) {
0021             if (j & 1)
0022                 m = PT_REGS_RC(ctx);
0023             else
0024                 m = j;
0025             sum += i * m;
0026         }
0027 
0028     return sum;
0029 }