[PATCH 5/7] sched/fair: Remove cpu_avg_load_per_task()

From: Dietmar Eggemann
Date: Fri Apr 29 2016 - 15:33:29 EST


From: Morten Rasmussen <morten.rasmussen@xxxxxxx>

cpu_avg_load_per_task() is called in situations where the local
sched_group currently has no runnable tasks according to the group
statistics (sum of rq->cfs.h_nr_running) to calculate the local
load_per_task based on the destination cpu average load_per_task. Since
group has no tasks neither will env->dst_cpu as it is part of the local
sched_group. In this case the function will always return zero which is
also the value of the local load_per_task.

The only case where cpu_avg_load_per_task() might make a difference is
if another cpu places a task on env->dst_cpu after the group statistics
was gathered but before this bit of code is reached during an
idle_balance().

This race doesn't seem to be taken into account elsewhere, so the
function call doesn't seem to have any effect and should be safe to
remove.

Signed-off-by: Morten Rasmussen <morten.rasmussen@xxxxxxx>
---
kernel/sched/fair.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index dc4828bbe50d..e68b9eb5cb97 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4797,18 +4797,6 @@ static unsigned long capacity_orig_of(int cpu)
return cpu_rq(cpu)->cpu_capacity_orig;
}

-static unsigned long cpu_avg_load_per_task(int cpu)
-{
- struct rq *rq = cpu_rq(cpu);
- unsigned long nr_running = READ_ONCE(rq->cfs.h_nr_running);
- unsigned long load_avg = weighted_cpuload(cpu);
-
- if (nr_running)
- return load_avg / nr_running;
-
- return 0;
-}
-
static void record_wakee(struct task_struct *p)
{
/*
@@ -6922,9 +6910,8 @@ void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds)
local = &sds->local_stat;
busiest = &sds->busiest_stat;

- if (!local->sum_nr_running)
- local->load_per_task = cpu_avg_load_per_task(env->dst_cpu);
- else if (busiest->load_per_task > local->load_per_task)
+ if (local->sum_nr_running &&
+ busiest->load_per_task > local->load_per_task)
imbn = 0;

scaled_busy_load_per_task =
--
1.9.1