From patchwork Tue Jul 23 06:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13739442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23CCEC3DA63 for ; Tue, 23 Jul 2024 06:45:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A06416B0085; Tue, 23 Jul 2024 02:45:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98BF26B00AC; Tue, 23 Jul 2024 02:45:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DF276B00AD; Tue, 23 Jul 2024 02:45:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5AEB46B0085 for ; Tue, 23 Jul 2024 02:45:03 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 25542A1C54 for ; Tue, 23 Jul 2024 06:45:03 +0000 (UTC) X-FDA: 82370080086.03.A1844DB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 6AC8914002F for ; Tue, 23 Jul 2024 06:45:01 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="NVxK/dES"; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721717078; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2p09vV4kyjAbjfcBRTwBuWazo0Z2nK08XGTBaQ/j8Q4=; b=rutKnvF2+GztCWMkOr0qeuIyu9PhhHRQ7cNsdNEF7QkbYgReADf2LzfnZAy/CJwKM/+yp/ cepxD8mFPD/YWKRybTHAxY1d9WCtrmJfdTsLDZ0qzXTuosvuk2jAsrEM9IK3fUYL7cuv2J 5zsTlIjTnudisaQI0dgYXEaFmuIVGWA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="NVxK/dES"; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717078; a=rsa-sha256; cv=none; b=iOYREZUGtPIU4+vRtLK2cNUPDkjowYxHTbfU/6cdfrpfZHO9fALNnfxcBtqQb6nsUXFJBx iMjtCSPk3de7bcrtRVoYmwCG3he2ETYk752BYD0ePwlvHM/q5B2kzwltiTjQIsbyffdJp4 zenNjontE69u9VStSRrODViN/FyiHsY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A967360B98; Tue, 23 Jul 2024 06:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41369C4AF0B; Tue, 23 Jul 2024 06:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721717100; bh=YsRpIjHui/E4Nyhzc91eYVtJPXNfygPjzJVhFxfItC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NVxK/dESWkZTLqLMzH+QJWFfHzOuDB5Zg9jxVFrm55l8etkE62sOi/PKgAV8Do0QY 9rqjDpdBneIIs6hLXbaC9H5ardG4k9hNSS/24b9JnxWSwubCihG79QaFgLXjiOt26i p5kfVp+usEUs2GaoIHsD2Gg+yWKdMTm1ax+yF74qZvG4LhsUAIfWXOI8A0pzR+4k2C 4L30n/ESR2jhEAg8I5Cgx9nuBQXnCjuKDvQSU/NlgeR8s9cl3adIfhZnMK/jclT8fC sCU2WFhWD8J2tFeo6YMWlMfyl6EZSdgTeivf6nLJX9D94/RMTIzVb5nPxrBdMYvlet +qODh3gpzSY0w== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v2 14/25] x86/numa_emu: split __apicid_to_node update to a helper function Date: Tue, 23 Jul 2024 09:41:45 +0300 Message-ID: <20240723064156.4009477-15-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240723064156.4009477-1-rppt@kernel.org> References: <20240723064156.4009477-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 6AC8914002F X-Stat-Signature: rqwxrfmc4dk1e68hd61xuqhhcxf1hckk X-Rspam-User: X-HE-Tag: 1721717101-304877 X-HE-Meta: U2FsdGVkX19eT7YgM2YzciVpCnLDJyuznzQLDr98qjOnsw3ESlIKA4l5q11k0rguX34w0hAhL44M6MSY6dPnfVn9Ke4ZCITsmhm81X+GgzezxRC/nQt73gk8MHy5IRGy09snbol5y4/7uSt2Yf0A8QNANm78LfWhlWoEAKv9lDcX+oeYT+jgOl4T7qnFf4YJojFvp4tAwZRJmQdF1J0WdupLz0t6I3Zl1QYPg/1t+37oNuxyEByuOFe4QN1BN8Y2inKp77/WPZ98zRI+d1Gh1LzzUP1D9Y0//GXKSrGaj1IiAn8vdgc2OMN9+6qkGpFuhpj+5uC0NMkfFwZ2zmcepPD3sIkYDtlDk0y0j9FDUuflx4nq1SxJX/gaB2yIeoOzM+uZf7QoiBvao+X/M5y8Y/j80Zj4OPtQ4phUMeP4sQikZI/m70QP3Ft4tK9eHnVp+xmixSTxeZ1NsYnlOG7T/o4EVg2UeAUar9k1TtwVMh8OIxoFnVeV6c05j4e/vcnAifIWKDKYV/JnX+iNMuy5CY6mxAxCqFL4zrdxRtGLs3TJD76CwiX6Q7FaXyGx9GLUSaYa3TFZa2/ib+ui63NkDEmQMJRuiupaYJSx5qZ5RBip/k6Dxh6F0I3Qgb+Yrairit2FngMmqUXD/a7oSIa9ezGTCdcXDdD0fjtdpYMCwxuSWx3PSzTqcaQEbSiqmk3SbZIuZPyAYA9zsXfgpYt8Ws21J/ckmUEvUJaVspk6T7QUUqYi0wxKypTNEeEP3LjUg86cwh2kxrp4OZMNZokk46Q31zBGqqnC3JsLPkjk2/PCPRM3y6zCY6LEcs5DXGgQo4FrdSytqb2B/LqUGuLlOU+yXaOOQfh2kJ8E4HIF061ojw1yKvBGmy/rjjgLF7FQoEVTSt1fXGxTOtf5x4C5kqWZ96hUJE1Bd876tdrdqEP/5qaS2bXMpk4kKXPfiTHg0VyYrU6QKTdsEkhcx3V MaqdFxzf lEsf11XrO7RIyD9l5gHtVoVLaHQ8PWP1mLVHMpE4GscMkNOkXHL5p5z0H1CNevcxJxPG56qWBIgwFWLUGSPSbmuZ6oBDJDcsK2DojRsMY2QHPAuFycWfb8GXQoaPuwmjgPYb/qZjFXDXGpfSlAAnGQIwoYevCBUAt0kTYHiTUoDaZ2UefOUArJzJ7QcsaDvKpc3AzBGhV9d6bon6ftri63RQNA7Vv9LenFJRL8q4+zAtvYH0rz4IMW9wE+AmLWG8WOBMx3yz/wD1iwcwmIhE/nQdNaZ+zDX+Ju71qGD/1dEoB3kIK9Mr1El/ciISoCO2t1DPGKvhfc9LL0JrdFInq4M6KNGdHNZt99BQD X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Mike Rapoport (Microsoft)" This is required to make numa emulation code architecture independent so that it can be moved to generic code in following commits. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron --- arch/x86/include/asm/numa.h | 2 ++ arch/x86/mm/numa.c | 22 ++++++++++++++++++++++ arch/x86/mm/numa_emulation.c | 14 +------------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 2dab1ada96cf..7017d540894a 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -72,6 +72,8 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable); #ifdef CONFIG_NUMA_EMU int numa_emu_cmdline(char *str); +void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, + unsigned int nr_emu_nids); #else /* CONFIG_NUMA_EMU */ static inline int numa_emu_cmdline(char *str) { diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index cfe7e5477cf8..9180d524cfe4 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -848,6 +848,28 @@ EXPORT_SYMBOL(cpumask_of_node); #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ +#ifdef CONFIG_NUMA_EMU +void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, + unsigned int nr_emu_nids) +{ + int i, j; + + /* + * Transform __apicid_to_node table to use emulated nids by + * reverse-mapping phys_nid. The maps should always exist but fall + * back to zero just in case. + */ + for (i = 0; i < ARRAY_SIZE(__apicid_to_node); i++) { + if (__apicid_to_node[i] == NUMA_NO_NODE) + continue; + for (j = 0; j < nr_emu_nids; j++) + if (__apicid_to_node[i] == emu_nid_to_phys[j]) + break; + __apicid_to_node[i] = j < nr_emu_nids ? j : 0; + } +} +#endif /* CONFIG_NUMA_EMU */ + #ifdef CONFIG_NUMA_KEEP_MEMINFO static int meminfo_to_nid(struct numa_meminfo *mi, u64 start) { diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index 439804e21962..f2746e52ab93 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -476,19 +476,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt) ei.blk[i].nid != NUMA_NO_NODE) node_set(ei.blk[i].nid, numa_nodes_parsed); - /* - * Transform __apicid_to_node table to use emulated nids by - * reverse-mapping phys_nid. The maps should always exist but fall - * back to zero just in case. - */ - for (i = 0; i < ARRAY_SIZE(__apicid_to_node); i++) { - if (__apicid_to_node[i] == NUMA_NO_NODE) - continue; - for (j = 0; j < ARRAY_SIZE(emu_nid_to_phys); j++) - if (__apicid_to_node[i] == emu_nid_to_phys[j]) - break; - __apicid_to_node[i] = j < ARRAY_SIZE(emu_nid_to_phys) ? j : 0; - } + numa_emu_update_cpu_to_node(emu_nid_to_phys, ARRAY_SIZE(emu_nid_to_phys)); /* make sure all emulated nodes are mapped to a physical node */ for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)