sched/fair: Introduce priority load balance for CFS
PATCH v2 1/1 sched/fair: Introduce priority load balance for CFS
For co-location with idle and non-idle tasks, when CFS do load balance, it is reasonable to prefer migrating non-idle tasks and migrating idle tasks lastly to improve QoS of non-idle(Latency Sensitive) tasks.
However, the migrate_{load|util|task} difference between env->src_rq and env->dst_rq should also be considered. So we should add some restrictions before migrating non-idle tasks.
Let's deal with the following cases.
case migrate_load:
load_diff = sum_load(non-idle cfs tasks of env->src_rq) - sum_load(non-idle cfs tasks of env->dst_rq); if (load_diff < env->imbalance) goto migrate_cfs_idle_tasks;
case migrate_util:
util_diff = sum_util(non-idle cfs tasks of env->src_rq) - sum_util(non-idle cfs tasks of env->dst_rq); if (util_diff < env->imbalance) goto migrate_cfs_idle_tasks;
case migrate_task:
nr_diff = sum_nr(non-idle cfs tasks of env->src_rq) - sum_nr(non-idle cfs tasks of env->dst_rq); if (nr_diff < 1) goto migrate_cfs_idle_tasks;
---v1->v2:
- Remove sysctl knob and add LB_PRIO sched feature.
- Migrating tasks consider non-idle migrate_{load|util|task} difference between env->src_rq and env->dst_rq, and if the difference smaller than env->imbalance, change to migrate idle tasks instead.
--- kernel/sched/core.c | 1 + kernel/sched/fair.c | 132 ++++++++++++++++++++++++++++++++++++++-- kernel/sched/features.h | 1 + kernel/sched/sched.h | 1 + 4 files changed, 131 insertions(+), 4 deletions(-)
kernel/sched/core.c +1 -0
@@ -9731,6 +9731,7 @@ void __init sched_init(void) rq->max_idle_balance_cost = sysctl_sched_migration_cost;INIT_LIST_HEAD (&rq->cfs_tasks); +INIT_LIST_HEAD (&rq->cfs_idle_tasks);rq_attach_root (rq, &def_root_domain);#ifdef CONFIG_NO_HZ_COMMON
kernel/sched/fair.c +128 -4
212 lines not on this page · raw message
kernel/sched/features.h +1 -0
@@ -85,6 +85,7 @@ SCHED_FEAT(RT_PUSH_IPI, true) SCHED_FEAT(RT_RUNTIME_SHARE, false) SCHED_FEAT(LB_MIN, false) +SCHED_FEAT(LB_PRIO, false) SCHED_FEAT(ATTACH_AGE_LOAD, true)SCHED_FEAT (WA_IDLE , true)
kernel/sched/sched.h +1 -0
@@ -1053,6 +1053,7 @@ struct rq {int online;struct list_head cfs_tasks; +struct list_head cfs_idle_tasks;struct sched_avg avg_rt;struct sched_avg avg_dl;
Signature · 1 line
2.33.0