sched: Have BUG_ON() check if linker sched classes don't line up correctly
Steven Rostedt
reviewerPATCH 1/1 sched: Have BUG_ON() check if linker sched classes don't line up correctly
From: Steven Rostedt (VMware) <[email protected]>
If the sched_class structures do not match how the compiler thinks they are in an array, it can cause hard to debug bugs. Change the BUG_ON() from making sure each of the sched classes are in the proper order, to also making sure they are off by the proper amount.
---
kernel/sched/core.c +5 -4
@@ -6635,12 +6635,13 @@ void __init sched_init(void)unsigned long ptr =0 ;int i; -BUG_ON (&idle_sched_class > &fair_sched_class || - &fair_sched_class > &rt_sched_class || - &rt_sched_class > &dl_sched_class); +/* Make sure the linker didn't screw up */ +BUG_ON (&idle_sched_class +1 != &fair_sched_class || + &fair_sched_class +1 != &rt_sched_class || + &rt_sched_class +1 != &dl_sched_class);#ifdef CONFIG_SMP -BUG_ON (&dl_sched_class > &stop_sched_class); +BUG_ON (&dl_sched_class +1 != &stop_sched_class);#endif wait_bit_init ();
Peter Zijlstra
maintainerQuoted 19 lines · Steven Rostedt
From: Steven Rostedt (VMware) <[email protected]>
If the
sched_classstructures do not match how the compiler thinks they are in an array, it can cause hard to debug bugs. Change theBUG_ON()from making sure each of the sched classes are in the proper order, to also making sure they are off by the proper amount.Signed-off-by Steven Rostedt (VMware) <[email protected]>---
kernel/sched/core.c +0
-2@@ -6635,12 +6635,13 @@ void __init sched_init(void)unsigned long ptr =0 ;int i; - BUG_ON(&idle_sched_class > &fair_sched_class || - &fair_sched_class > &rt_sched_class ||
kernel/sched/core.c void __init sched_init(void) · line 6645
Quoted 10 lines
kernel/sched/core.c +5
-2- &rt_sched_class > &dl_sched_class); +/* Make sure the linker didn't screw up */ +BUG_ON (&idle_sched_class +1 != &fair_sched_class || + &fair_sched_class +1 != &rt_sched_class || + &rt_sched_class +1 != &dl_sched_class);#ifdef CONFIG_SMP -BUG_ON (&dl_sched_class > &stop_sched_class); +BUG_ON (&dl_sched_class +1 != &stop_sched_class);#endif
Nice, I'll fold that.