From c29231af861344c457c07432dc1015c7e275374b Mon Sep 17 00:00:00 2001 From: Hailong Liu Date: Wed, 23 Mar 2022 14:44:35 +0800 Subject: [PATCH] schedmoni: Set the default delay-threshold to 20ms The original 10ms for runslow is too short; It can generate amount of schedule latency infomation when I run a "make -j20" command on my 4 cores machine. So, change the default to 20ms. Signed-off-by: Hailong Liu --- .../monitor/sched/schedmoni/bpf/schedmoni.bpf.c | 14 ++++++++++++-- source/tools/monitor/sched/schedmoni/schedmoni.c | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/source/tools/monitor/sched/schedmoni/bpf/schedmoni.bpf.c b/source/tools/monitor/sched/schedmoni/bpf/schedmoni.bpf.c index 6d56d4e0..8ae5bb09 100644 --- a/source/tools/monitor/sched/schedmoni/bpf/schedmoni.bpf.c +++ b/source/tools/monitor/sched/schedmoni/bpf/schedmoni.bpf.c @@ -6,6 +6,7 @@ #include "../schedmoni.h" #include "../nosched.comm.h" +#define MAX_THRESH (10*1000) #define TASK_RUNNING 0 #define _(P) ({typeof(P) val = 0; bpf_probe_read(&val, sizeof(val), &P); val;}) @@ -214,11 +215,19 @@ int handle_switch(struct trace_event_raw_sched_switch *ctx) return 0; } +static inline u64 adjust_thresh(u64 min_us) +{ + if (min_us > MAX_THRESH) + min_us = MAX_THRESH; + + return min_us; +} + SEC("kprobe/account_process_tick") int BPF_KPROBE(account_process_tick, struct task_struct *p, int user_tick) { int args_key; - u64 cpuid; + u64 cpuid, min_us; u64 resched_latency, now; struct latinfo lati, *latp; struct args args, *argsp; @@ -243,7 +252,8 @@ int BPF_KPROBE(account_process_tick, struct task_struct *p, int user_tick) } else { latp->ticks_without_resched++; resched_latency = (now - latp->last_seen_need_resched_ns)/1000; - if (resched_latency > _(argsp->min_us)) { + min_us = adjust_thresh(_(argsp->min_us)); + if (resched_latency > min_us) { struct key_t key; struct ext_key ext_key; struct ext_val ext_val; diff --git a/source/tools/monitor/sched/schedmoni/schedmoni.c b/source/tools/monitor/sched/schedmoni/schedmoni.c index d858fc90..c4b19f06 100644 --- a/source/tools/monitor/sched/schedmoni/schedmoni.c +++ b/source/tools/monitor/sched/schedmoni/schedmoni.c @@ -24,7 +24,7 @@ char filename[256] = {0}; struct env env = { .span = 0, - .min_us = 10000, + .min_us = 20000, .fp = NULL, }; -- Gitee