Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2021 Facebook */
0003 
0004 #include "vmlinux.h"
0005 #include <bpf/bpf_helpers.h>
0006 #include "bpf_misc.h"
0007 
0008 char _license[] SEC("license") = "GPL";
0009 
0010 u32 nr_loops;
0011 long hits;
0012 
0013 static int empty_callback(__u32 index, void *data)
0014 {
0015     return 0;
0016 }
0017 
0018 SEC("fentry/" SYS_PREFIX "sys_getpgid")
0019 int benchmark(void *ctx)
0020 {
0021     for (int i = 0; i < 1000; i++) {
0022         bpf_loop(nr_loops, empty_callback, NULL, 0);
0023 
0024         __sync_add_and_fetch(&hits, nr_loops);
0025     }
0026     return 0;
0027 }