1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/usdt.bpf.h>
10 int urand_read_without_sema_call_cnt;
11 int urand_read_without_sema_buf_sz_sum;
13 SEC("usdt/./urandom_read:urand:read_without_sema")
14 int BPF_USDT(urand_read_without_sema, int iter_num, int iter_cnt, int buf_sz)
16 if (urand_pid != (bpf_get_current_pid_tgid() >> 32))
19 __sync_fetch_and_add(&urand_read_without_sema_call_cnt, 1);
20 __sync_fetch_and_add(&urand_read_without_sema_buf_sz_sum, buf_sz);
25 int urand_read_with_sema_call_cnt;
26 int urand_read_with_sema_buf_sz_sum;
28 SEC("usdt/./urandom_read:urand:read_with_sema")
29 int BPF_USDT(urand_read_with_sema, int iter_num, int iter_cnt, int buf_sz)
31 if (urand_pid != (bpf_get_current_pid_tgid() >> 32))
34 __sync_fetch_and_add(&urand_read_with_sema_call_cnt, 1);
35 __sync_fetch_and_add(&urand_read_with_sema_buf_sz_sum, buf_sz);
40 int urandlib_read_without_sema_call_cnt;
41 int urandlib_read_without_sema_buf_sz_sum;
43 SEC("usdt/./liburandom_read.so:urandlib:read_without_sema")
44 int BPF_USDT(urandlib_read_without_sema, int iter_num, int iter_cnt, int buf_sz)
46 if (urand_pid != (bpf_get_current_pid_tgid() >> 32))
49 __sync_fetch_and_add(&urandlib_read_without_sema_call_cnt, 1);
50 __sync_fetch_and_add(&urandlib_read_without_sema_buf_sz_sum, buf_sz);
55 int urandlib_read_with_sema_call_cnt;
56 int urandlib_read_with_sema_buf_sz_sum;
58 SEC("usdt/./liburandom_read.so:urandlib:read_with_sema")
59 int BPF_USDT(urandlib_read_with_sema, int iter_num, int iter_cnt, int buf_sz)
61 if (urand_pid != (bpf_get_current_pid_tgid() >> 32))
64 __sync_fetch_and_add(&urandlib_read_with_sema_call_cnt, 1);
65 __sync_fetch_and_add(&urandlib_read_with_sema_buf_sz_sum, buf_sz);
70 char _license[] SEC("license") = "GPL";