From patchwork Fri Apr 29 19:32:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 66968 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp969226qge; Fri, 29 Apr 2016 12:33:38 -0700 (PDT) X-Received: by 10.66.189.65 with SMTP id gg1mr31651612pac.148.1461958417649; Fri, 29 Apr 2016 12:33:37 -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.37; Fri, 29 Apr 2016 12:33:37 -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 S1752735AbcD2TdW (ORCPT + 29 others); Fri, 29 Apr 2016 15:33:22 -0400 Received: from foss.arm.com ([217.140.101.70]:53134 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752653AbcD2TdV (ORCPT ); Fri, 29 Apr 2016 15:33:21 -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 2EC4A46D; Fri, 29 Apr 2016 12:33:23 -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 148503F25F; Fri, 29 Apr 2016 12:33:19 -0700 (PDT) From: Dietmar Eggemann To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Morten Rasmussen Subject: [PATCH 4/7] sched/fair: Clean up the logic in fix_small_imbalance() Date: Fri, 29 Apr 2016 20:32:41 +0100 Message-Id: <1461958364-675-5-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 Avoid the need to add scaled_busy_load_per_task on both sides of the if condition to determine whether imbalance has to be set to busiest->load_per_task or not. The imbn variable was introduced with commit 2dd73a4f09be ("[PATCH] sched: implement smpnice") and the original if condition was if (max_load - this_load >= busiest_load_per_task * imbn) which over time changed into the current version where scaled_busy_load_per_task is to be found on both sides of the if condition. Signed-off-by: Dietmar Eggemann --- The original smpnice implementation sets imbalance to the avg task load of the busiest sched group (sg) if the difference between the avg load of the busiest sg and the local sg is greater or equal 2 times (imbn) the avg task load of the busiest sg if there is no task running in the local sg or the avg task load of the busiest sg is smaller or equal the avg task load of the local sg. Otherwise the imbn factor is lowered to 1. imbn set to 2 makes sense when all the tasks have the same priority so in case there are n tasks on local sd there have to be n+2 tasks on the busiest sg to give load balance the chance to pull over one task. imbn set to 1 makes sense when the avg task load of the busiest sg is greater than the one of the local sg since there could be at least one task with a smaller load on the busiest sg which can be pulled over to the local sg. The current version lowered imbn effectively by one, so we use 1 instead of 2 in case the avg task load of sg_busiest isn't greater than the one of sg_local and 0 instead of 1 in the other case. This behaviour is not in sync with the explanation above on why we set imbn to certain values. kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 1.9.1 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c066574cff04..dc4828bbe50d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6915,7 +6915,7 @@ static inline void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds) { unsigned long tmp, capa_now = 0, capa_move = 0; - unsigned int imbn = 2; + unsigned int imbn = 1; unsigned long scaled_busy_load_per_task; struct sg_lb_stats *local, *busiest; @@ -6925,13 +6925,13 @@ void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds) 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) - imbn = 1; + imbn = 0; scaled_busy_load_per_task = (busiest->load_per_task * SCHED_CAPACITY_SCALE) / busiest->group_capacity; - if (busiest->avg_load + scaled_busy_load_per_task >= + if (busiest->avg_load >= local->avg_load + (scaled_busy_load_per_task * imbn)) { env->imbalance = busiest->load_per_task; return;