From patchwork Tue Nov 14 04:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 164717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1635295vqg; Mon, 13 Nov 2023 20:05:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaZAaHmUQrisUN9uc9crawvcYugt3m3GauFUNFSOSd8QgrQkzsB0rNi5//Kj6+cYAm2CJp X-Received: by 2002:a05:6870:fb87:b0:1e9:bd5c:ae40 with SMTP id kv7-20020a056870fb8700b001e9bd5cae40mr11896218oab.38.1699934700484; Mon, 13 Nov 2023 20:05:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699934700; cv=none; d=google.com; s=arc-20160816; b=yYLvX2qKqLv28jIjIKAhHRXextn8iwdgvJ2QD32G8SSDAYSmzYUWyQfW1iRQISQCEJ WFnEhJVV99O+DjDQq7HxU4P39VFkLZIMThYFKn0jkfWzhLZZUC/sRII3541UBELH9kkB CQOJsi6m1HZ2UyEpv/is0sGlL5KQbKr4s4wpaJiyA4Wl+axQu3KPV8GqxX3UPnQm4DM0 WENqa8vq0Ho8R5xU4O8a1UnvtFF+PD+sRt1rsnAOU9Wes+OJ1GdxoJXoodHbKj163AXB 4uNJ7IT36hEAIp6YW/soWqq+F60Q2bxpnkDMm2F5QWGa6nvyVkLbcw725peO7Nnd+yRl BokQ== 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=sj73GfBXe/BwMfpQHDa6N0NmBrbO1mzMKorLkWovCHTOL6LgPYWeeVAg/Fi5c4uus2 azkYmtg212IycsQ9X6Bsf6TDRyPzgdLqf+gWauf8QYR68JhUy8WP7APJ6pZUyO/53d/N EFRBakqmACQf1duNZIjD29IDr1wSnKw9H4xDDeUhGxBwFmPsJsaA8p/OSR3pu9MjCqgx gw6bMs99zhRdUPyxyjTPO17mPME4T09wYlAq3tWr3RoaHn/cXe6kv8nlWq34DFmZRlSw W3J+Pu5/Tbj0LBaIG2xylbYY117RKa0p6velG/jrUBPIc6KKLv1ExO7YI7BQyfXa66MG qRSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id c1-20020aa78e01000000b006bf2e5f0841si6786409pfr.393.2023.11.13.20.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 20:05:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 91DE780236DB; Mon, 13 Nov 2023 20:04:59 -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 S232047AbjKNEEo (ORCPT + 30 others); Mon, 13 Nov 2023 23:04:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjKNEEb (ORCPT ); Mon, 13 Nov 2023 23:04:31 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C590D45 for ; Mon, 13 Nov 2023 20:04:26 -0800 (PST) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4STt2x0HVNzvQh4; Tue, 14 Nov 2023 12:04:09 +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.31; Tue, 14 Nov 2023 12:04:24 +0800 From: Yicong Yang To: , , , CC: , , , , , , , Subject: [PATCH v3 3/4] arm64: topology: Support SMT control on ACPI based system Date: Tue, 14 Nov 2023 12:01:09 +0800 Message-ID: <20231114040110.54590-4-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20231114040110.54590-1-yangyicong@huawei.com> References: <20231114040110.54590-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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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]); Mon, 13 Nov 2023 20:04:59 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782510728047522932 X-GMAIL-MSGID: 1782510728047522932 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