From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752820AbcD2Td1 (ORCPT ); Fri, 29 Apr 2016 15:33:27 -0400 Received: from foss.arm.com ([217.140.101.70]:53140 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752356AbcD2TdW (ORCPT ); Fri, 29 Apr 2016 15:33:22 -0400 From: Dietmar Eggemann To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Morten Rasmussen Subject: [PATCH 5/7] sched/fair: Remove cpu_avg_load_per_task() Date: Fri, 29 Apr 2016 20:32:42 +0100 Message-Id: <1461958364-675-6-git-send-email-dietmar.eggemann@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461958364-675-1-git-send-email-dietmar.eggemann@arm.com> References: <1461958364-675-1-git-send-email-dietmar.eggemann@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Morten Rasmussen 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 --- 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