Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2/* Copyright (c) 2021 Facebook */
 3
 4#include "vmlinux.h"
 5#include <bpf/bpf_helpers.h>
 6#include "bpf_misc.h"
 7
 8char _license[] SEC("license") = "GPL";
 9
10u32 nr_loops;
11long hits;
12
13static int empty_callback(__u32 index, void *data)
14{
15	return 0;
16}
17
18static int outer_loop(__u32 index, void *data)
19{
20	bpf_loop(nr_loops, empty_callback, NULL, 0);
21	__sync_add_and_fetch(&hits, nr_loops);
22	return 0;
23}
24
25SEC("fentry/" SYS_PREFIX "sys_getpgid")
26int benchmark(void *ctx)
27{
28	bpf_loop(1000, outer_loop, NULL, 0);
29	return 0;
30}
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2/* Copyright (c) 2021 Facebook */
 3
 4#include "vmlinux.h"
 5#include <bpf/bpf_helpers.h>
 6#include "bpf_misc.h"
 7
 8char _license[] SEC("license") = "GPL";
 9
10u32 nr_loops;
11long hits;
12
13static int empty_callback(__u32 index, void *data)
14{
15	return 0;
16}
17
18static int outer_loop(__u32 index, void *data)
19{
20	bpf_loop(nr_loops, empty_callback, NULL, 0);
21	__sync_add_and_fetch(&hits, nr_loops);
22	return 0;
23}
24
25SEC("fentry/" SYS_PREFIX "sys_getpgid")
26int benchmark(void *ctx)
27{
28	bpf_loop(1000, outer_loop, NULL, 0);
29	return 0;
30}