From patchwork Wed May 13 20:38:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 6400091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1F6A79F374 for ; Wed, 13 May 2015 20:41:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3AD4B2028D for ; Wed, 13 May 2015 20:41:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BB6620218 for ; Wed, 13 May 2015 20:41:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YsdQk-0002cC-NZ; Wed, 13 May 2015 20:39:02 +0000 Received: from mail-qk0-f173.google.com ([209.85.220.173]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YsdQd-0002Rn-33 for linux-arm-kernel@lists.infradead.org; Wed, 13 May 2015 20:38:55 +0000 Received: by qkgx75 with SMTP id x75so36873221qkg.1 for ; Wed, 13 May 2015 13:38:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=m3TuAVqMG7Ua5znSYhkhK9CjCp0ws2w4dr7AgeFMNCM=; b=h+cmZXdmyGQBoiKT8AxJzQP05YqlVNvJNMyrwui0xVLtQWgz7JPp7FYBKZpHZsjy0V rrdf0LvfR4RqzcCtK7kYSupyz2yPlf21yTu3QHnCuVzHmbBP0Quu6caSMDj9UthWTvFF e7G4wuADyleJ6tkXiBfhC0GmkNszGxR5uiGZWmoRnbJi5XwwE0NGBVs2u8cHbhCvbbX0 PiotpiyxeVwnAy8yY2kLhy/07Xv1kwJQn1s/ndCi2GK0C0e3Rd0FCZVDu5Ok2j6JHznb v+6fG6HzDNIjErTA5TzeJrdfsQlb+gP8JWiT/+ay2nRejiSVK2xZWf8McmMc4eusXLCg TKdg== X-Gm-Message-State: ALoCoQmKY8HcxjIoKLzmnhTVmAcYGrSWHSs7KFmk3r+mU4Byjxja6lMPX27OJApKM8xagkeCulLf X-Received: by 10.55.21.224 with SMTP id 93mr1654937qkv.89.1431549510800; Wed, 13 May 2015 13:38:30 -0700 (PDT) Received: from calypso.3dsystems.internal (cpe-67-247-86-207.rochester.res.rr.com. [67.247.86.207]) by mx.google.com with ESMTPSA id r2sm16336091qkr.42.2015.05.13.13.38.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 May 2015 13:38:29 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, khilman@linaro.org, catalin.marinas@arm.com, broonie@linaro.org, vincent.guittot@linaro.org Subject: [PATCH] arm: topology: fix capacity calculation on SMP SoCs Date: Wed, 13 May 2015 16:38:23 -0400 Message-Id: <1431549503-11799-1-git-send-email-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150513_133855_251844_2E0EA1C3 X-CRM114-Status: GOOD ( 11.86 ) X-Spam-Score: -0.7 (/) Cc: tixy@linaro.org, will.deacon@arm.com, linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit sets the capacity of the average CPU in SMP systems to SCHED_CAPACITY_SCALE. Ignoring the condition "min_capacity==max_capacity" causes the function update_cpu_capacity( .. ) to generate out of range values [1]. This is because the default value of middle_capacity is used in the final calculation instead of a valid scaling factor. Incidentally, when out of range values are generated and if SCHED_FEAT(ARCH_POWER, true), the load balancing algorithm makes the wrong decisions typically overallocating work on one of the cores while leaving the others unused. [1] val > SCHED_CAPACITY_SCALE Signed-off-by: Jorge Ramirez-Ortiz --- arch/arm/kernel/topology.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 08b7847..509bc9b 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -137,14 +137,14 @@ static void __init parse_dt_topology(void) cpu_capacity(cpu) = capacity; } - /* If min and max capacities are equals, we bypass the update of the - * cpu_scale because all CPUs have the same capacity. Otherwise, we - * compute a middle_capacity factor that will ensure that the capacity + /* Compute a middle_capacity factor that will ensure that the capacity * of an 'average' CPU of the system will be as close as possible to * SCHED_CAPACITY_SCALE, which is the default value, but with the * constraint explained near table_efficiency[]. */ - if (4*max_capacity < (3*(max_capacity + min_capacity))) + if (min_capacity == max_capacity) + middle_capacity = min_capacity >> SCHED_CAPACITY_SHIFT; + else if (4*max_capacity < (3*(max_capacity + min_capacity))) middle_capacity = (min_capacity + max_capacity) >> (SCHED_CAPACITY_SHIFT+1); else