From nobody Mon Feb 9 13:54:09 2026 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94C8B1BD501 for ; Tue, 6 Aug 2024 08:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934776; cv=none; b=hFb+p4Eb7Qqw30IfnGeWJdX06xiRUjSgjNvQKg5c88YJ/EtwP6mzv682jhBOreXEEIHtnFhlqI643DgBhayfv1vGBhOlY6Fv5jMpZDxNcIsf2yj7rEYD+hLHb3HKhkojnKBquXi068IaNOmuLLCxE1mtxQS8Hq3dE03+40ZBX4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934776; c=relaxed/simple; bh=6JnnqaIXe7PHt7I+mVGT45OA30w7a2TRSyVk4JkpKLM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EySYEWQeP0ucQn+0P3oMCNrM2lJd7p5Bny2X8sUbDWdXXA3Htm0TDyS/4H0DqFLuUQKi+ONbcDvHajyE6IQrOF0n+cKJRPoQrrl12dudwY3I3nbSgNoQ+UNG56/ERaXtxGMfufVp+UfEhYaeyXthNbCOdQ/3ETdJ92m/pKrRVpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WdRyp5JJdzfZtB; Tue, 6 Aug 2024 16:57:38 +0800 (CST) Received: from kwepemd200014.china.huawei.com (unknown [7.221.188.8]) by mail.maildlp.com (Postfix) with ESMTPS id 14C9C180105; Tue, 6 Aug 2024 16:59:32 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by kwepemd200014.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 6 Aug 2024 16:59:31 +0800 From: Yicong Yang To: , , , , , , , , , CC: , , , , , , , , , , , Subject: [PATCH v5 2/4] arch_topology: Support SMT control for OF based system Date: Tue, 6 Aug 2024 16:53:18 +0800 Message-ID: <20240806085320.63514-3-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20240806085320.63514-1-yangyicong@huawei.com> References: <20240806085320.63514-1-yangyicong@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemd200014.china.huawei.com (7.221.188.8) Content-Type: text/plain; charset="utf-8" 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 75fcb75d5515..95513abd664f 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -531,6 +532,16 @@ static int __init get_cpu_for_node(struct device_node = *node) return cpu; } =20 +static void __init update_smt_num_threads(unsigned int num_threads) +{ + static unsigned int max_smt_thread_num =3D 1; + + if (num_threads > max_smt_thread_num) { + max_smt_thread_num =3D num_threads; + cpu_smt_set_num_threads(max_smt_thread_num, max_smt_thread_num); + } +} + static int __init parse_core(struct device_node *core, int package_id, int cluster_id, int core_id) { @@ -561,6 +572,8 @@ static int __init parse_core(struct device_node *core, = int package_id, i++; } while (1); =20 + update_smt_num_threads(i); + cpu =3D get_cpu_for_node(core); if (cpu >=3D 0) { if (!leaf) { --=20 2.24.0