hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I526XC
--------------------------------
If the feature enabled, util_avg of bottom-level tg is used, otherwise, util_avg of rq's cfs_rq is used.
Signed-off-by: Hui Tang tanghui20@huawei.com --- kernel/sched/fair.c | 19 ++++++++++++++----- kernel/sched/features.h | 7 +++++++ 2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5c8b48150862..f6068f1c28bc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7097,6 +7097,17 @@ static inline bool prefer_cpus_valid(struct task_struct *p) cpumask_subset(p->prefer_cpus, p->cpus_ptr); }
+static inline unsigned long taskgroup_cpu_util(struct task_group *tg, + int cpu) +{ +#ifdef CONFIG_FAIR_GROUP_SCHED + if (tg->se[cpu] && sched_feat(DA_UTIL_TASKGROUP)) + return tg->se[cpu]->avg.util_avg; +#endif + + return cpu_util(cpu); +} + /* * set_task_select_cpus: select the cpu range for task * @p: the task whose available cpu range will to set @@ -7127,13 +7138,11 @@ static void set_task_select_cpus(struct task_struct *p, int *idlest_cpu, rcu_read_lock(); tg = task_group(p); for_each_cpu(cpu, p->prefer_cpus) { - if (unlikely(!tg->se[cpu])) - continue; - if (idlest_cpu && available_idle_cpu(cpu)) { *idlest_cpu = cpu; } else if (idlest_cpu) { - spare = (long)(capacity_of(cpu) - tg->se[cpu]->avg.util_avg); + spare = (long)(capacity_of(cpu) - + taskgroup_cpu_util(tg, cpu)); if (spare > min_util) { min_util = spare; *idlest_cpu = cpu; @@ -7148,7 +7157,7 @@ static void set_task_select_cpus(struct task_struct *p, int *idlest_cpu, return; }
- util_avg_sum += tg->se[cpu]->avg.util_avg; + util_avg_sum += taskgroup_cpu_util(tg, cpu); tg_capacity += capacity_of(cpu); } rcu_read_unlock(); diff --git a/kernel/sched/features.h b/kernel/sched/features.h index fef48f5be2fa..76fade025c4b 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -106,3 +106,10 @@ SCHED_FEAT(UTIL_EST_FASTUP, true)
SCHED_FEAT(ALT_PERIOD, true) SCHED_FEAT(BASE_SLICE, true) + +#ifdef CONFIG_QOS_SCHED_DYNAMIC_AFFINITY +/* + * Use util_avg of bottom-Level taskgroup + */ +SCHED_FEAT(DA_UTIL_TASKGROUP, true) +#endif