From patchwork Mon Jul 17 12:56:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 121289 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1102610vqt; Mon, 17 Jul 2023 06:13:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlFbuOynUqYeYNJmm12k/aq8kmL19y1tKxwHwHL0Dp22DBbskbhwYqn2vZtOJN1BEvGMYTN2 X-Received: by 2002:a17:90a:ff04:b0:262:ff86:ac2d with SMTP id ce4-20020a17090aff0400b00262ff86ac2dmr11396686pjb.46.1689599587102; Mon, 17 Jul 2023 06:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689599587; cv=none; d=google.com; s=arc-20160816; b=sMl/mLx5HyoOCEA7/tGBThkfGJOS3u7VfrKerbK/kqWhLqZpTW8aL0xpxCVMYw/xBI UEY96dE37K/ov2LJ3wRbnV/O0hKT9Z/hG+zFWpT/f/6fsBsJf3ATI07sKKXCCXRGuhPH L0bvZDfKg48REQIP8i43wfNyWhYD39jcz17FTAye2wwIBWK5i+9JUWVW2WUTOFtMOzZo KgWvgwsFzI7+cnZirgETb2XzgHI2k8AEWwsjmCwwN6QxsM78C/XmqT+bLmKoNZtgwo6z /xZBgPZ2spuMhPGbs5xeluifRs/61wRKwjnSd/uYefzjhJtc89dLmeEkIfS0lfp+SeJV qdDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=Eknuv9JzEkTP8q2JWBFLcMfKm/vef1f57vqL4RUF+M0=; fh=/K854cUSQ3ewyhJ+i2Nf2/n8lZlkzVHGXXExVGdP8tU=; b=gH6TdXlqb3JXHuaE0i1OMb9kY+jlCFcP2wqOJCcAkCZ41aGpL0yi+yyGwAHXbEbNli un1ywAGeSc41LsMrdbbljkV++/XqLpDkpTFJnkC5DjXldjZhQMzIYi44gMnTe7+LW1UI ToqU8lgnKd9Qs/FmaDl4uZW4vmY88rRu5SV1zNzumzaPhbJuv8OdWwXxfJedgHVxeCe7 mfTiPjnuDwcl83JUaptWxPgyMi2PFWonPTZCCPOFuIosEJMhALK+6/Ty+tYe56r6dPlQ 2w3BkX3DrevrpqZtLFjv0iCCi8Q/XfUt6d0ZaHFBIjTae8mi4cfWrK7rdkyVF9QSuqcY r08Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Dah4yfUr; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bYuPTL5a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r124-20020a632b82000000b0055bdcb7dd5csi11788105pgr.701.2023.07.17.06.12.53; Mon, 17 Jul 2023 06:13:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Dah4yfUr; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bYuPTL5a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231246AbjGQM5i (ORCPT + 99 others); Mon, 17 Jul 2023 08:57:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbjGQM5P (ORCPT ); Mon, 17 Jul 2023 08:57:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33A9319AE; Mon, 17 Jul 2023 05:56:42 -0700 (PDT) Date: Mon, 17 Jul 2023 12:56:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689598573; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Eknuv9JzEkTP8q2JWBFLcMfKm/vef1f57vqL4RUF+M0=; b=Dah4yfUr2ZAnTYLZjviQ9J5JhglZ+f8A/6WeVQ+my6VJQG99N8GIYnuYZu3HXEYrBCyFUR vDvES0375l+K6TEpo7WMlTxaYDp5yMlirF3tDPAlwSTw4avWpeMfy0y524M9YzjTkZshGW qaNgfITTqKatfhli+Z40P792PVDim4OjG3CX6pUYiAk8n/doXkAAvsKCfyL1yqUiME0xZ0 AExyPfnfvU9mfD6dhvQUkHkL/asKGTXDHT+gz2uRBshw1Ru/9CuiRgqe92QeOIS0ENfSGN ZhILAldqgvUjBB8Zm4Pov7fNCi/UbrdBRLXby/y/52nYXQgjYWHwe6BmdDfS+w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689598573; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Eknuv9JzEkTP8q2JWBFLcMfKm/vef1f57vqL4RUF+M0=; b=bYuPTL5aaW0YxGwTHpM8HZbHUT2D11h4xvWMITYeCm/y1lxhGzzK6gfqjztp1kDsxg9xsV qAYMxrVWaW2JivDA== From: "tip-bot2 for Tim C Chen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/topology: Record number of cores in sched group Cc: Tim Chen , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3C04641eeb0e95c21224352f5743ecb93dfac44654=2E1688770?= =?utf-8?q?494=2Egit=2Etim=2Ec=2Echen=40linux=2Eintel=2Ecom=3E?= References: =?utf-8?q?=3C04641eeb0e95c21224352f5743ecb93dfac44654=2E16887704?= =?utf-8?q?94=2Egit=2Etim=2Ec=2Echen=40linux=2Eintel=2Ecom=3E?= MIME-Version: 1.0 Message-ID: <168959857267.28540.7534555852542758519.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1770804919050984590 X-GMAIL-MSGID: 1771673576556569739 The following commit has been merged into the sched/core branch of tip: Commit-ID: d24cb0d9113f5932b8832533ce82351b5911ed50 Gitweb: https://git.kernel.org/tip/d24cb0d9113f5932b8832533ce82351b5911ed50 Author: Tim C Chen AuthorDate: Fri, 07 Jul 2023 15:57:01 -07:00 Committer: Peter Zijlstra CommitterDate: Thu, 13 Jul 2023 15:21:51 +02:00 sched/topology: Record number of cores in sched group When balancing sibling domains that have different number of cores, tasks in respective sibling domain should be proportional to the number of cores in each domain. In preparation of implementing such a policy, record the number of cores in a scheduling group. Signed-off-by: Tim Chen Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/04641eeb0e95c21224352f5743ecb93dfac44654.1688770494.git.tim.c.chen@linux.intel.com --- kernel/sched/sched.h | 1 + kernel/sched/topology.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 1dcea9b..9baeb1a 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1884,6 +1884,7 @@ struct sched_group { atomic_t ref; unsigned int group_weight; + unsigned int cores; struct sched_group_capacity *sgc; int asym_prefer_cpu; /* CPU of highest priority in group */ int flags; diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index d3a3b26..7cfcfe5 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1275,14 +1275,24 @@ build_sched_groups(struct sched_domain *sd, int cpu) static void init_sched_groups_capacity(int cpu, struct sched_domain *sd) { struct sched_group *sg = sd->groups; + struct cpumask *mask = sched_domains_tmpmask2; WARN_ON(!sg); do { - int cpu, max_cpu = -1; + int cpu, cores = 0, max_cpu = -1; sg->group_weight = cpumask_weight(sched_group_span(sg)); + cpumask_copy(mask, sched_group_span(sg)); + for_each_cpu(cpu, mask) { + cores++; +#ifdef CONFIG_SCHED_SMT + cpumask_andnot(mask, mask, cpu_smt_mask(cpu)); +#endif + } + sg->cores = cores; + if (!(sd->flags & SD_ASYM_PACKING)) goto next;