Skip to content

Commit c3a340f

Browse files
rostedtPeter Zijlstra
authored andcommitted
sched: Have sched_class_highest define by vmlinux.lds.h
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) <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 590d697 commit c3a340f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

include/asm-generic/vmlinux.lds.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@
114114
* relation to each other.
115115
*/
116116
#define SCHED_DATA \
117+
STRUCT_ALIGN(); \
118+
__begin_sched_classes = .; \
117119
*(__idle_sched_class) \
118120
*(__fair_sched_class) \
119121
*(__rt_sched_class) \
120122
*(__dl_sched_class) \
121-
*(__stop_sched_class)
123+
*(__stop_sched_class) \
124+
__end_sched_classes = .;
122125

123126
/*
124127
* Align to a 32 byte boundary equal to the

kernel/sched/core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6646,6 +6646,14 @@ void __init sched_init(void)
66466646
unsigned long ptr = 0;
66476647
int i;
66486648

6649+
/* Make sure the linker didn't screw up */
6650+
BUG_ON(&idle_sched_class + 1 != &fair_sched_class ||
6651+
&fair_sched_class + 1 != &rt_sched_class ||
6652+
&rt_sched_class + 1 != &dl_sched_class);
6653+
#ifdef CONFIG_SMP
6654+
BUG_ON(&dl_sched_class + 1 != &stop_sched_class);
6655+
#endif
6656+
66496657
wait_bit_init();
66506658

66516659
#ifdef CONFIG_FAIR_GROUP_SCHED

kernel/sched/sched.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@ struct sched_class {
18111811
#ifdef CONFIG_FAIR_GROUP_SCHED
18121812
void (*task_change_group)(struct task_struct *p, int type);
18131813
#endif
1814-
};
1814+
} __aligned(32); /* STRUCT_ALIGN(), vmlinux.lds.h */
18151815

18161816
static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
18171817
{
@@ -1825,17 +1825,18 @@ static inline void set_next_task(struct rq *rq, struct task_struct *next)
18251825
next->sched_class->set_next_task(rq, next, false);
18261826
}
18271827

1828-
#ifdef CONFIG_SMP
1829-
#define sched_class_highest (&stop_sched_class)
1830-
#else
1831-
#define sched_class_highest (&dl_sched_class)
1832-
#endif
1828+
/* Defined in include/asm-generic/vmlinux.lds.h */
1829+
extern struct sched_class __begin_sched_classes[];
1830+
extern struct sched_class __end_sched_classes[];
1831+
1832+
#define sched_class_highest (__end_sched_classes - 1)
1833+
#define sched_class_lowest (__begin_sched_classes - 1)
18331834

18341835
#define for_class_range(class, _from, _to) \
1835-
for (class = (_from); class != (_to); class = class->next)
1836+
for (class = (_from); class != (_to); class--)
18361837

18371838
#define for_each_class(class) \
1838-
for_class_range(class, sched_class_highest, NULL)
1839+
for_class_range(class, sched_class_highest, sched_class_lowest)
18391840

18401841
extern const struct sched_class stop_sched_class;
18411842
extern const struct sched_class dl_sched_class;

0 commit comments

Comments
 (0)