1. vmlinux中shced_class的位置

 1/// kernel/sched/sched.h
 2/*
 3 * Helper to define a sched_class instance; each one is placed in a separate
 4 * section which is ordered by the linker script:
 5 *
 6 *   include/asm-generic/vmlinux.lds.h
 7 *
 8 * *CAREFUL* they are laid out in *REVERSE* order!!!
 9 *
10 * Also enforce alignment on the instance, not the type, to guarantee layout.
11 */
12#define DEFINE_SCHED_CLASS(name) \
13const struct sched_class name##_sched_class \
14	__aligned(__alignof__(struct sched_class)) \
15	__section("__" #name "_sched_class")
16
17/* Defined in include/asm-generic/vmlinux.lds.h */
18extern struct sched_class __sched_class_highest[];
19extern struct sched_class __sched_class_lowest[];
20
21#define for_class_range(class, _from, _to) \
22	for (class = (_from); class < (_to); class++)
23
24#define for_each_class(class) \
25	for_class_range(class, __sched_class_highest, __sched_class_lowest)
26
27#define sched_class_above(_a, _b)	((_a) < (_b))
28
29extern const struct sched_class stop_sched_class;
30extern const struct sched_class dl_sched_class;
31extern const struct sched_class rt_sched_class;
32extern const struct sched_class fair_sched_class;
33extern const struct sched_class idle_sched_class;

sched_class定义。

1# git grep -Inw DEFINE_SCHED_CLASS kernel/sched/*.c
2kernel/sched/deadline.c:2718:DEFINE_SCHED_CLASS(dl) = {
3kernel/sched/fair.c:12904:DEFINE_SCHED_CLASS(fair) = {
4kernel/sched/idle.c:478:DEFINE_SCHED_CLASS(idle) = {
5kernel/sched/rt.c:2699:DEFINE_SCHED_CLASS(rt) = {
6kernel/sched/stop_task.c:117:DEFINE_SCHED_CLASS(stop) = {

vmlinux.lds.h控制链接布局。

 1/// include/asm-generic/vmlinux.lds.h
 2/*
 3 * The order of the sched class addresses are important, as they are
 4 * used to determine the order of the priority of each sched class in
 5 * relation to each other.
 6 */
 7#define SCHED_DATA				\
 8	STRUCT_ALIGN();				\
 9	__sched_class_highest = .;		\
10	*(__stop_sched_class)			\
11	*(__dl_sched_class)			\
12	*(__rt_sched_class)			\
13	*(__fair_sched_class)			\
14	*(__idle_sched_class)			\
15	__sched_class_lowest = .;

2. shced_class列表

member idle fair rt dl stop
uclamp_enabled 1 1
enqueue_task enqueue_task_fair enqueue_task_rt enqueue_task_dl enqueue_task_stop
dequeue_task dequeue_task_idle dequeue_task_fair dequeue_task_rt dequeue_task_dl dequeue_task_stop
yield_task yield_task_fair yield_task_rt yield_task_dl yield_task_stop
yield_to_task yield_to_task_fair
check_preempt_curr check_preempt_curr_idle check_preempt_wakeup check_preempt_curr_rt check_preempt_curr_dl check_preempt_curr_stop
pick_next_task pick_next_task_idle __pick_next_task_fair pick_next_task_rt pick_next_task_dl pick_next_task_stop
put_prev_task put_prev_task_idle put_prev_task_fair put_prev_task_rt put_prev_task_dl put_prev_task_stop
set_next_task set_next_task_idle set_next_task_fair set_next_task_rt set_next_task_dl set_next_task_stop
balance balance_idle balance_fair balance_rt balance_dl balance_stop
select_task_rq select_task_rq_idle select_task_rq_fair select_task_rq_rt select_task_rq_dl select_task_rq_stop
pick_task pick_task_idle pick_task_fair pick_task_rt pick_task_dl pick_task_stop
migrate_task_rq migrate_task_rq_fair migrate_task_rq_dl
task_woken task_woken_rt task_woken_dl
set_cpus_allowed set_cpus_allowed_common set_cpus_allowed_common set_cpus_allowed_common set_cpus_allowed_dl set_cpus_allowed_common
rq_online rq_online_fair rq_online_rt rq_online_dl
rq_offline rq_offline_fair rq_offline_rt rq_offline_dl
find_lock_rq find_lock_lowest_rq find_lock_later_rq
task_tick task_tick_idle task_tick_fair task_tick_rt task_tick_dl task_tick_stop
task_fork task_fork_fair task_fork_dl
task_dead task_dead_fair
switched_from switched_from_fair switched_from_rt switched_from_dl
switched_to switched_to_idle switched_to_fair switched_to_rt switched_to_dl switched_to_stop
prio_changed prio_changed_idle prio_changed_fair prio_changed_rt prio_changed_dl prio_changed_stop
get_rr_interval get_rr_interval_fair get_rr_interval_rt
update_curr update_curr_idle update_curr_fair update_curr_rt update_curr_dl update_curr_stop
task_change_group task_change_group_fair
task_is_throttled task_is_throttled_fair task_is_throttled_rt task_is_throttled_dl

3. 调用关系