From 134eb5e5d280b044e1a9b21f2b3f93dc89f13fea Mon Sep 17 00:00:00 2001 From: Zhangxinyi <643470801@qq.com> Date: Fri, 12 Jul 2024 16:54:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BE=93=E5=87=BA=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=EF=BC=8C=E8=AF=86=E5=88=AB=E8=A2=AB=E4=BA=89=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CPU_Subsystem/cpu_watcher/cpu_watcher.c | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c b/eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c index ef4ccfd67..0838cc238 100644 --- a/eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c +++ b/eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c @@ -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()