Peter, Since you've already pulled the need_resched warning patch into your tree, I'm including just the diff based on that patch (in response to Mel's comments) below. This should be squashed into the original patch. Thanks, Josh --- >From 85796b4d299b1cf3f99bde154a356ce1061221b7 Mon Sep 17 00:00:00 2001 From: Josh Don <joshdon@xxxxxxxxxx> Date: Mon, 22 Mar 2021 20:57:06 -0700 Subject: [PATCH] fixup: sched: Warn on long periods of pending need_resched --- kernel/sched/core.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 6fdf15eebc0d..c07a4c17205f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -61,17 +61,13 @@ const_debug unsigned int sysctl_sched_features = /* * Print a warning if need_resched is set for the given duration (if - * resched_latency_warn_enabled is set). + * LATENCY_WARN is enabled). * * If sysctl_resched_latency_warn_once is set, only one warning will be shown * per boot. - * - * Resched latency will be ignored for the first resched_boot_quiet_sec, to - * reduce false alarms. */ -int sysctl_resched_latency_warn_ms = 100; -int sysctl_resched_latency_warn_once = 1; -static const long resched_boot_quiet_sec = 600; +__read_mostly int sysctl_resched_latency_warn_ms = 100; +__read_mostly int sysctl_resched_latency_warn_once = 1; #endif /* CONFIG_SCHED_DEBUG */ /* @@ -4542,20 +4538,19 @@ unsigned long long task_sched_runtime(struct task_struct *p) } #ifdef CONFIG_SCHED_DEBUG -static u64 resched_latency_check(struct rq *rq) +static u64 cpu_resched_latency(struct rq *rq) { int latency_warn_ms = READ_ONCE(sysctl_resched_latency_warn_ms); - u64 need_resched_latency, now = rq_clock(rq); + u64 resched_latency, now = rq_clock(rq); static bool warned_once; if (sysctl_resched_latency_warn_once && warned_once) return 0; - if (!need_resched() || WARN_ON_ONCE(latency_warn_ms < 2)) + if (!need_resched() || !latency_warn_ms) return 0; - /* Disable this warning for the first few mins after boot */ - if (now < resched_boot_quiet_sec * NSEC_PER_SEC) + if (system_state == SYSTEM_BOOTING) return 0; if (!rq->last_seen_need_resched_ns) { @@ -4565,13 +4560,13 @@ static u64 resched_latency_check(struct rq *rq) } rq->ticks_without_resched++; - need_resched_latency = now - rq->last_seen_need_resched_ns; - if (need_resched_latency <= latency_warn_ms * NSEC_PER_MSEC) + resched_latency = now - rq->last_seen_need_resched_ns; + if (resched_latency <= latency_warn_ms * NSEC_PER_MSEC) return 0; warned_once = true; - return need_resched_latency; + return resched_latency; } static int __init setup_resched_latency_warn_ms(char *str) @@ -4588,7 +4583,7 @@ static int __init setup_resched_latency_warn_ms(char *str) } __setup("resched_latency_warn_ms=", setup_resched_latency_warn_ms); #else -static inline u64 resched_latency_check(struct rq *rq) { return 0; } +static inline u64 cpu_resched_latency(struct rq *rq) { return 0; } #endif /* CONFIG_SCHED_DEBUG */ /* @@ -4614,7 +4609,7 @@ void scheduler_tick(void) update_thermal_load_avg(rq_clock_thermal(rq), rq, thermal_pressure); curr->sched_class->task_tick(rq, curr, 0); if (sched_feat(LATENCY_WARN)) - resched_latency = resched_latency_check(rq); + resched_latency = cpu_resched_latency(rq); calc_global_load_tick(rq); rq_unlock(rq, &rf); -- 2.31.0.291.g576ba9dcdaf-goog