Skip to content

Commit

Permalink
增加输出过滤,识别被争用的锁
Browse files Browse the repository at this point in the history
  • Loading branch information
vvzxy committed Jul 12, 2024
1 parent b3d04d9 commit 134eb5e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,16 +598,19 @@ static int mutrace_print(void *ctx, void *data, unsigned long data_sz) {
return 0;
}

static int mutex_detail(){
int fd = bpf_map__fd(mu_skel->maps.mutex_info_map);
u64 key,next_key;
struct mutex_info_kernel info;
while (bpf_map_get_next_key(fd, &key, &next_key) == 0) {
int err = bpf_map_lookup_elem(fd, &next_key, &info);
printf(" %15llu %15llu %15llu %15llu %15d %15d %20s\n",
next_key, info.locked_total, info.locked_max, info.contended_total,info.count ,info.last_owner,info.last_name);
key = next_key;
}
static int mutex_detail() {
int fd = bpf_map__fd(mu_skel->maps.mutex_info_map);
u64 key, next_key;
struct mutex_info_kernel info;
while (bpf_map_get_next_key(fd, &key, &next_key) == 0) {
int err = bpf_map_lookup_elem(fd, &next_key, &info);
if (err == 0 && info.contended_total != 0) { // 添加过滤条件
printf(" %15llu %15lluns %15lluns %15lluns %15d %15d %20s\n",
next_key, info.locked_total, info.locked_max, info.contended_total, info.count, info.last_owner, info.last_name);
}
key = next_key;
}
return 0;
}

static int schedule_print()
Expand Down

0 comments on commit 134eb5e

Please sign in to comment.