]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
sched/core: Convert ___assert_task_state() link time assert to BUILD_BUG_ON()
authorIngo Molnar <mingo@kernel.org>
Fri, 3 Feb 2017 11:22:54 +0000 (12:22 +0100)
committerIngo Molnar <mingo@kernel.org>
Thu, 2 Mar 2017 07:42:23 +0000 (08:42 +0100)
The length of TASK_STATE_TO_CHAR_STR was still checked using the old
link-time manual error method - convert it to BUILD_BUG_ON(). This
has a couple of advantages:

 - it's more obvious what's going on

 - it reduces the size and complexity of <linux/sched.h>

 - BUILD_BUG_ON() will fail during compilation, with a clearer
   error message than the link time assert.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/sched.h
kernel/sched/core.c

index 4a28deb5f210a103d486fa12c509405f92f4ca60..c204613396cd3cb53b06b0a3e897ab7ae8a1e215 100644 (file)
@@ -223,9 +223,6 @@ extern void proc_sched_set_task(struct task_struct *p);
 
 #define TASK_STATE_TO_CHAR_STR "RSDTtXZxKWPNn"
 
-extern char ___assert_task_state[1 - 2*!!(
-               sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)];
-
 /* Convenience macros for the sake of set_current_state */
 #define TASK_KILLABLE          (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
 #define TASK_STOPPED           (TASK_WAKEKILL | __TASK_STOPPED)
index bbfb917a9b4998f8254b4cae92f2dce129761bbb..7d76ccb79e91e462532c86b21302d90574ef6762 100644 (file)
@@ -5233,6 +5233,9 @@ void sched_show_task(struct task_struct *p)
        int ppid;
        unsigned long state = p->state;
 
+       /* Make sure the string lines up properly with the number of task states: */
+       BUILD_BUG_ON(sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1);
+
        if (!try_get_task_stack(p))
                return;
        if (state)