From patchwork Fri Apr 29 19:32:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 66970 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp969252qge; Fri, 29 Apr 2016 12:33:42 -0700 (PDT) X-Received: by 10.98.85.195 with SMTP id j186mr31990934pfb.50.1461958418337; Fri, 29 Apr 2016 12:33:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9si19563929paa.62.2016.04.29.12.33.38; Fri, 29 Apr 2016 12:33:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752823AbcD2Td1 (ORCPT + 29 others); 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 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 12EC3521; Fri, 29 Apr 2016 12:33:24 -0700 (PDT) Received: from e107985-lin.cambridge.arm.com (e107985-lin.cambridge.arm.com [10.1.207.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EE7E73F25F; Fri, 29 Apr 2016 12:33:20 -0700 (PDT) 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 Precedence: bulk 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(-) -- 1.9.1 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 =