From patchwork Thu Aug 1 06:08:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749747 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 B1841C49EA1 for ; Thu, 1 Aug 2024 06:11:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DDB06B00AC; Thu, 1 Aug 2024 02:11:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2673C6B00AE; Thu, 1 Aug 2024 02:11:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B9666B00AF; Thu, 1 Aug 2024 02:11:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DD6696B00AC for ; Thu, 1 Aug 2024 02:11:33 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A491E1608E2 for ; Thu, 1 Aug 2024 06:11:33 +0000 (UTC) X-FDA: 82402654866.26.8CA518E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 0A646180014 for ; Thu, 1 Aug 2024 06:11:31 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sggkX9UX; spf=pass (imf06.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=1722492647; 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=bG6M5e3j+jSHyqtWx4rOIEyZl256PwLpGT2BLqjHCxw=; b=H4o5CzSRQe9+e29lZAh690kozcyZalzahWMvkJ6rm/SniqsR66Io9P57xKWLuTZXlA2kdw 2639E9plCpTdtEAo55f89jbQgMMhJ+slBAIJR+1zvPinCzcIybgVXjZy9eyA63UldfwGhw 8N61i1ycVDF3FWNzX/MMgNAExvYk+Bw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sggkX9UX; spf=pass (imf06.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=1722492647; a=rsa-sha256; cv=none; b=B+rXGhVaA8wvr2wE0Wsn5aZWT1k399URx/MLsdpgSNTi1F2Ql+Zol0UfKPC2KrivvEnTiP xIpRLW7/+0pkrao7zf9wMcBLOigkkZnZmnJOeSAKz/Tz+A8iw2/MOAfpi3zupQFNHaylnn OXiIprUs7aQ6RFm5ZDO3pzDyUsGVnsQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4A73A6140C; Thu, 1 Aug 2024 06:11:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7173C4AF0C; Thu, 1 Aug 2024 06:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492691; bh=Hwkl2fYIk7TOliTb70qL/9b9HRfQD7yZz25kkbJxzwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sggkX9UXhxZlNsIU8Cl5aBh0kTbihmyOr+rKh8PUi6HpNbM0T6FIQKsN6mrcRHsf+ /SHE74zS057DN4assx4nJNhHkYwGmMqA+89c3GAN3GWW1EkySpM/jKp7djIHsHmlQ5 J+Rv/xUy1WL2p4zN9YP1XUUreurEUzXm4yz/xIU+P7O+cVStnX8B/b0U7trY1kXI3V hD82NTGJiywRlimIOVt1MLB+ZyReKPZdsG0bD+xetL7gw2D1t4eztwZAnWKJPPnk54 vnKaRI5ocC0Nw9z/8HV7kFU7UWYinD8YhScEarF8oyOHxHwNgCdMiLoia/TVqvYCnm Y30JzCKYd6e+A== 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 v3 14/26] x86/numa_emu: split __apicid_to_node update to a helper function Date: Thu, 1 Aug 2024 09:08:14 +0300 Message-ID: <20240801060826.559858-15-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 5yzc6oo8t5y5nnimr3zc57aem6s1a5do X-Rspam-User: X-Rspamd-Queue-Id: 0A646180014 X-Rspamd-Server: rspam02 X-HE-Tag: 1722492691-343066 X-HE-Meta: U2FsdGVkX1/0fKT5sNuw80F8o0se5RDsd1OE/qmBKEM8koxaoXIXHiNWs61IiDjllVldZGGQ+uaPwIIj2/L3RDxqsZ4hOmksGcygC8ca4qj7OTji7ZtYOqbdWD+I2/taU3EdpJP8n0gBMEKrVLCrz0rIVASiSBY7i6JNOHYIZd8+D/5yiBI/vPJvpKXU3Uh1ex7jZ0KaKthZIvqFv+boF0O9NQv+mdRm/vo0TLatKFwMkIbrWoJuyLu23muAr6roTp6LexPgjKJfwJBiY99qwLf8OdlCmkWdONI35/HSfHUUfgxbIIEEMYC47HmqnjZmz+p+odbh9GN1nVkuhTdguHk/M6P5EhVu67SPcZCFc/7TVV8ZOaiVhBfgixJ8687MeeipAlFT32ir1CxOBwijiCbWHQBmK5g0x7XAuP6ykRwnK92+XT/YeGdcgql2Ep11GecPB+hqmyvREDVTjBh5z0x+0hcYBQT4pgzIOnM783f73HfQgWe5T00szMcM+4CSTImDSGcpqSq5dJiVUJsOKfYRMBamdG/EiwkeO2ShoDXxsGXzLFCWcKgwW+4IyDjonTECxSojRhgp6y7jT8wEftqgKd/0Y+gwnH6EQ+bm3VRteKK00l+BoX6dJWovd99IhFfPXjNwX8JIqA0nMsaR2F5fXSCjhZgvEskiZWgwILOd/jpeBzOBMEk7QDkONwS/deHS+WbhZkCCV5ZxXYf3AcjWCMrUqwHqSC+boL5vq4SeVMyhAsOMpTWLFLottyg7Ee6JOMEcAFRffkWdOWc84Ft7Sw2jdqQHEPLCMHX3861f1CTnJe+bPOL0bKBSeNFNvGaJ0ztBPiS9UsTuY/y/ArkL9qbXCtpj/7h+2sn8EiWkWrUhc8tf/KWywkSEYrJ9V1mwimEylw2dHPnglI7Lw9Ky/6dKkxKyiKldXng8kVX1odF97p9r4fyANxFyHwep5+yPnnvJZXc9FlNLLzg 7250qL4Y Nm2dbFjwXRa9cwMOD/utBg3Ji7/j7g757x4i7CafunIDui8hcVRDYnY1faR8cFOJcRLf0vbc4DZ5M1oWUYikcMwuO6D0wyNGXNzPDD1X31YBXZ26qkN+8nNogqucHJTqGVA8p2CYtRjNPpyXRL6qpIhoUAqKkbI5aao97++E7TkSnKBkhd6i73aq29AWL7jeizsGQtoMiGcU4xpe33SSVz3zMVeGxhkn0QzY5afk+JvYg9NzzOuBd76Zbklf1Ajg4dHXVuin6nk1nJS6KH8rLQRro8yDVNfDkUcTD0u0V5zEzud1XQMUJoSdyFCN3vb9Cgj3d53k0fk8WmBuBIF4R7rJa+/qTZd8aSh9FKhvWy/948vtY2j8AlzSvBA== 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 Tested-by: Zi Yan # for x86_64 and arm64 Acked-by: David Hildenbrand --- 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++)