sched/fair: Introduce priority load balance to reduce interference from IDLE tasks
PATCH 1/1 sched/fair: Introduce priority load balance to reduce interference from IDLE tasks
For co-location with NORMAL and IDLE tasks, when CFS trigger load balance, it is reasonable to prefer migrating NORMAL(Latency Sensitive) tasks from the busy src CPU to dst CPU, and migrating IDLE tasks lastly.
This is very important for reducing interference from IDLE tasks. So the CFS load balance can be optimized to below:
1.cfs_tasks list of CPU rq is owned by NORMAL tasks. 2.cfs_idle_tasks list of CPU rq which is owned by IDLE tasks. 3.Prefer to migrate NORMAL tasks of cfs_tasks to dst CPU. 4.Lastly migrate IDLE tasks of cfs_idle_tasks to dst CPU.
This was tested with the following reproduction:
- small number of NORMAL tasks colocated with a large number of IDLE tasks
With this patch, NORMAL tasks latency can be reduced about 5~10% compared with current.
--- kernel/sched/core.c | 1 + kernel/sched/fair.c | 43 +++++++++++++++++++++++++++++++++++++++---- kernel/sched/sched.h | 1 + 3 files changed, 41 insertions(+), 4 deletions(-)
kernel/sched/core.c +1 -0
@@ -9733,6 +9733,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 +39 -4
113 lines not on this page · raw message
kernel/sched/sched.h +1 -0
@@ -1068,6 +1068,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.27.0
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi zhangsong,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on tip/sched/core]
[also build test ERROR on linus/master v5.19 next-20220809] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/zhangsong/sched-fair-Introduce-priority-load-balance-to-reduce-interference-from-IDLE-tasks/20220809-213204 base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 8648f92a66a323ed01903d2cbb248cdbe2f312d9 config: um-x86_64_defconfig (https://download.01.org/0day-ci/archive/20220810/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/20ac252fc4280e5b1a45070d722c7edc0695088b git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review zhangsong/sched-fair-Introduce-priority-load-balance-to-reduce-interference-from-IDLE-tasks/20220809-213204 git checkout 20ac252fc4280e5b1a45070d722c7edc0695088b # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=um SUBARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
All errors (new ones prefixed by >>):
kernel/sched/fair.c:672:5: warning: no previous prototype for 'sched_update_scaling' [-Wmissing-prototypes]
672 | int sched_update_scaling(void)
| ^~~~~~~~~~~~~~~~~~~~
kernel/sched/fair.c: In function 'adjust_rq_cfs_tasks':
>> kernel/sched/fair.c:3045:48: error: 'struct rq' has no member named 'cfs_idle_tasks'
3045 | (*list_op)(&se->group_node, &rq->cfs_idle_tasks);
| ^~
>> kernel/sched/fair.c:3047:48: error: 'struct rq' has no member named 'cfs_tasks'
3047 | (*list_op)(&se->group_node, &rq->cfs_tasks);
| ^~
At top level:
kernel/sched/fair.c:3038:1: warning: 'adjust_rq_cfs_tasks' defined but not used [-Wunused-function]
3038 | adjust_rq_cfs_tasks(void (*list_op)(struct list_head *, struct list_head *),
| ^~~~~~~~~~~~~~~~~~~vim +3045 kernel/sched/fair.c
3036
3037 static void
3038 adjust_rq_cfs_tasks(void (*list_op)(struct list_head *, struct list_head *),
3039 struct rq *rq,
3040 struct sched_entity *se)
3041 {
3042 struct cfs_rq *cfs_rq = cfs_rq_of(se);
3043
3044 if (task_has_idle_policy(task_of(se)) || tg_is_idle(cfs_rq->tg))
> 3045 (*list_op)(&se->group_node, &rq->cfs_idle_tasks); 3046 else > 3047 (*list_op)(&se->group_node, &rq->cfs_tasks);
3048 }
3049
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp