sched/debug: Change need_resched warnings to pr_err
PATCH 1/2 sched/debug: Change need_resched warnings to pr_err
need_resched warnings, if enabled, are treated as WARNINGs. If kernel.panic_on_warn is enabled, then this causes a kernel panic.
It's highly unlikely that a panic is desired for these warnings, only a stack trace is normally required to debug and resolve.
Thus, switch need_resched warnings to simply be a printk with an associated stack trace so they are no longer in scope for panic_on_warn.
--- kernel/sched/debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/sched/debug.c +6 -4
@@ -1295,8 +1295,10 @@ void resched_latency_warn(int cpu, u64 latency) { static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1); -WARN (__ratelimit (&latency_check_ratelimit), -"sched: CPU %d need_resched set for > %llu ns (%d ticks) " -"without schedule\n" , - cpu, latency,cpu_rq (cpu)->ticks_without_resched); +if (likely (!__ratelimit (&latency_check_ratelimit))) +return ; + +pr_err ("sched: CPU %d need_resched set for > %llu ns (%d ticks) without schedule\n" , + cpu, latency,cpu_rq (cpu)->ticks_without_resched); +dump_stack (); }
Quoted 24 lines · David Rientjes
need_reschedwarnings, if enabled, are treated as WARNINGs. If kernel.panic_on_warn is enabled, then this causes a kernel panic.It's highly unlikely that a panic is desired for these warnings, only a stack trace is normally required to debug and resolve.
Thus, switch
need_reschedwarnings to simply be a printk with an associated stack trace so they are no longer in scope forpanic_on_warn.Signed-off-by David Rientjes <[email protected]>--- kernel/sched/debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)kernel/sched/debug.c +0
-1@@ -1295,8 +1295,10 @@ void resched_latency_warn(int cpu, u64 latency) { static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1); - WARN(__ratelimit(&latency_check_ratelimit),
kernel/sched/debug.c void resched_latency_warn(int cpu, u64 latency) · line 1304
Quoted 10 lines
kernel/sched/debug.c +6
-3-"sched: CPU %d need_resched set for > %llu ns (%d ticks) " -"without schedule\n" , - cpu, latency, cpu_rq(cpu)->ticks_without_resched); +if (likely (!__ratelimit (&latency_check_ratelimit))) +return ; + +pr_err ("sched: CPU %d need_resched set for > %llu ns (%d ticks) without schedule\n" , + cpu, latency,cpu_rq (cpu)->ticks_without_resched); +dump_stack (); }
Thanks David, looks reasonable to me.
Hi David Rientjes,
Quoted 20 lines · David Rientjes
need_reschedwarnings, if enabled, are treated as WARNINGs. If kernel.panic_on_warn is enabled, then this causes a kernel panic.It's highly unlikely that a panic is desired for these warnings, only a stack trace is normally required to debug and resolve.
Thus, switch
need_reschedwarnings to simply be a printk with an associated stack trace so they are no longer in scope forpanic_on_warn.Signed-off-by David Rientjes <[email protected]>--- kernel/sched/debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)kernel/sched/debug.c +0
-0@@ -1295,8 +1295,10 @@ void resched_latency_warn(int cpu, u64 latency) { static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1);
kernel/sched/debug.c void resched_latency_warn(int cpu, u64 latency) · line 1302
Quoted 10 lines
kernel/sched/debug.c +5
-4-WARN (__ratelimit (&latency_check_ratelimit), -"sched: CPU %d need_resched set for > %llu ns (%d ticks) " -"without schedule\n" , - cpu, latency,cpu_rq (cpu)->ticks_without_resched); +if (likely (!__ratelimit (&latency_check_ratelimit))) +return ; + +pr_err ("sched: CPU %d need_resched set for > %llu ns (%d ticks) without schedule\n" , + cpu, latency,cpu_rq (cpu)->ticks_without_resched);
LGTM. While this is an issue, it doesn't necessarily indicate a critical failure that would require the kernel to panic.
Nit: Would using pr_warn instead be too lenient in this case?
Thanks,
Madadi Vineeth Reddy
Quoted 2 lines
kernel/sched/debug.c +1
-0+dump_stack (); }
Quoted 37 lines · Madadi Vineeth Reddy
Hi David Rientjes,
Quoted 20 lines · David Rientjes
need_reschedwarnings, if enabled, are treated as WARNINGs. If kernel.panic_on_warn is enabled, then this causes a kernel panic.It's highly unlikely that a panic is desired for these warnings, only a stack trace is normally required to debug and resolve.
Thus, switch
need_reschedwarnings to simply be a printk with an associated stack trace so they are no longer in scope forpanic_on_warn.Signed-off-by David Rientjes <[email protected]>--- kernel/sched/debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)kernel/sched/debug.c +0
-0@@ -1295,8 +1295,10 @@ void resched_latency_warn(int cpu, u64 latency) { static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1);kernel/sched/debug.c void resched_latency_warn(int cpu, u64 latency) · line 1302
Quoted 10 lines
kernel/sched/debug.c +5
-4-WARN (__ratelimit (&latency_check_ratelimit), -"sched: CPU %d need_resched set for > %llu ns (%d ticks) " -"without schedule\n" , - cpu, latency,cpu_rq (cpu)->ticks_without_resched); +if (likely (!__ratelimit (&latency_check_ratelimit))) +return ; + +pr_err ("sched: CPU %d need_resched set for > %llu ns (%d ticks) without schedule\n" , + cpu, latency,cpu_rq (cpu)->ticks_without_resched);LGTM. While this is an issue, it doesn't necessarily indicate a critical failure that would require the kernel to panic.
Quoted 2 lines
Nit: Would using
pr_warninstead be too lenient in this case?
Thanks! I pondered the log level here for about five seconds, I'm indifferent to pr_err() or pr_warn() :) Since the stack trace is the most critical element of the output here, imo, and it has its own log level, I didn't feel strongly for either err or warn.
Quoted 9 lines
Reviewed-by Madadi Vineeth Reddy <[email protected]>Thanks,
Madadi Vineeth ReddyQuoted 2 lines
kernel/sched/debug.c +1
-0+dump_stack (); }
PATCH v2 1/1 sched/debug: Change need_resched warnings to pr_err
In reply to David Rientjesneed_resched warnings, if enabled, are treated as WARNINGs. If kernel.panic_on_warn is enabled, then this causes a kernel panic.
It's highly unlikely that a panic is desired for these warnings, only a stack trace is normally required to debug and resolve.
Thus, switch need_resched warnings to simply be a printk with an associated stack trace so they are no longer in scope for panic_on_warn.
---
v2: added Acked-by and Reviewed-by, dropped second patch in the series
kernel/sched/debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/sched/debug.c +6 -4
@@ -1295,8 +1295,10 @@ void resched_latency_warn(int cpu, u64 latency) { static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1); -WARN (__ratelimit (&latency_check_ratelimit), -"sched: CPU %d need_resched set for > %llu ns (%d ticks) " -"without schedule\n" , - cpu, latency,cpu_rq (cpu)->ticks_without_resched); +if (likely (!__ratelimit (&latency_check_ratelimit))) +return ; + +pr_err ("sched: CPU %d need_resched set for > %llu ns (%d ticks) without schedule\n" , + cpu, latency,cpu_rq (cpu)->ticks_without_resched); +dump_stack (); }
The following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 8061b9f5e111a3012f8b691e5b75dd81eafbb793 Gitweb: https://git.kernel.org/tip/8061b9f5e111a3012f8b691e5b75dd81eafbb793 Author: David Rientjes <[email protected]> AuthorDate: Thu, 09 Jan 2025 16:24:33 -08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 13 Jan 2025 14:10:23 +01:00
sched/debug: Change need_resched warnings to pr_err
need_resched warnings, if enabled, are treated as WARNINGs. If kernel.panic_on_warn is enabled, then this causes a kernel panic.
It's highly unlikely that a panic is desired for these warnings, only a stack trace is normally required to debug and resolve.
Thus, switch need_resched warnings to simply be a printk with an associated stack trace so they are no longer in scope for panic_on_warn.
--- kernel/sched/debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/sched/debug.c +6 -4
@@ -1292,8 +1292,10 @@ void resched_latency_warn(int cpu, u64 latency) { static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1); -WARN (__ratelimit (&latency_check_ratelimit), -"sched: CPU %d need_resched set for > %llu ns (%d ticks) " -"without schedule\n" , - cpu, latency,cpu_rq (cpu)->ticks_without_resched); +if (likely (!__ratelimit (&latency_check_ratelimit))) +return ; + +pr_err ("sched: CPU %d need_resched set for > %llu ns (%d ticks) without schedule\n" , + cpu, latency,cpu_rq (cpu)->ticks_without_resched); +dump_stack (); }