Skip to content

Commit

Permalink
modify mfutex.bpf.c
Browse files Browse the repository at this point in the history
  • Loading branch information
albertxu216 committed Sep 13, 2024
1 parent 09a1fe1 commit a000226
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions eBPF_Supermarket/CPU_Subsystem/eBPF_proc_image/bpf/mfutex.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ struct {
__uint(max_entries,528 * 10240);
} mfutex_rb SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 10240);
__type(key, struct record_lock_key);
__type(value, struct per_request);
} futex_wait_queue SEC(".maps");//记录futex陷入内核
// struct {
// __uint(type, BPF_MAP_TYPE_HASH);
// __uint(max_entries, 10240);
// __type(key, struct record_lock_key);
// __type(value, struct per_request);
// } futex_wait_queue SEC(".maps");//记录futex陷入内核


#define MUTEX_FLAG 1
Expand Down Expand Up @@ -280,27 +280,15 @@ int BPF_KPROBE(pthread_mutex_unlock_enter, void *__mutex)
// return 0;
// }

SEC("uprobe/futex")
int trace_futex(struct pt_regs *ctx) {
struct event ev = {};
ev.pid = bpf_get_current_pid_tgid() >> 32; // 获取进程PID
ev.ts = bpf_ktime_get_ns(); // 获取时间戳
ev.uaddr = PT_REGS_PARM1(ctx); // 获取futex地址
ev.futex_op = PT_REGS_PARM2(ctx); // 获取futex操作

// 将数据发送到用户态
bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, &ev, sizeof(ev));
return 0;
}

/*获取到要加入等待队列的线程,拿到时间*/
SEC("kprobe/futex_wait")
int BPF_KPROBE(trace_futex_wait,
u32 __user *uaddr, unsigned int flags,
u32 val, ktime_t *abs_time, u32 bitset)
{
// /*获取到要加入等待队列的线程,拿到时间*/
// SEC("kprobe/futex_wait")
// int BPF_KPROBE(trace_futex_wait,
// u32 __user *uaddr, unsigned int flags,
// u32 val, ktime_t *abs_time, u32 bitset)
// {




}
// }

0 comments on commit a000226

Please sign in to comment.