From patchwork Fri Apr 9 06:21:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 49770 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 0DFE2B7F5D for ; Fri, 9 Apr 2010 16:21:39 +1000 (EST) Received: by ozlabs.org (Postfix) id 23BE6B7D0A; Fri, 9 Apr 2010 16:21:19 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 0CBBBB7CF7; Fri, 9 Apr 2010 16:21:19 +1000 (EST) Received: by localhost.localdomain (Postfix, from userid 1000) id D4096CBB6C; Fri, 9 Apr 2010 16:21:18 +1000 (EST) To: Peter Zijlstra , Benjamin Herrenschmidt From: Michael Neuling Date: Fri, 09 Apr 2010 16:21:18 +1000 Subject: [PATCH 1/5] sched: fix capacity calculations for SMT4 In-Reply-To: <1270794078.794237.347827867455.qpush@pale> Message-Id: <20100409062118.D4096CBB6C@localhost.localdomain> Cc: linuxppc-dev@ozlabs.org, Ingo Molnar , Gautham R Shenoy , linux-kernel@vger.kernel.org, Suresh Siddha X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org When calculating capacity we use the following calculation: capacity = DIV_ROUND_CLOSEST(power, SCHED_LOAD_SCALE); In SMT2, power will be 1178/2 (provided we are not scaling power with freq say) and SCHED_LOAD_SCALE will be 1024, resulting in capacity being 1. With SMT4 however, power will be 1178/4, hence capacity will end up as 0. Fix this by ensuring capacity is always at least 1 after this calculation. Signed-off-by: Michael Neuling --- I'm not sure this is the correct fix but this works for me. Original post here: http://lkml.org/lkml/2010/3/30/884 --- kernel/sched_fair.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) Index: linux-2.6-ozlabs/kernel/sched_fair.c =================================================================== --- linux-2.6-ozlabs.orig/kernel/sched_fair.c +++ linux-2.6-ozlabs/kernel/sched_fair.c @@ -1482,6 +1482,7 @@ static int select_task_rq_fair(struct ta } capacity = DIV_ROUND_CLOSEST(power, SCHED_LOAD_SCALE); + capacity = max(capacity, 1UL); if (tmp->flags & SD_POWERSAVINGS_BALANCE) nr_running /= 2; @@ -2488,6 +2489,7 @@ static inline void update_sg_lb_stats(st sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power, SCHED_LOAD_SCALE); + sgs->group_capacity = max(sgs->group_capacity, 1UL); } /** @@ -2795,9 +2797,11 @@ find_busiest_queue(struct sched_group *g for_each_cpu(i, sched_group_cpus(group)) { unsigned long power = power_of(i); - unsigned long capacity = DIV_ROUND_CLOSEST(power, SCHED_LOAD_SCALE); + unsigned long capacity; unsigned long wl; + capacity = max(DIV_ROUND_CLOSEST(power, SCHED_LOAD_SCALE), 1UL); + if (!cpumask_test_cpu(i, cpus)) continue;