[RFC][PATCH 2/4] sched: Have sched_class_highest define by vmlinux.lds.h

From: Steven Rostedt
Date: Thu Dec 19 2019 - 16:46:01 EST


From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

Now that the sched_class descriptors are defined by the linker script, and
this needs to be aware of the existance of stop_sched_class when SMP is
enabled or not, as it is used as the "highest" priority when defined. Move
the declaration of sched_class_highest to the same location in the linker
script that inserts stop_sched_class, and this will also make it easier to
see what should be defined as the highest class, as this linker script
location defines the priorities as well.

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
include/asm-generic/vmlinux.lds.h | 11 ++++++++++-
kernel/sched/sched.h | 9 +++------
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 772d961c69a5..1c14c4ddf785 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -109,9 +109,16 @@
#endif

#ifdef CONFIG_SMP
-#define STOP_SCHED_CLASS *(__stop_sched_class)
+#define STOP_SCHED_CLASS \
+ STRUCT_ALIGN(); \
+ sched_class_highest = .; \
+ *(__stop_sched_class)
+#define BEFORE_DL_SCHED_CLASS
#else
#define STOP_SCHED_CLASS
+#define BEFORE_DL_SCHED_CLASS \
+ STRUCT_ALIGN(); \
+ sched_class_highest = .;
#endif

/*
@@ -120,9 +127,11 @@
* relation to each other.
*/
#define SCHED_DATA \
+ STRUCT_ALIGN(); \
*(__idle_sched_class) \
*(__fair_sched_class) \
*(__rt_sched_class) \
+ BEFORE_DL_SCHED_CLASS \
*(__dl_sched_class) \
STOP_SCHED_CLASS

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 280a3c735935..0554c588ad85 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1771,17 +1771,14 @@ static inline void set_next_task(struct rq *rq, struct task_struct *next)
next->sched_class->set_next_task(rq, next, false);
}

-#ifdef CONFIG_SMP
-#define sched_class_highest (&stop_sched_class)
-#else
-#define sched_class_highest (&dl_sched_class)
-#endif
+/* Defined in include/asm-generic/vmlinux.lds.h */
+extern struct sched_class sched_class_highest;

#define for_class_range(class, _from, _to) \
for (class = (_from); class != (_to); class = class->next)

#define for_each_class(class) \
- for_class_range(class, sched_class_highest, NULL)
+ for_class_range(class, &sched_class_highest, NULL)

extern const struct sched_class stop_sched_class;
extern const struct sched_class dl_sched_class;
--
2.24.0