sched_ext: Move built-in idle CPU selection policy to a separate file
PATCH v3 1/1 sched_ext: Move built-in idle CPU selection policy to a separate file
As ext.c is becoming quite large, move the idle CPU selection policy to separate files (ext_idle.c / ext_idle.h) for better code readability.
Moreover, group together all the idle CPU selection kfunc's to the same btf_kfunc_id_set block.
No functional changes, this is purely code reorganization.
--- MAINTAINERS | 3 +- kernel/sched/build_policy.c | 1 + kernel/sched/ext.c | 739 +---------------------------------- kernel/sched/ext_idle.c | 752 ++++++++++++++++++++++++++++++++++++ kernel/sched/ext_idle.h | 39 ++ 5 files changed, 808 insertions(+), 726 deletions(-) create mode 100644 kernel/sched/ext_idle.c create mode 100644 kernel/sched/ext_idle.h
ChangeLog v2 -> v3:
- make the kfunc id sets static and introduce scx_idle_init() to register them
ChangeLog v1 -> v2:
- move idle kfuncs to a separate btf ids set (scx_kfunc_set_idle)
- declare idle functions as extern prototypes with an "scx_idle_" prefix
MAINTAINERS +1 -2
@@ -21006,8 +21006,7 @@ S: Maintained W: https://github.com/sched-ext/scx T: git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git F: include/linux/sched/ext.h -F: kernel/sched/ext.h -F: kernel/sched/ext.c +F: kernel/sched/ext* F: tools/sched_ext/ F: tools/testing/selftests/sched_ext
kernel/sched/build_policy.c +1 -0
@@ -61,6 +61,7 @@#ifdef CONFIG_SCHED_CLASS_EXT # include "ext.c" +# include "ext_idle.c" #endif #include "syscalls.c"
kernel/sched/ext.c +15 -724
823 lines not on this page · raw message
kernel/sched/ext_idle.c new file +752 -0
752 lines not on this page · raw message
kernel/sched/ext_idle.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* BPF extensible scheduler class: Documentation/scheduler/sched-ext.rst +* +* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. +* Copyright (c) 2022 Tejun Heo <[email protected]> +* Copyright (c) 2022 David Vernet <[email protected]> +* Copyright (c) 2024 Andrea Righi <[email protected]> +*/ +#ifndef _KERNEL_SCHED_EXT_IDLE_H +#define _KERNEL_SCHED_EXT_IDLE_H + +extern struct static_key_false scx_builtin_idle_enabled; + +#ifdef CONFIG_SMP +extern struct static_key_false scx_selcpu_topo_llc; +extern struct static_key_false scx_selcpu_topo_numa; + +void scx_idle_update_selcpu_topology (void ); +void scx_idle_reset_masks (void ); +void scx_idle_init_masks (void ); +bool scx_idle_test_and_clear_cpu (int cpu); +s32 scx_pick_idle_cpu (const struct cpumask *cpus_allowed,u64 flags); +#else /* !CONFIG_SMP */ +static inline void scx_idle_update_selcpu_topology (void ) {} +static inline void scx_idle_reset_masks (void ) {} +static inline void scx_idle_init_masks (void ) {} +static inline bool scx_idle_test_and_clear_cpu (int cpu) {return false; } +static inline s32 scx_pick_idle_cpu (const struct cpumask *cpus_allowed,u64 flags) +{ +return -EBUSY ; +} +#endif /* CONFIG_SMP */ + +s32 scx_select_cpu_dfl (struct task_struct *p,s32 prev_cpu,u64 wake_flags,bool *found); + +extern int scx_idle_init (void ); + +#endif /* _KERNEL_SCHED_EXT_IDLE_H */
Signature · 1 line
2.48.1
Tejun Heo
AppliedQuoted 10 lines · Andrea Righi
As
ext.cis becoming quite large, move the idle CPU selection policy to separate files (ext_idle.c/ext_idle.h) for better code readability.Moreover, group together all the idle CPU selection kfunc's to the same
btf_kfunc_id_setblock.No functional changes, this is purely code reorganization.
Suggested-by Yury Norov <[email protected]>Signed-off-by Andrea Righi <[email protected]>
Applied to sched_ext/for-6.15.
Thanks.
Signature · 1 line
tejun