sched: Warn on long periods of pending need_resched
authorPaul Turner <pjt@google.com>
Fri, 16 Apr 2021 21:29:36 +0000 (14:29 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 21 Apr 2021 11:55:41 +0000 (13:55 +0200)
commitc006fac556e401a62054d065da168099ea5a5b10
treed35910fa4eab4ab7821226ebc76709a04a33baf5
parent3f5ad91488e813026f8c5f46b839e91a83912703
sched: Warn on long periods of pending need_resched

CPU scheduler marks need_resched flag to signal a schedule() on a
particular CPU. But, schedule() may not happen immediately in cases
where the current task is executing in the kernel mode (no
preemption state) for extended periods of time.

This patch adds a warn_on if need_resched is pending for more than the
time specified in sysctl resched_latency_warn_ms. If it goes off, it is
likely that there is a missing cond_resched() somewhere. Monitoring is
done via the tick and the accuracy is hence limited to jiffy scale. This
also means that we won't trigger the warning if the tick is disabled.

This feature (LATENCY_WARN) is default disabled.

Signed-off-by: Paul Turner <pjt@google.com>
Signed-off-by: Josh Don <joshdon@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210416212936.390566-1-joshdon@google.com
include/linux/sched/sysctl.h
kernel/sched/core.c
kernel/sched/debug.c
kernel/sched/features.h
kernel/sched/sched.h