Skip to content

Commit

Permalink
Merge pull request #887 from vvzxy/develop
Browse files Browse the repository at this point in the history
cpu_watcher:用户态互斥锁测试
  • Loading branch information
LinkinPF committed Sep 13, 2024
2 parents 2471bf2 + 4e1d172 commit 240185a
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 128 deletions.
6 changes: 6 additions & 0 deletions eBPF_Supermarket/CPU_Subsystem/cpu_watcher/bpf/cs_delay.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ SEC("kprobe/schedule")
int BPF_KPROBE(schedule)
{
struct cs_ctrl *cs_ctrl = get_cs_ctrl();
if (!cs_ctrl) {
return 0;
}
u64 t1;
t1 = bpf_ktime_get_ns()/1000;
int key =0;
Expand All @@ -54,6 +57,9 @@ SEC("kretprobe/schedule")
int BPF_KRETPROBE(schedule_exit)
{
struct cs_ctrl *cs_ctrl = get_cs_ctrl();
if (!cs_ctrl) {
return 0;
}
u64 t2 = bpf_ktime_get_ns()/1000;
u64 t1,delay;
int key = 0;
Expand Down
21 changes: 21 additions & 0 deletions eBPF_Supermarket/CPU_Subsystem/cpu_watcher/bpf/mq_delay.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ int BPF_KPROBE(mq_timedsend,mqd_t mqdes, const char *u_msg_ptr,
struct timespec64 *ts)
{
struct mq_ctrl *mq_ctrl = get_mq_ctrl();
if (!mq_ctrl) {
return 0;
}
u64 send_enter_time = bpf_ktime_get_ns();//开始发送信息时间;
int pid = bpf_get_current_pid_tgid();//发送端pid

Expand All @@ -95,6 +98,9 @@ int BPF_KPROBE(mq_timedsend,mqd_t mqdes, const char *u_msg_ptr,
SEC("kprobe/load_msg")
int BPF_KPROBE(load_msg_enter,const void *src, size_t len){
struct mq_ctrl *mq_ctrl = get_mq_ctrl();
if (!mq_ctrl) {
return 0;
}
int pid = bpf_get_current_pid_tgid();//发送端pid
/*记录load入参src*/
struct send_events *mq_send_info = bpf_map_lookup_elem(&send_msg1, &pid);
Expand All @@ -110,6 +116,9 @@ int BPF_KPROBE(load_msg_enter,const void *src, size_t len){
SEC("kretprobe/load_msg")
int BPF_KRETPROBE(load_msg_exit,void *ret){
struct mq_ctrl *mq_ctrl = get_mq_ctrl();
if (!mq_ctrl) {
return 0;
}
int pid = bpf_get_current_pid_tgid();//发送端pid
/*构建消息块结构体,作为key*/
struct send_events *mq_send_info = bpf_map_lookup_elem(&send_msg1, &pid);
Expand All @@ -136,6 +145,9 @@ SEC("kretprobe/do_mq_timedsend")
int BPF_KRETPROBE(do_mq_timedsend_exit,void *ret)
{
struct mq_ctrl *mq_ctrl = get_mq_ctrl();
if (!mq_ctrl) {
return 0;
}
bpf_printk("do_mq_timedsend_exit----------------------------------------------------------------\n");
u64 send_exit_time = bpf_ktime_get_ns();//开始发送信息时间;
int pid = bpf_get_current_pid_tgid();//发送端pid
Expand Down Expand Up @@ -164,6 +176,9 @@ int BPF_KPROBE(mq_timedreceive_entry,mqd_t mqdes, const char __user *u_msg_ptr,
struct timespec64 *ts)
{
struct mq_ctrl *mq_ctrl = get_mq_ctrl();
if (!mq_ctrl) {
return 0;
}
u64 rcv_enter_time = bpf_ktime_get_ns();
int pid = bpf_get_current_pid_tgid();

Expand All @@ -182,6 +197,9 @@ SEC("kprobe/store_msg")
int BPF_KPROBE(store_msg,void __user *dest, struct msg_msg *msg, size_t len)
{
struct mq_ctrl *mq_ctrl = get_mq_ctrl();
if (!mq_ctrl) {
return 0;
}
int pid = bpf_get_current_pid_tgid();

/*make key*/
Expand Down Expand Up @@ -210,6 +228,9 @@ int BPF_KPROBE(store_msg,void __user *dest, struct msg_msg *msg, size_t len)
SEC("kretprobe/do_mq_timedreceive")
int BPF_KRETPROBE(do_mq_timedreceive_exit,void *ret){
struct mq_ctrl *mq_ctrl = get_mq_ctrl();
if (!mq_ctrl) {
return 0;
}
u64 rcv_exit_time = bpf_ktime_get_ns();
int pid = bpf_get_current_pid_tgid();
u64 send_enter_time,delay;
Expand Down
Loading

0 comments on commit 240185a

Please sign in to comment.