Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp14886727ybl; Mon, 30 Dec 2019 19:52:59 -0800 (PST) X-Google-Smtp-Source: APXvYqw5/fP+2vSDnenaBgJbAHVlEfoP7s0pAZGsh/fu6G51xJHTz2s0ubiiFOxctSjKp612rgrg X-Received: by 2002:a05:6830:4a4:: with SMTP id l4mr78837598otd.91.1577764379480; Mon, 30 Dec 2019 19:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577764379; cv=none; d=google.com; s=arc-20160816; b=Q1f+xflcWzLBvBoabweHUzF8/LaVgSGLNRuNqjErwYVO7kpoHRh1PFDLEURjqGlDFU 56xn1tvonTbHDdJaegwhmnZW5QMtfK1gDxiWAcuZfQXvVF4bg7owOe8SUWfVAc91lsaF SZo4qYIfKpJ+AYX7C0CJo4La5y8yrApElLEdJCdeL++DjcJWUD23HxZWUmk0S40lCYyz 5WVQVn1mSb/pDuuOQ52Vr8LFWhBPPEuQm0grIWqrCTh8yTIuk9ZoLd1Irngn3KOvPJWF GyiUuM6nSvQNMCx2IwKFUvOynVJSNZwNAbWdUDPTmpz6kDAnB1Q1jkRhO2VstKfDigsB zX4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=LxqW63gNt+zxxT7StUjJBELGbfxi8smcFBc9U8y/oWA=; b=RjefAo3S+xrtMhsia3DmQw6QV6X9Ug8iKL8syY0Sb3Lrlwamkbw4j7bi7P2AyYyosW xDZv2MzR8TZBXuxUBlXwjF6UzesXbyVKPEYPVbTSfKi8ynQ85lWbBhBD58EGLPSPQzwH rkEEViQer/sCd99Bu0N/Zz+ERJn4O5lB7BLARpwrEVp2ZhIs05rNqB2hewPWbLZHfk4K OsLlrDB/swtddF7A6pMTmmndO5u5iPxhBaT2zWrarQKZgn1iBU19YJvTBOJYTi//Viw+ hWYpgdJ3jOWIKgmj/P09NREJ0vbN60pcAvCczlusIrRmFfCYql3aMs7svsSxeRgLPlYI EVkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t0MQrtdI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si20920723otr.140.2019.12.30.19.52.46; Mon, 30 Dec 2019 19:52: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t0MQrtdI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbfLaDv2 (ORCPT + 99 others); Mon, 30 Dec 2019 22:51:28 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43434 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbfLaDv2 (ORCPT ); Mon, 30 Dec 2019 22:51:28 -0500 Received: by mail-pg1-f195.google.com with SMTP id k197so18986971pga.10 for ; Mon, 30 Dec 2019 19:51:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=LxqW63gNt+zxxT7StUjJBELGbfxi8smcFBc9U8y/oWA=; b=t0MQrtdIJr5pIctu01WazQGkAdXvUFIB9grH2WFsfV9MlDQXmFJNNJJgt8nfqq0BNp BHahrrVFwiz9LA5ZRCQY+KO0Rt3UTP7gx0sN+u9IdbgctcIjpjaBthxp+ZPScBbZ2Hnr LZ98mmCd/rUMjQAFvU/G02i7Bf1hpNonxt/NzzD4zzURL4dofxhMQcTUiBk2myZ7MNLw DkunLCpi5Gmu5JbRAc3nQRf1oR65hYgUjhvHmYnUazWwU6o4uFYqDrC9IcqA3LpePLuJ IHRbUhZhjhXTtrA0U4L2kS3VCBkEHzoJL0Tn6CFLq6iotbW2Xq05OHfoHpY+RlwQzufj NLsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=LxqW63gNt+zxxT7StUjJBELGbfxi8smcFBc9U8y/oWA=; b=TPhZyhM47UeNSkmc0qdGR45zPaJRkYwMbZB8mlKpbZvb+igBEhXFBPHOH4pd+jRcRb HIB5ZH9zhyuMW+NHsG5BB2o219AlrOaMyDUkKIvEPOxNDuZOswPo7NPMYdBwtCeZ+4im kgWpuC/FmmpuYCKipbbpls5nkyL6FPX7pjS+YVC1lNxcUBH3yhDULqGwtuNRJUawNfgy xOJmO7+ep4+5XR/y+gDqJbSbhiftzTcBj4hCbo7M9aWQStHwMuZFlLcODZMenc/0EaXo set6klH4korovePtZ7Ggxr0mTmSkeFilZLfnf2GQGqiPZbhf4Qyd3l6AvyqzgCbTYVgY CYdw== X-Gm-Message-State: APjAAAVKsWC6BuspkAHIAmXvWUTfXC2RNf7aeVRQKKRJsnnUdU+U6Id+ qxjGH34cHnyfNZBCA2eXS2hS0o0d X-Received: by 2002:a63:590e:: with SMTP id n14mr74433933pgb.10.1577764287205; Mon, 30 Dec 2019 19:51:27 -0800 (PST) Received: from iZj6chx1xj0e0buvshuecpZ ([47.75.1.235]) by smtp.gmail.com with ESMTPSA id y21sm32635523pfm.136.2019.12.30.19.51.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Dec 2019 19:51:26 -0800 (PST) Date: Tue, 31 Dec 2019 11:51:22 +0800 From: Peng Liu To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, qais.yousef@arm.com, morten.rasmussen@arm.com Subject: [PATCH] sched/fair: fix sgc->{min,max}_capacity miscalculate Message-ID: <20191231035122.GA10020@iZj6chx1xj0e0buvshuecpZ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. sgc->capacity is the *SUM* of all CPU's capacity in the group. sgc->{min,max}_capacity are the sg per-cpu variables. Compare with sgc->capacity to get sgc->{min,max}_capacity makes no sense. Instead, we should compare one by one in each iteration to get sgc->{min,max}_capacity of the group. Signed-off-by: Peng Liu --- kernel/sched/fair.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2d170b5da0e3..97b164fcda93 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7795,6 +7795,7 @@ 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 cap; /* * build_sched_domains() -> init_sched_groups_capacity() @@ -7808,14 +7809,16 @@ void update_group_capacity(struct sched_domain *sd, int cpu) * causing divide-by-zero issues on boot. */ if (unlikely(!rq->sd)) { - capacity += capacity_of(cpu); + cap = capacity_of(cpu); + capacity += cap; + min_capacity = min(cap, min_capacity); + max_capacity = max(cap, max_capacity); } else { sgc = rq->sd->groups->sgc; capacity += sgc->capacity; + min_capacity = min(sgc->min_capacity, min_capacity); + max_capacity = max(sgc->max_capacity, max_capacity); } - - min_capacity = min(capacity, min_capacity); - max_capacity = max(capacity, max_capacity); } } else { /* -- 2.17.1