Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8849477ybl; Fri, 17 Jan 2020 02:10:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzMPGydNzCm4SZ5prBz1wwszi+jQiX16i4jELE9/6ylHq95Az4gRrYrfucAMRhc0xxNxGYx X-Received: by 2002:a54:4501:: with SMTP id l1mr2665763oil.101.1579255799933; Fri, 17 Jan 2020 02:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579255799; cv=none; d=google.com; s=arc-20160816; b=jT4zmCSYfHfE/SLGowrBeIN58dk3P+Fx1pvrcnuZyX1XJx1UgqjCc5pBgmwQlJaF9w YA0mpTrO+2STPd7x8Gx2Ti8KTdRUxVxiPpjapwGHGaxXIX2MHl6AL8lyJ0eDhglQP8MZ angvlZ8T//V3UwOdpkG0MwPQY67k2gvKBggFDQerJiz7qYJrogFRJmY/obdqO3Hg0QZF AV1EUNOq/HtFbNde6Hh1/Czpc6sg0lTOxRS0zBB1qN9MhCOJdiM8Jzxo7Hixm52xlbgk +0kYYf5S5LdVeDYZFEUTpqlWDjiFY7j34dpuLWn3ASldw9VU/3NqXtL11HcDbytZBMaz OMrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=Wkrk9seCrkgKSSR42n2RwrDZkXdIivTCzKSxCSnM2rY=; b=QIKY4lOkwwIBc7M4WdI++usVeUTu6dBKzHjdcpHlsmhTPUIyIBvBsc9q2fmsE27ULe DOLAyKknR6dhfSmtKzi5ADtfmCJqw75LItjrkzG1wdTlmn4s1WFy18UFg7bRMZcIki8V DYve+1UIvcb6eXydOmupUsxnd0mikbrjuLP21FAOPnnbD01jb/9iYs0IvCs2iIpTNL7s AzfY5nh996Nhio2LiAmUGhkO2dmo2ZCmuZCI4QQmHzxT0/jsdL/pk4PaePOmlt7SbUTQ lXrS96ZW5y2Mktrn78BX20iqYayxbnjtd91VOURv3TFWYBy3zCiCqNCuUmCj2iUdbvD+ ADkw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si13408023oih.217.2020.01.17.02.09.48; Fri, 17 Jan 2020 02:09:59 -0800 (PST) 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 S1728892AbgAQKIw (ORCPT + 99 others); Fri, 17 Jan 2020 05:08:52 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:55338 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727243AbgAQKIs (ORCPT ); Fri, 17 Jan 2020 05:08:48 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1isOYV-0005RS-27; Fri, 17 Jan 2020 11:08:43 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 6A42F1C19CF; Fri, 17 Jan 2020 11:08:41 +0100 (CET) Date: Fri, 17 Jan 2020 10:08:41 -0000 From: "tip-bot2 for Peng Liu" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Fix sgc->{min,max}_capacity calculation for SD_OVERLAP Cc: Peng Liu , "Peter Zijlstra (Intel)" , Valentin Schneider , x86 , LKML In-Reply-To: <20200104130828.GA7718@iZj6chx1xj0e0buvshuecpZ> References: <20200104130828.GA7718@iZj6chx1xj0e0buvshuecpZ> MIME-Version: 1.0 Message-ID: <157925572126.396.16039413045911352646.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 4c58f57fa6e93318a0899f70d8b99fe6bac22ce8 Gitweb: https://git.kernel.org/tip/4c58f57fa6e93318a0899f70d8b99fe6bac22ce8 Author: Peng Liu AuthorDate: Sat, 04 Jan 2020 21:08:28 +08:00 Committer: Peter Zijlstra CommitterDate: Fri, 17 Jan 2020 10:19:21 +01:00 sched/fair: Fix sgc->{min,max}_capacity calculation for SD_OVERLAP commit bf475ce0a3dd ("sched/fair: Add per-CPU min capacity to sched_group_capacity") introduced per-cpu min_capacity. commit e3d6d0cb66f2 ("sched/fair: Add sched_group per-CPU max capacity") introduced per-cpu max_capacity. In the SD_OVERLAP case, the local variable 'capacity' represents the sum of CPU capacity of all CPUs in the first sched group (sg) of the sched domain (sd). It is erroneously used to calculate sg's min and max CPU capacity. To fix this use capacity_of(cpu) instead of 'capacity'. The code which achieves this via cpu_rq(cpu)->sd->groups->sgc->capacity (for rq->sd != NULL) can be removed since it delivers the same value as capacity_of(cpu) which is currently only used for the (!rq->sd) case (see update_cpu_capacity()). An sg of the lowest sd (rq->sd or sd->child == NULL) represents a single CPU (and hence sg->sgc->capacity == capacity_of(cpu)). Signed-off-by: Peng Liu Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Link: https://lkml.kernel.org/r/20200104130828.GA7718@iZj6chx1xj0e0buvshuecpZ --- kernel/sched/fair.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 32c5421..e84723c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7802,29 +7802,11 @@ void update_group_capacity(struct sched_domain *sd, int cpu) */ for_each_cpu(cpu, sched_group_span(sdg)) { - struct sched_group_capacity *sgc; - struct rq *rq = cpu_rq(cpu); + unsigned long cpu_cap = capacity_of(cpu); - /* - * build_sched_domains() -> init_sched_groups_capacity() - * gets here before we've attached the domains to the - * runqueues. - * - * Use capacity_of(), which is set irrespective of domains - * in update_cpu_capacity(). - * - * This avoids capacity from being 0 and - * causing divide-by-zero issues on boot. - */ - if (unlikely(!rq->sd)) { - capacity += capacity_of(cpu); - } else { - sgc = rq->sd->groups->sgc; - capacity += sgc->capacity; - } - - min_capacity = min(capacity, min_capacity); - max_capacity = max(capacity, max_capacity); + capacity += cpu_cap; + min_capacity = min(cpu_cap, min_capacity); + max_capacity = max(cpu_cap, max_capacity); } } else { /*