From nobody Mon Feb 9 18:21:39 2026 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (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 4D3701BD507 for ; Tue, 6 Aug 2024 08:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934778; cv=none; b=l/d9pFL+L2lz9rwKHW6OC7nGMSxnAO4vzdKjjbyfGLr+3kDNj8NKqjshqyC1dCBUGDCUfDmZ+YbzZEmFJlTTVVY3pSk6XEdNcZpGFxwMoZAw4kyBwG/d3JyrxX05SOWVE04r5AHcZDPEHSMbaA9ii7bS5U0RjhSjJoMxkvHtFsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934778; c=relaxed/simple; bh=ug6TQ0Oc1jLSDCX8oHX8vABMdkpnSFcNVdIGOcgjyDQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YMA24dwWRnp+KXICpuSjK2r4RP0/iZ8obvw0oVM0zTqDEAjKMUGN/HdQNHbRRIIxhW7pzX+IAGloP3rje+6zamDvwzPZJfxhL/JhDTHgeJLsoVtfAoNIh3hBA6w4zNVK/Fv7106yZ55UnQ4Q/XDj1UnmaI1ZTjK4jEI1oopeW/Y= 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.189 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.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WdRvv15sVzQngm; Tue, 6 Aug 2024 16:55:07 +0800 (CST) Received: from kwepemd200014.china.huawei.com (unknown [7.221.188.8]) by mail.maildlp.com (Postfix) with ESMTPS id A30A118009B; 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 3/4] arm64: topology: Support SMT control on ACPI based system Date: Tue, 6 Aug 2024 16:53:19 +0800 Message-ID: <20240806085320.63514-4-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 For ACPI we'll build the topology from PPTT and we cannot directly get the SMT number of each core. Instead using a temporary xarray to record the SMT number of each core when building the topology and we can know the largest SMT number in the system. Then we can enable the support of SMT control. Signed-off-by: Yicong Yang --- arch/arm64/kernel/topology.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 1a2c72f3e7f8..f72e1e55b05e 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -15,8 +15,10 @@ #include #include #include +#include #include #include +#include =20 #include #include @@ -43,11 +45,16 @@ static bool __init acpi_cpu_is_threaded(int cpu) */ int __init parse_acpi_topology(void) { + int thread_num, max_smt_thread_num =3D 1; + struct xarray core_threads; int cpu, topology_id; + void *entry; =20 if (acpi_disabled) return 0; =20 + xa_init(&core_threads); + for_each_possible_cpu(cpu) { topology_id =3D find_acpi_cpu_topology(cpu, 0); if (topology_id < 0) @@ -57,6 +64,20 @@ int __init parse_acpi_topology(void) cpu_topology[cpu].thread_id =3D topology_id; topology_id =3D find_acpi_cpu_topology(cpu, 1); cpu_topology[cpu].core_id =3D topology_id; + + entry =3D xa_load(&core_threads, topology_id); + if (!entry) { + xa_store(&core_threads, topology_id, + xa_mk_value(1), GFP_KERNEL); + } else { + thread_num =3D xa_to_value(entry); + thread_num++; + xa_store(&core_threads, topology_id, + xa_mk_value(thread_num), GFP_KERNEL); + + if (thread_num > max_smt_thread_num) + max_smt_thread_num =3D thread_num; + } } else { cpu_topology[cpu].thread_id =3D -1; cpu_topology[cpu].core_id =3D topology_id; @@ -67,6 +88,9 @@ int __init parse_acpi_topology(void) cpu_topology[cpu].package_id =3D topology_id; } =20 + cpu_smt_set_num_threads(max_smt_thread_num, max_smt_thread_num); + + xa_destroy(&core_threads); return 0; } #endif --=20 2.24.0