Re: [PATCH v2 resubmit] sched: Warn on long periods of pending need_resched

From: Peter Zijlstra
Date: Mon Apr 19 2021 - 04:08:38 EST


On Fri, Apr 16, 2021 at 02:29:36PM -0700, Josh Don wrote:
> From: Paul Turner <pjt@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> Signed-off-by: Josh Don <joshdon@xxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> Link: https://lkml.kernel.org/r/20210323035706.572953-1-joshdon@xxxxxxxxxx

Thanks!