From patchwork Tue Nov 21 09:26:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 167587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp499949vqb; Tue, 21 Nov 2023 01:29:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJ9JfaqqmDzKAqN2/K9NEGEwb4lpTjm3rDGVa/PXFQw1JehNHkF6lZ8yladxaSKOykpR9H X-Received: by 2002:a05:6359:630e:b0:16d:f46f:16a9 with SMTP id sf14-20020a056359630e00b0016df46f16a9mr37625rwb.17.1700558991863; Tue, 21 Nov 2023 01:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700558991; cv=none; d=google.com; s=arc-20160816; b=CcFdb1yVjcQRWD/IjyeSSbzqEwcuZ4R8EaajSuMH7u/6hVpiInvv55SK+g0sXVkAN6 A1U0hNBqMa8gZXwGGsZSLb+Tw9i37fMkUhNovjHF5yjtZM+1zBEh+srOdt4thc3QlnKz mPjuF5kRv+mmm7RQ8OvqsNIR5lDC+duFy+tVDH3lD1IhdIjzkPXNhyt+xdKQGrbn+c26 vbtDPJ2Ol5aVqXE8g1id8otQFGPt5dprZ/gb6oI/IPLNYd9EAER3qYmotpyNT10Jd/U8 EK45H4RRH19G4shG9KkUMe4z8r5dt/kLQghGcNF/u7q9/pU2/GX4w+qOPOdLW1+pHrY6 flKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=eyUMLXsoIuhkBPshhbJZuVrOlIB+AoZQP17LzzWJ2aM=; fh=3iB9MPM7gOV8iaw6nlpksJFY47xoJvfTkJIkOXUlBK4=; b=TZxtygPltaJHefG3g1Aelee3uTAwx4hDe6lMfktgAESvOMlvIxlSovVP7Sx0LTTz9f GoD98mwFTMttiJLNXVVCiSvFn/DoHn/e850PEeh+S9IXmmrhDDU8LcW8PmymxnlVQAds Y2qpkSxkn32iV4VR4ZEk0N9W3r/PrmkomJxjEY4Ckb6mEx6d6GEzGl3F1cmuYq7qk+is Hm+oFV7OP997a6x0zT4zFNWpdDYUEFiVzM2CRs8FCB7AzAJmKu/KEdsZ8QBqxN0mDN85 WdVzFuOw1PyC9Yfd95Fm/w614b3Wial2nxcPOZ+XIVu9QTXejoCcozUWt3hLVNF9p+vV GJKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n186-20020a6327c3000000b005b8f24e6526si9969668pgn.234.2023.11.21.01.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:29:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 63A0C80E73C4; Tue, 21 Nov 2023 01:29:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233622AbjKUJ3k (ORCPT + 99 others); Tue, 21 Nov 2023 04:29:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232257AbjKUJ3c (ORCPT ); Tue, 21 Nov 2023 04:29:32 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4929123 for ; Tue, 21 Nov 2023 01:29:24 -0800 (PST) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SZJrw6gJ3z1P8k5; Tue, 21 Nov 2023 17:25:52 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 21 Nov 2023 17:29:20 +0800 From: Yicong Yang To: , , , CC: , , , , , , , Subject: [PATCH v4 2/4] arch_topology: Support SMT control for OF based system Date: Tue, 21 Nov 2023 17:26:00 +0800 Message-ID: <20231121092602.47792-3-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20231121092602.47792-1-yangyicong@huawei.com> References: <20231121092602.47792-1-yangyicong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 01:29:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783165345089470630 X-GMAIL-MSGID: 1783165345089470630 From: Yicong Yang On building the topology from the devicetree, we've already gotten the SMT thread number of each core. Update the largest SMT thread number to enable the SMT control. Signed-off-by: Yicong Yang --- drivers/base/arch_topology.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 3ed6bdf9460e..252a436e0c1b 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -526,6 +526,13 @@ static int __init parse_core(struct device_node *core, int package_id, i++; } while (t); + /* + * We've already gotten threads number in this core, update the SMT + * threads number when necessary. + */ + if (i > topology_smt_get_num_threads()) + topology_smt_set_num_threads(i); + cpu = get_cpu_for_node(core); if (cpu >= 0) { if (!leaf) {