mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	philip.li@intel.com, Ingo Molnar <mingo@kernel.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>
Subject: [PATCH] sched: Have BUG_ON() check if linker sched classes don't line up correctly
Date: Fri, 19 Jun 2020 18:02:19 -0400	[thread overview]
Message-ID: <20200619180219.0d558512@oasis.local.home> (raw)

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();

             reply	other threads:[~2020-06-19 22:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-19 22:02 Steven Rostedt [this message]
2020-06-19 22:38 ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200619180219.0d558512@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=philip.li@intel.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®