From patchwork Fri Mar 28 13:22:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 27283 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CB6A220062 for ; Fri, 28 Mar 2014 13:24:59 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf11679099yha.3 for ; Fri, 28 Mar 2014 06:24:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=ANUFp36JOrTZ7/YPVCNcJdqu3Kf8A8LZfje11NRp/tY=; b=aKWDbv3HPw/Kp6j3oAMXNDzq4Z09kv+mLyuSwvE9+gKl0L4xq0wyLqOrQOtVj7M2oi B8KvXwobmthuhqFntofHutKsVU0i7IiYi9nE0mMZmE75CpWyXqtljN9PoAzFO3gAyAQy TC48FKyvkHKi4D/FBobGTy+54xDZg9v5FQvAhOPaYz2Jlb1HWOXiQUturmCVPOhb4h5z XQxFzOiE/+txG5VlZRzKpl/q7cqMowLzBv8zv0SllO3Nq3cNeqNflvDZ5WuAcmI8fDll /QfuwKK/QX5Sht18zByjsaEaCjSVKg7+9PiO+q/XekjsHuVFuCoeJ+u1oC67YbSt2W8/ Z/Rw== X-Gm-Message-State: ALoCoQktugkqzXIjHSFQmpC5zfGrNZ5bqHMIaau1nSwVNCYIagLy9hpSLcwZ3Ol0cvAwQfw0yB7O X-Received: by 10.224.95.9 with SMTP id b9mr3140124qan.2.1396013099551; Fri, 28 Mar 2014 06:24:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.73 with SMTP id 67ls1520327qga.18.gmail; Fri, 28 Mar 2014 06:24:59 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr7213014vcm.11.1396013099415; Fri, 28 Mar 2014 06:24:59 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id gs7si1242028vdc.56.2014.03.28.06.24.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 06:24:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lg15so5949033vcb.30 for ; Fri, 28 Mar 2014 06:24:59 -0700 (PDT) X-Received: by 10.221.40.10 with SMTP id to10mr1486414vcb.22.1396013099313; Fri, 28 Mar 2014 06:24:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp8408vcv; Fri, 28 Mar 2014 06:24:58 -0700 (PDT) X-Received: by 10.68.180.66 with SMTP id dm2mr8483971pbc.143.1396013098552; Fri, 28 Mar 2014 06:24:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uc9si3683536pac.253.2014.03.28.06.24.57; Fri, 28 Mar 2014 06:24:57 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150AbaC1NYa (ORCPT + 27 others); Fri, 28 Mar 2014 09:24:30 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:53340 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbaC1NY0 (ORCPT ); Fri, 28 Mar 2014 09:24:26 -0400 Received: by mail-wg0-f48.google.com with SMTP id l18so3607866wgh.19 for ; Fri, 28 Mar 2014 06:24:25 -0700 (PDT) X-Received: by 10.180.96.66 with SMTP id dq2mr12595538wib.54.1396013065131; Fri, 28 Mar 2014 06:24:25 -0700 (PDT) Received: from lmenx30s.lme.st.com (LPuteaux-656-01-48-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPSA id q2sm7237157wix.5.2014.03.28.06.24.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 06:24:24 -0700 (PDT) From: Vincent Guittot To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org Cc: preeti@linux.vnet.ibm.com, Morten.Rasmussen@arm.com, efault@gmx.de, linaro-kernel@lists.linaro.org, Vincent Guittot Subject: [RFC 3/4] sched: fix computed capacity for HMP Date: Fri, 28 Mar 2014 14:22:28 +0100 Message-Id: <1396012949-6227-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1396012949-6227-1-git-send-email-vincent.guittot@linaro.org> References: <1396012949-6227-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vincent.guittot@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The current sg_capacity solves the ghost cores issue for SMT system and cluster made of big cores which have a cpu_power above SCHED_POWER_SCALE at core level. But it still removes some real cores of a cluster made of LITTLE cores which have a cpu_power below SCHED_POWER_SCALE. Instead of using the power_orig to detect SMT system and compute a smt factor that will be used to calculate the real number of cores, we set a core_fct field when building the sched_domain topology. We can detect SMT system thanks to SD_SHARE_CPUPOWER flag and set core_fct to know how many CPUs per core we have. The core_fct will ensure that sg_capacity will return cores capacity of a SMT system and will not remove any real core of LITTLE cluster. This method also fixes a use case where the capacity of a SMT system was overrated. Let take the example of a system made of 8 cores HT system: At CPU level, sg_capacity is cap to a maximum capacity of 8 whereas DIV_ROUND_CLOSEST(power, SCHED_POWER_SCALE) returns 9. ((589*16) / 1024) = 9.3 Now if 2 CPUs (1 core) are fully loaded by rt tasks, sg_capacity still returns a capacity of 8 whereas it should return a capacity of 7. This happen because DIV_ROUND_CLOSEST(power, SCHED_POWER_SCALE) is still above 7.5: ((589*14) / 1024) = 8.05 Signed-off-by: Vincent Guittot --- kernel/sched/core.c | 7 +++++++ kernel/sched/fair.c | 6 ++---- kernel/sched/sched.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f9d9776..5b20b27 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5844,6 +5844,13 @@ static void init_sched_groups_power(int cpu, struct sched_domain *sd) WARN_ON(!sg); + if (!sd->child) + sg->core_fct = 1; + else if (sd->child->flags & SD_SHARE_CPUPOWER) + sg->core_fct = cpumask_weight(sched_group_cpus(sg)); + else + sg->core_fct = sd->child->groups->core_fct; + do { sg->group_weight = cpumask_weight(sched_group_cpus(sg)); sg = sg->next; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ed42061..7387c05 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5773,12 +5773,10 @@ static inline int sg_capacity(struct lb_env *env, struct sched_group *group) power = group->sgp->power; power_orig = group->sgp->power_orig; cpus = group->group_weight; + smt = group->core_fct; - /* smt := ceil(cpus / power), assumes: 1 < smt_power < 2 */ - smt = DIV_ROUND_UP(SCHED_POWER_SCALE * cpus, power_orig); - capacity = cpus / smt; /* cores */ + capacity = DIV_ROUND_CLOSEST(power * cpus, power_orig * smt); - capacity = min_t(unsigned, capacity, DIV_ROUND_CLOSEST(power, SCHED_POWER_SCALE)); if (!capacity) capacity = fix_small_capacity(env->sd, group); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index c9007f2..46c3784 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -759,7 +759,7 @@ struct sched_group { struct sched_group *next; /* Must be a circular list */ atomic_t ref; - unsigned int group_weight; + unsigned int group_weight, core_fct; struct sched_group_power *sgp; /*