hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8929 ---------------------------------------- Refactor QOS_SCHED by decoupling the tag-related logic into a new sub-config called "QOS_LEVEL". This new config implements cgroup tagging and tag propagation, allowing it to be reused by "SMT QoS". Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- include/linux/sched.h | 20 ++++++++++++++++++++ init/Kconfig | 5 +++++ kernel/sched/core.c | 20 +++++++++++--------- kernel/sched/fair.c | 4 ++-- kernel/sched/sched.h | 18 ++---------------- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index f5c80c372f74..ba35e2265893 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2679,4 +2679,24 @@ static inline bool smart_grid_used(void) return false; } #endif + +#ifdef CONFIG_QOS_LEVEL +#ifdef CONFIG_QOS_SCHED_MULTILEVEL +enum task_qos_level { + QOS_LEVEL_OFFLINE_EX = -2, + QOS_LEVEL_OFFLINE = -1, + QOS_LEVEL_ONLINE = 0, + QOS_LEVEL_HIGH = 1, + QOS_LEVEL_HIGH_EX = 2 +}; +#else +enum task_qos_level { + QOS_LEVEL_OFFLINE = -1, + QOS_LEVEL_ONLINE = 0, +}; +#endif + +DECLARE_PER_CPU_ALIGNED(int, qos_smt_status); +#endif + #endif diff --git a/init/Kconfig b/init/Kconfig index b577cdeec6e5..a50e9c8a8cab 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1096,11 +1096,16 @@ menuconfig CGROUP_SCHED tasks. if CGROUP_SCHED +config QOS_LEVEL + bool + depends on CGROUP_SCHED && CFS_BANDWIDTH + config QOS_SCHED bool "Qos task scheduling" depends on CGROUP_SCHED depends on CFS_BANDWIDTH depends on SMP + select QOS_LEVEL default n help This option enable qos scheduler, and support co-location online diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 0d071de3ffa5..db9e41f600b8 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -121,7 +121,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); DEFINE_PER_CPU(struct rnd_state, sched_rnd_state); -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL static void sched_change_qos_group(struct task_struct *tsk, struct task_group *tg); #endif @@ -4881,7 +4881,7 @@ void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs) struct task_group, css); tg = autogroup_task_group(p, tg); p->sched_task_group = tg; -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL tg_qos = tg; #endif } @@ -4892,7 +4892,7 @@ void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs) * so use __set_task_cpu(). */ __set_task_cpu(p, smp_processor_id()); -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL sched_change_qos_group(p, tg_qos); #endif @@ -7850,7 +7850,7 @@ static int __sched_setscheduler(struct task_struct *p, } change: -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL /* * If the scheduling policy of an offline task is set to a policy * other than SCHED_IDLE, the online task preemption and cpu resource @@ -10524,7 +10524,7 @@ void ia64_set_curr_task(int cpu, struct task_struct *p) /* task_group_lock serializes the addition/removal of task groups */ static DEFINE_SPINLOCK(task_group_lock); -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL static inline int alloc_qos_sched_group(struct task_group *tg, struct task_group *parent) { @@ -10551,7 +10551,9 @@ static void sched_change_qos_group(struct task_struct *tsk, struct task_group *t __setscheduler_prio(tsk, normal_prio(tsk)); } } +#endif +#ifdef CONFIG_QOS_SCHED struct offline_args { struct work_struct work; struct task_struct *p; @@ -10642,7 +10644,7 @@ struct task_group *sched_create_group(struct task_group *parent) if (!alloc_fair_sched_group(tg, parent)) goto err; -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL if (!alloc_qos_sched_group(tg, parent)) goto err; #endif @@ -10737,7 +10739,7 @@ static void sched_change_group(struct task_struct *tsk, struct task_group *group { tsk->sched_task_group = group; -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL sched_change_qos_group(tsk, group); #endif @@ -11655,7 +11657,7 @@ static int cpu_rebuild_affinity_domain_u64(struct cgroup_subsys_state *css, } #endif /* CONFIG_QOS_SCHED_SMART_GRID */ -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL static int tg_change_scheduler(struct task_group *tg, void *data) { int policy; @@ -11988,7 +11990,7 @@ static struct cftype cpu_legacy_files[] = { .write = cpu_uclamp_max_write, }, #endif -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL { .name = "qos_level", .flags = CFTYPE_NOT_ON_ROOT, diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 38ee4c9c79bf..5af2793adae8 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -165,8 +165,8 @@ static bool qos_smt_expelled(int this_cpu); static bool is_offline_task(struct task_struct *p); #endif -#ifdef CONFIG_QOS_SCHED_SMT_EXPELLER -static DEFINE_PER_CPU(int, qos_smt_status); +#ifdef CONFIG_QOS_LEVEL +DEFINE_PER_CPU_ALIGNED(int, qos_smt_status); #endif #ifdef CONFIG_QOS_SCHED_PRIO_LB diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e9a60a6295e4..bba4812d9e21 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -459,7 +459,7 @@ struct task_group { struct cfs_bandwidth cfs_bandwidth; -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL long qos_level; #endif @@ -1583,20 +1583,6 @@ do { \ } while (0) #ifdef CONFIG_QOS_SCHED -#ifdef CONFIG_QOS_SCHED_MULTILEVEL -enum task_qos_level { - QOS_LEVEL_OFFLINE_EX = -2, - QOS_LEVEL_OFFLINE = -1, - QOS_LEVEL_ONLINE = 0, - QOS_LEVEL_HIGH = 1, - QOS_LEVEL_HIGH_EX = 2 -}; -#else -enum task_qos_level { - QOS_LEVEL_OFFLINE = -1, - QOS_LEVEL_ONLINE = 0, -}; -#endif void init_qos_hrtimer(int cpu); #endif @@ -3483,7 +3469,7 @@ static inline bool is_per_cpu_kthread(struct task_struct *p) } #endif -#ifdef CONFIG_QOS_SCHED +#ifdef CONFIG_QOS_LEVEL static inline int qos_idle_policy(int policy) { return policy == QOS_LEVEL_OFFLINE; -- 2.34.1