sched/core: Convert remaining BUG_ON() instances to WARN_ON_ONCE()
PATCH 1/1 sched/core: Convert remaining BUG_ON() instances to WARN_ON_ONCE()
Commit 09348d75a6ce ("sched/all: Change all BUG_ON() instances in the scheduler to WARN_ON_ONCE()") left a few BUG_ON() behind in core.c. Convert them as well.
As described in Documentation/process/deprecated.rst, BUG_ON() crashes the system, which makes the failure harder to report and to debug, as the message often never reaches the console or the syslog. With WARN_ON_ONCE() the user gets a chance to see and report the problem instead, and system owners who do not want to keep running after an "impossible" condition can still set panic_on_warn.
---
Follow-up to commit 09348d75a6ce which converted the scheduler BUG_ON() instances to WARN_ON_ONCE() but left a few behind in core.c.
Build tested on arm64 with CONFIG_NO_HZ_FULL and CONFIG_SCHED_CLASS_EXT enabled so that every converted site is compiled.
--- kernel/sched/core.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
kernel/sched/core.c +10 -10
@@ -5949,7 +5949,7 @@ static void sched_tick_stop(int cpu)int __init sched_tick_offload_init (void ) { tick_work_cpu = alloc_percpu(struct tick_work); -BUG_ON (!tick_work_cpu); +WARN_ON_ONCE (!tick_work_cpu);return 0 ; }
@@ -7582,7 +7582,7 @@ asmlinkage __visible void __sched preempt_schedule_irq(void)enum ctx_state prev_state;/* Catch callers which need to be fixed */ -BUG_ON (preempt_count () || !irqs_disabled ()); +WARN_ON_ONCE (preempt_count () || !irqs_disabled ()); prev_state =exception_enter ();
@@ -8619,7 +8619,7 @@ static inline void sched_set_rq_online(struct rq *rq, int cpu)rq_lock_irqsave (rq, &rf);if (rq->rd) { -BUG_ON (!cpumask_test_cpu (cpu, rq->rd->span)); +WARN_ON_ONCE (!cpumask_test_cpu (cpu, rq->rd->span));set_rq_online (rq); }rq_unlock_irqrestore (rq, &rf);
@@ -8631,7 +8631,7 @@ static inline void sched_set_rq_offline(struct rq *rq, int cpu)rq_lock_irqsave (rq, &rf);if (rq->rd) { -BUG_ON (!cpumask_test_cpu (cpu, rq->rd->span)); +WARN_ON_ONCE (!cpumask_test_cpu (cpu, rq->rd->span));set_rq_offline (rq); }rq_unlock_irqrestore (rq, &rf);
@@ -8954,13 +8954,13 @@ void __init sched_init(void)int i;/* Make sure the linker didn't screw up */ -BUG_ON (!sched_class_above (&stop_sched_class, &dl_sched_class)); -BUG_ON (!sched_class_above (&dl_sched_class, &rt_sched_class)); -BUG_ON (!sched_class_above (&rt_sched_class, &fair_sched_class)); -BUG_ON (!sched_class_above (&fair_sched_class, &idle_sched_class)); +WARN_ON_ONCE (!sched_class_above (&stop_sched_class, &dl_sched_class)); +WARN_ON_ONCE (!sched_class_above (&dl_sched_class, &rt_sched_class)); +WARN_ON_ONCE (!sched_class_above (&rt_sched_class, &fair_sched_class)); +WARN_ON_ONCE (!sched_class_above (&fair_sched_class, &idle_sched_class));#ifdef CONFIG_SCHED_CLASS_EXT -BUG_ON (!sched_class_above (&fair_sched_class, &ext_sched_class)); -BUG_ON (!sched_class_above (&ext_sched_class, &idle_sched_class)); +WARN_ON_ONCE (!sched_class_above (&fair_sched_class, &ext_sched_class)); +WARN_ON_ONCE (!sched_class_above (&ext_sched_class, &idle_sched_class));#endif wait_bit_init ();
---
base-commit: 73e3f0710014fe6d4ed98cfc02292f6121db7558
change-id: 20260827-warn_instead_bug-c9ea9389813c
Best regards,
Signature · 1 line
Amin Gattout <[email protected]>
Peter Zijlstra
maintainerQuoted 45 lines · Amin Gattout
Commit
09348d75a6ce("sched/all: Change allBUG_ON()instances in the scheduler toWARN_ON_ONCE()") left a fewBUG_ON()behind incore.c. Convert them as well.As described in
Documentation/process/deprecated.rst,BUG_ON()crashes the system, which makes the failure harder to report and to debug, as the message often never reaches the console or the syslog. WithWARN_ON_ONCE()the user gets a chance to see and report the problem instead, and system owners who do not want to keep running after an "impossible" condition can still setpanic_on_warn.Signed-off-by Amin Gattout <[email protected]>---
Follow-up to commit09348d75a6cewhich converted the schedulerBUG_ON()instances toWARN_ON_ONCE()but left a few behind incore.c.Build tested on arm64 with
CONFIG_NO_HZ_FULLandCONFIG_SCHED_CLASS_EXTenabled so that every converted site is compiled.--- kernel/sched/core.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)kernel/sched/core.c +2
-5@@ -5949,7 +5949,7 @@ static void sched_tick_stop(int cpu)int __init sched_tick_offload_init (void ) { tick_work_cpu = alloc_percpu(struct tick_work); -BUG_ON (!tick_work_cpu); +WARN_ON_ONCE (!tick_work_cpu);return 0 ; }@@ -8954,13 +8954,13 @@ void __init sched_init(void)int i;/* Make sure the linker didn't screw up */ -BUG_ON (!sched_class_above (&stop_sched_class, &dl_sched_class)); -BUG_ON (!sched_class_above (&dl_sched_class, &rt_sched_class)); -BUG_ON (!sched_class_above (&rt_sched_class, &fair_sched_class)); -BUG_ON (!sched_class_above (&fair_sched_class, &idle_sched_class)); +WARN_ON_ONCE (!sched_class_above (&stop_sched_class, &dl_sched_class));
kernel/sched/core.c void __init sched_init(void) · line 8965
Quoted 10 lines
kernel/sched/core.c +5
-2+WARN_ON_ONCE (!sched_class_above (&dl_sched_class, &rt_sched_class)); +WARN_ON_ONCE (!sched_class_above (&rt_sched_class, &fair_sched_class)); +WARN_ON_ONCE (!sched_class_above (&fair_sched_class, &idle_sched_class));#ifdef CONFIG_SCHED_CLASS_EXT -BUG_ON (!sched_class_above (&fair_sched_class, &ext_sched_class)); -BUG_ON (!sched_class_above (&ext_sched_class, &idle_sched_class)); +WARN_ON_ONCE (!sched_class_above (&fair_sched_class, &ext_sched_class)); +WARN_ON_ONCE (!sched_class_above (&ext_sched_class, &idle_sched_class));#endif
These all really should be BUG_ON(), there is absolutely no point in tying to complete the boot if they fail.
Fair enough, thanks for the quick feedback.
Quoted 62 lines · Peter Zijlstra
Quoted 45 lines · Amin Gattout
Commit
09348d75a6ce("sched/all: Change allBUG_ON()instances in the scheduler toWARN_ON_ONCE()") left a fewBUG_ON()behind incore.c. Convert them as well.As described in
Documentation/process/deprecated.rst,BUG_ON()crashes the system, which makes the failure harder to report and to debug, as the message often never reaches the console or the syslog. WithWARN_ON_ONCE()the user gets a chance to see and report the problem instead, and system owners who do not want to keep running after an "impossible" condition can still setpanic_on_warn.Signed-off-by Amin Gattout <[email protected]>---
Follow-up to commit09348d75a6cewhich converted the schedulerBUG_ON()instances toWARN_ON_ONCE()but left a few behind incore.c.Build tested on arm64 with
CONFIG_NO_HZ_FULLandCONFIG_SCHED_CLASS_EXTenabled so that every converted site is compiled.--- kernel/sched/core.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)kernel/sched/core.c +2
-5@@ -5949,7 +5949,7 @@ static void sched_tick_stop(int cpu)int __init sched_tick_offload_init (void ) { tick_work_cpu = alloc_percpu(struct tick_work); -BUG_ON (!tick_work_cpu); +WARN_ON_ONCE (!tick_work_cpu);return 0 ; }@@ -8954,13 +8954,13 @@ void __init sched_init(void)int i;/* Make sure the linker didn't screw up */ -BUG_ON (!sched_class_above (&stop_sched_class, &dl_sched_class)); -BUG_ON (!sched_class_above (&dl_sched_class, &rt_sched_class)); -BUG_ON (!sched_class_above (&rt_sched_class, &fair_sched_class)); -BUG_ON (!sched_class_above (&fair_sched_class, &idle_sched_class)); +WARN_ON_ONCE (!sched_class_above (&stop_sched_class, &dl_sched_class));kernel/sched/core.c void __init sched_init(void) · line 8965
Quoted 10 lines
kernel/sched/core.c +5
-2+WARN_ON_ONCE (!sched_class_above (&dl_sched_class, &rt_sched_class)); +WARN_ON_ONCE (!sched_class_above (&rt_sched_class, &fair_sched_class)); +WARN_ON_ONCE (!sched_class_above (&fair_sched_class, &idle_sched_class));#ifdef CONFIG_SCHED_CLASS_EXT -BUG_ON (!sched_class_above (&fair_sched_class, &ext_sched_class)); -BUG_ON (!sched_class_above (&ext_sched_class, &idle_sched_class)); +WARN_ON_ONCE (!sched_class_above (&fair_sched_class, &ext_sched_class)); +WARN_ON_ONCE (!sched_class_above (&ext_sched_class, &idle_sched_class));#endif These all really should be
BUG_ON(), there is absolutely no point in tying to complete the boot if they fail.