sched/fair: Introduce priority load balance for CFS
PATCH v4 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 by env->migration_type for detach_tasks().
If {load|util|nr}_imb is the non-idle cfs tasks {load|util|nr} imbalance between env->src_rq and env->dst_rq.
case migrate_load:
load = task_h_load(p); if (load_imb < load) goto next; load_imb -= load;
case migrate_util:
util = task_util(p); if (util_imb < util) goto next; util_imb -= util;
case migrate_task:
if (nr_imb < 1) break loop;
---v3->v4:
- Remove can_migrate_cfs_tasks().
- Fix calculate migration {load|util|task} imbalance for env->src_rq and env->dst_rq for non-idle cfs tasks.
v2->v3:
- Fix can_migrate_cfs_tasks() for detach_one_task.
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 | 104 ++++++++++++++++++++++++++++++++++++++-- kernel/sched/features.h | 1 + kernel/sched/sched.h | 1 + 4 files changed, 103 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 +100 -4
184 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