Rework the locality diff code to affect all tasks, not just sticky ones and microoptimise locality_diff. This leads to improved throughput and better soft affinity overall. Fix certain config build failures courtesy of Serge Belyshev. -ck --- include/linux/sched.h | 4 ++-- kernel/sched/bfs.c | 31 ++++++++----------------------- 2 files changed, 10 insertions(+), 25 deletions(-) Index: linux-4.3-ck2/kernel/sched/bfs.c =================================================================== --- linux-4.3-ck2.orig/kernel/sched/bfs.c 2015-12-11 18:29:09.454456985 +1100 +++ linux-4.3-ck2/kernel/sched/bfs.c 2015-12-11 18:34:20.904079653 +1100 @@ -135,7 +135,7 @@ void print_scheduler_version(void) { - printk(KERN_INFO "BFS CPU scheduler v0.465 by Con Kolivas.\n"); + printk(KERN_INFO "BFS CPU scheduler v0.466 by Con Kolivas.\n"); } /* @@ -861,9 +861,9 @@ static inline bool scaling_rq(struct rq return rq->scaling; } -static inline int locality_diff(struct task_struct *p, struct rq *rq) +static inline int locality_diff(int cpu, struct rq *rq) { - return rq->cpu_locality[task_cpu(p)]; + return rq->cpu_locality[cpu]; } #else /* CONFIG_SMP */ static inline void set_cpuidle_map(int cpu) @@ -2680,20 +2680,6 @@ void account_idle_time(cputime_t cputime { } -void update_cpu_load_nohz(void) -{ -} - -#ifdef CONFIG_NO_HZ_COMMON -void calc_load_enter_idle(void) -{ -} - -void calc_load_exit_idle(void) -{ -} -#endif /* CONFIG_NO_HZ_COMMON */ - /* * Account guest cpu time to a process. * @p: the process that the cpu time gets accounted to @@ -3202,6 +3188,7 @@ task_struct *earliest_deadline_task(stru */ earliest_deadline = ~0ULL; list_for_each_entry(p, queue, run_list) { + int tcpu; u64 dl; /* Make sure cpu affinity is ok */ @@ -3219,12 +3206,10 @@ task_struct *earliest_deadline_task(stru * against its deadline when not, based on cpu cache * locality. */ - if (task_sticky(p) && task_rq(p) != rq) { - if (scaling_rq(rq)) - continue; - dl = p->deadline << locality_diff(p, rq); - } else - dl = p->deadline; + tcpu = task_cpu(p); + if (tcpu != cpu && task_sticky(p) && scaling_rq(rq)) + continue; + dl = p->deadline << locality_diff(tcpu, rq); if (deadline_before(dl, earliest_deadline)) { earliest_deadline = dl; Index: linux-4.3-ck2/include/linux/sched.h =================================================================== --- linux-4.3-ck2.orig/include/linux/sched.h 2015-12-11 18:34:13.000000000 +1100 +++ linux-4.3-ck2/include/linux/sched.h 2015-12-11 18:34:20.902079679 +1100 @@ -176,7 +176,7 @@ extern void get_iowait_load(unsigned lon extern void calc_global_load(unsigned long ticks); -#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) +#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) && !defined(CONFIG_SCHED_BFS) extern void update_cpu_load_nohz(void); #else static inline void update_cpu_load_nohz(void) { } @@ -2319,7 +2319,7 @@ static inline int set_cpus_allowed_ptr(s } #endif -#ifdef CONFIG_NO_HZ_COMMON +#if defined(CONFIG_NO_HZ_COMMON) && !defined(CONFIG_SCHED_BFS) void calc_load_enter_idle(void); void calc_load_exit_idle(void); #else