* [PATCH] sched: Have BUG_ON() check if linker sched classes don't line up correctly
@ 2020-06-19 22:02 Steven Rostedt
2020-06-19 22:38 ` Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2020-06-19 22:02 UTC (permalink / raw)
To: Peter Zijlstra
Cc: LKML, philip.li, Ingo Molnar, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Ben Segall, Mel Gorman
From: Steven Rostedt (VMware) <rostedt@goodmis.org>
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.
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7ad864dc3ac5..876d7ecdab52 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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();
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sched: Have BUG_ON() check if linker sched classes don't line up correctly
2020-06-19 22:02 [PATCH] sched: Have BUG_ON() check if linker sched classes don't line up correctly Steven Rostedt
@ 2020-06-19 22:38 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2020-06-19 22:38 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, philip.li, Ingo Molnar, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Ben Segall, Mel Gorman
On Fri, Jun 19, 2020 at 06:02:19PM -0400, Steven Rostedt wrote:
> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> 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.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 7ad864dc3ac5..876d7ecdab52 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -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
Nice, I'll fold that.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-19 22:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19 22:02 [PATCH] sched: Have BUG_ON() check if linker sched classes don't line up correctly Steven Rostedt
2020-06-19 22:38 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).