1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Facebook
6 #include <bpf/bpf_helpers.h>
9 char _license[] SEC("license") = "GPL";
12 __uint(type, BPF_MAP_TYPE_RINGBUF);
13 } ringbuf SEC(".maps");
15 const volatile int batch_cnt = 0;
16 const volatile long use_output = 0;
19 long dropped __attribute__((aligned(128))) = 0;
21 const volatile long wakeup_data_size = 0;
23 static __always_inline long get_flags()
27 if (!wakeup_data_size)
30 sz = bpf_ringbuf_query(&ringbuf, BPF_RB_AVAIL_DATA);
31 return sz >= wakeup_data_size ? BPF_RB_FORCE_WAKEUP : BPF_RB_NO_WAKEUP;
34 SEC("fentry/" SYS_PREFIX "sys_getpgid")
35 int bench_ringbuf(void *ctx)
41 for (i = 0; i < batch_cnt; i++) {
42 sample = bpf_ringbuf_reserve(&ringbuf,
43 sizeof(sample_val), 0);
45 __sync_add_and_fetch(&dropped, 1);
49 bpf_ringbuf_submit(sample, flags);
53 for (i = 0; i < batch_cnt; i++) {
55 if (bpf_ringbuf_output(&ringbuf, &sample_val,
56 sizeof(sample_val), flags))
57 __sync_add_and_fetch(&dropped, 1);