0001
0002
0003
0004 #include "vmlinux.h"
0005 #include <bpf/bpf_helpers.h>
0006 #include <bpf/usdt.bpf.h>
0007
0008 int urand_pid;
0009
0010 int urand_read_without_sema_call_cnt;
0011 int urand_read_without_sema_buf_sz_sum;
0012
0013 SEC("usdt/./urandom_read:urand:read_without_sema")
0014 int BPF_USDT(urand_read_without_sema, int iter_num, int iter_cnt, int buf_sz)
0015 {
0016 if (urand_pid != (bpf_get_current_pid_tgid() >> 32))
0017 return 0;
0018
0019 __sync_fetch_and_add(&urand_read_without_sema_call_cnt, 1);
0020 __sync_fetch_and_add(&urand_read_without_sema_buf_sz_sum, buf_sz);
0021
0022 return 0;
0023 }
0024
0025 int urand_read_with_sema_call_cnt;
0026 int urand_read_with_sema_buf_sz_sum;
0027
0028 SEC("usdt/./urandom_read:urand:read_with_sema")
0029 int BPF_USDT(urand_read_with_sema, int iter_num, int iter_cnt, int buf_sz)
0030 {
0031 if (urand_pid != (bpf_get_current_pid_tgid() >> 32))
0032 return 0;
0033
0034 __sync_fetch_and_add(&urand_read_with_sema_call_cnt, 1);
0035 __sync_fetch_and_add(&urand_read_with_sema_buf_sz_sum, buf_sz);
0036
0037 return 0;
0038 }
0039
0040 int urandlib_read_without_sema_call_cnt;
0041 int urandlib_read_without_sema_buf_sz_sum;
0042
0043 SEC("usdt/./liburandom_read.so:urandlib:read_without_sema")
0044 int BPF_USDT(urandlib_read_without_sema, int iter_num, int iter_cnt, int buf_sz)
0045 {
0046 if (urand_pid != (bpf_get_current_pid_tgid() >> 32))
0047 return 0;
0048
0049 __sync_fetch_and_add(&urandlib_read_without_sema_call_cnt, 1);
0050 __sync_fetch_and_add(&urandlib_read_without_sema_buf_sz_sum, buf_sz);
0051
0052 return 0;
0053 }
0054
0055 int urandlib_read_with_sema_call_cnt;
0056 int urandlib_read_with_sema_buf_sz_sum;
0057
0058 SEC("usdt/./liburandom_read.so:urandlib:read_with_sema")
0059 int BPF_USDT(urandlib_read_with_sema, int iter_num, int iter_cnt, int buf_sz)
0060 {
0061 if (urand_pid != (bpf_get_current_pid_tgid() >> 32))
0062 return 0;
0063
0064 __sync_fetch_and_add(&urandlib_read_with_sema_call_cnt, 1);
0065 __sync_fetch_and_add(&urandlib_read_with_sema_buf_sz_sum, buf_sz);
0066
0067 return 0;
0068 }
0069
0070 char _license[] SEC("license") = "GPL";