From f522a546bf9a682f3c99b809a2a15c3ad5c7328b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=99=97=E5=8D=9A?= Date: Fri, 17 Jan 2025 18:42:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9cs=5Fdelay=E8=BE=93=E5=87=BAb?= =?UTF-8?q?ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CPU_Subsystem/cpu_watcher/cpu_watcher.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c b/eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c index e50e23ab2..f59178c50 100644 --- a/eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c +++ b/eBPF_Supermarket/CPU_Subsystem/cpu_watcher/cpu_watcher.c @@ -438,7 +438,7 @@ static int print_all() return 0; } -int count[25]={0};//定义一个count数组,用于汇总schedul()调度时间,以log2(时间间隔)为统计依据; +int count[25]={0} , cs_flag=0;//定义一个count数组,用于汇总schedul()调度时间,以log2(时间间隔)为统计依据; static int handle_event(void *ctx, void *data,unsigned long data_sz) { const struct event *e = data; @@ -449,6 +449,8 @@ static int handle_event(void *ctx, void *data,unsigned long data_sz) i ++; } count[i]++; + if(!cs_flag) + cs_flag = 1; return 0; } static int print_hstgram(int i,int max,int per_len) @@ -1101,7 +1103,11 @@ int main(int argc, char **argv) printf("Error polling perf buffer: %d\n", err); break; } - histogram(); + struct cs_ctrl *cs_ctrl; + int ctrl_key = 0 ; + if(cs_flag){ + histogram(); + } } else if(env.SYSCALL_DELAY){ err = ring_buffer__poll(rb, 100 /* timeout, ms */); //ring_buffer__poll(),轮询打开ringbuf缓冲区。如果有事件,handle_event函数会执行