From patchwork Tue Jul 16 11:13:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734336 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 895C9C3DA49 for ; Tue, 16 Jul 2024 11:15:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22B006B00A1; Tue, 16 Jul 2024 07:15:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16A8D6B00A2; Tue, 16 Jul 2024 07:15:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 031306B00A3; Tue, 16 Jul 2024 07:15:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D82786B00A1 for ; Tue, 16 Jul 2024 07:15:43 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8855C1C36B2 for ; Tue, 16 Jul 2024 11:15:43 +0000 (UTC) X-FDA: 82345360566.26.862CF51 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 3E42814001B for ; Tue, 16 Jul 2024 11:15:40 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U2KDJ8Qq; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 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=1721128504; 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=A+/tdVLHdUu5IiSLs0ToB0NcWOw5qRePM1lcfecBvTY=; b=ZWXCJYVByKpIjouNVTH0qLw8/8a5Bc7gRvg/swqnqJY9n4mFOGt2Am8tJ+aJPLeomjkhNh AUj82rvIyUwRS4xCgueOVL72r6Id9LX6hE4ceA2AaecigyTYXh2wWEnp4OxptfZdsqRTbC eG8/M6ROTUanmXzQAsjuJqbBRt7/Rfg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128504; a=rsa-sha256; cv=none; b=DwthIPCqJpDY6zhxj+/c0c7+UO2dhZJmP5rXFQ/uJBc7krKV6n2lAwgi65favNYp2vwlUi /pm2UdH/7n+XBnyHGAy9FW9j0EwGT7EPMjv0R4ydH+fGXJQD5v5uf/1x/h43VEBkScBiyV GXwu3gkSY8f37JoueC0JALgJ2cZgDvo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U2KDJ8Qq; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5465DCE12EA; Tue, 16 Jul 2024 11:15:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC052C116B1; Tue, 16 Jul 2024 11:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128537; bh=TtK2o1XZcHSBtZCo/iztzChwQXjabLP9TIYCaEXwnLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2KDJ8QqsZ6ujc8t3TBx7FtuEY8O5WaX+Pxrz/aCCWpcNBESgqGzhlnFbOkmiGPh2 BJDM7n8YGnKhU5qvx5xGSCARdDsfvYgNqD8EAbGRyHyYeTH+Yslikcs3PSkxSDepVn cxfdTAdceSRM/JpCQqHkRcmntPwLxiy+SNTlSghcM4k+ANvJAHDPnWL7Ti/RdZmlx0 v2w/71QyzD8CSAR0b0qE+uBtAq2mpnIqwFDRPgutMiYJKCqg5n5OjpsTIWeyFQbMWL v38YxQomZehHmcgvvjOMbeO5+ArCF4brt6hJKVfzRxVp68ChSZcyOHFg3sWrxXeNpQ BKm8ZNJsG2pkw== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 09/17] x86/numa_emu: split __apicid_to_node update to a helper function Date: Tue, 16 Jul 2024 14:13:38 +0300 Message-ID: <20240716111346.3676969-10-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3E42814001B X-Stat-Signature: x5s4a8krd8nx7re6181i898cczsuh734 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721128540-237439 X-HE-Meta: U2FsdGVkX1+ldMp6IYPBVLPyrvDd8T67oAIVzO+kH51DTe9XhOfqPXFanQ/6QZF7oYhW5ip2DPMW+jbV6KGZOX2TNMxkQR0q10Rh7QQddgLxrwYbTJja5clhNsa6xlCNJfiKhoJHgBGg7ogKO8ZVKB3SjY9iJZiqmoXMIv/trUULK5LNDM9XIlT6nBxsmPVk10wTGtEezvAxJgw8NyKsfwvNGRz28P09tDzDuj8R4O/rOjeEpVYoudPJEak/AsJGvaS9GoxdZEgM65ATfIjNFuzAGxWHfE4IY4cCE6XFII7AIa70hh1ksQSVZCbLuyOhuWXu+eypkzWILjThFmRON0dG857Y+oa7na6pjLMWsO7RER2r9OZzffGw0yoY+/b3Ga8lueNGMhKnIcaTG1lmA/A+lCrOEE0s7xZChJUKK7FIB5gUEc2DkYOtx0QlGHbkjZAdbmN0ynPUQUOA+cWieuplGMzf494JgUxpLW07YzazrcA2OnMhIWnir0s0SWG6z827xjIZRpFHMU96u8wUzfI2eu+r+1f4uDOWatVoWeUy6vc+3h/G9gamIS99sDgWEpl3TkMqyYv/mBrGIe3xxHiHqWKHTaOd3Cn6B24z8PsZgi5mQM4y7bQByA22734r3eBHcnLbkfQ3zI2Xoz/BrlJifYhu9MbrowzG2sfqRjgGoXgMtdIuWuYmFfKWv+LqTHNQ9VsMdBubmMm09jZmKlC35MRAiYpikE2tuHN+hG0FTN4eoHAM+m3OFXZ4Bp1mQYFZJhfmVFqO1Cd0MXFPXQ/ZUmzAJq49AK0921KkGoldiw0AZPj1LSHXsvQRdBQAZhrzrw07gCQaql+K2BrQUuV5T8qgBz82GPh6pzraZjirdgyJcG3WCwpFvkxomMTWkzbRi48VYQhhEQBQglDZ5g6KejevwB/FEFD6Q8gXaxR/dJzimbubkBXQPTtyGks/7qoGb6pXHqq/w8CwN0X j3PGFdTM YphpbTzm3uYHgz2M1bO6XNq2mBIrjW0fFMX6Tn1dNM/D38siFjA+BmI4A3ipT+988HaUbHghmcQPMIT2amzHWhaeMEhTqsLXHz3IYXpis86Ia7HmQZGqr4d8quF56fFHzS9hyc0S60hXIZpfSvWHaGZ1WkMRVosdZhwpXDu4msL8cjUgcB8o3No9QrLaGUfY3CV4trOaW5AeI9wCLp6XUWLVTfIMEflkr2531ywhrth78P0wx8An3AaNWy3VUluqjm03di8ELSYh5ldarlBOMW9HO/NMWZF7ymjgy 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 ab2d4ecef786..1320d776caed 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -852,6 +852,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++)