From patchwork Tue Nov 21 09:26:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 167586 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp499921vqb; Tue, 21 Nov 2023 01:29:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGw3+BNCTiAZjGWtSqQgpGbZt+AZ3yP01eKRj/jsfSc+otlkTt5gAZCK32xcn3WAyB8RqI8 X-Received: by 2002:a9d:7851:0:b0:6c6:4843:2abc with SMTP id c17-20020a9d7851000000b006c648432abcmr11474766otm.18.1700558988076; Tue, 21 Nov 2023 01:29:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700558988; cv=none; d=google.com; s=arc-20160816; b=kxOykASNf8AY8htOwkKJhQZR9Fv1Evi5IJxKEeHIseYypTDWgSL5WDjCmEor6j6RyV tQ+Wpdm9O4eac4+c+I7c7C6fc46CgEzZObNxnF4OZE+4Z332d8+MM4MeG0PvOIBRYJgQ 51cL/+0wuYSslVILYPJQXuUuIEf5PmUg62V0xxqrF6doTRQLZxur3wiHecibsyXiGkTu +P6rZxydAGjfHrZRoehSqmoxw+jYleA5FG995a4613bSdeb03k5QPABhshazc6TxwkzJ Gj1TZBECv2wiIclx036h9WgtuPsImKx3ks46JxiJ1LN4a2f0TOXuyl8KYyNAc7CAmWeR EQYg== 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=qdn/c2ldV6pRMP6ABZUKaVNPGYAjT0cccb5LyUh6pmw=; fh=3iB9MPM7gOV8iaw6nlpksJFY47xoJvfTkJIkOXUlBK4=; b=ooVkvWoLAqTviRB16ENYz4ycR/46KIHCPK1n9B3RJJ6BJz9yPziEOmfKUowAmXK1Sp w6DQgIUrpDe9Q+Q2WGl0VkuviNekmmBinA3tmDr4l0mnLdwHpDNVJXq76BEqOHIZZgt6 5mPTRnDMUoE9xRYmGi4WQTXwA9szjGOQkNjHUTeRVNH/X1mdCNJ5UTd4WdOfeTNgkn0T //asuy/QwSmNr2AtW/HtcbMCdE3ZOfawqXUqzY9i7IGQO5Jmmln23WYKr279cStAb9tt 78xL2wQGIA7KyyHtCP+ZYbHVe9egYpw4xbxq+8Ou+Fs+iVwkyXYgzlZOIKTI+pT3g35D TrMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id g16-20020a635650000000b005b861478b70si9741616pgm.341.2023.11.21.01.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:29:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id DCCD480CCDA7; Tue, 21 Nov 2023 01:29:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232600AbjKUJ3f (ORCPT + 99 others); Tue, 21 Nov 2023 04:29:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232033AbjKUJ3c (ORCPT ); Tue, 21 Nov 2023 04:29:32 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3DFF122 for ; Tue, 21 Nov 2023 01:29:24 -0800 (PST) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SZJwT4GGSzvQwK; Tue, 21 Nov 2023 17:28:57 +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 3/4] arm64: topology: Support SMT control on ACPI based system Date: Tue, 21 Nov 2023 17:26:01 +0800 Message-ID: <20231121092602.47792-4-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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 01:29:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783165341242862071 X-GMAIL-MSGID: 1783165341242862071 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 notify the arch_topology for supporting SMT control. Signed-off-by: Yicong Yang --- arch/arm64/kernel/topology.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 817d788cd866..0dc360c32ec8 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -43,11 +44,16 @@ static bool __init acpi_cpu_is_threaded(int cpu) */ int __init parse_acpi_topology(void) { + int thread_num, max_smt_thread_num = 1; + struct xarray core_threads; int cpu, topology_id; + void *entry; if (acpi_disabled) return 0; + xa_init(&core_threads); + for_each_possible_cpu(cpu) { topology_id = find_acpi_cpu_topology(cpu, 0); if (topology_id < 0) @@ -57,6 +63,20 @@ int __init parse_acpi_topology(void) cpu_topology[cpu].thread_id = topology_id; topology_id = find_acpi_cpu_topology(cpu, 1); cpu_topology[cpu].core_id = topology_id; + + entry = xa_load(&core_threads, topology_id); + if (!entry) { + xa_store(&core_threads, topology_id, + xa_mk_value(1), GFP_KERNEL); + } else { + thread_num = 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 = thread_num; + } } else { cpu_topology[cpu].thread_id = -1; cpu_topology[cpu].core_id = topology_id; @@ -67,6 +87,9 @@ int __init parse_acpi_topology(void) cpu_topology[cpu].package_id = topology_id; } + topology_smt_set_num_threads(max_smt_thread_num); + + xa_destroy(&core_threads); return 0; } #endif