From patchwork Tue Jul 23 06:41:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13739447 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 A1090C3DA49 for ; Tue, 23 Jul 2024 06:46:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 264C06B00B4; Tue, 23 Jul 2024 02:46:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 213416B00B6; Tue, 23 Jul 2024 02:46:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B40A6B00B7; Tue, 23 Jul 2024 02:46:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DDD186B00B4 for ; Tue, 23 Jul 2024 02:46:04 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A605AA5E46 for ; Tue, 23 Jul 2024 06:46:04 +0000 (UTC) X-FDA: 82370082648.04.56E9F02 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 664451C0025 for ; Tue, 23 Jul 2024 06:46:02 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=S2VpYoVm; spf=pass (imf18.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=1721717127; 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=nByA89AMuruUBQqwNJQrSHQjjiCmK3RL3+YeA9z0jjo=; b=S6MuXf3D525DCwWRUskJnM5AAnAAjC+l+RaUryw0ltpummQkCwtjn7Ztx7oU9kvMgJNWZV bUaEXS2yqESbFxl/1tsi1ZNrhwyh08TVjlk+hwlUvZ3ZgDxJldWH82TRYlWe8Kw5YgGrk4 Bx4L1Z2ayJmGQRxz61dZILP4M4+sbCI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=S2VpYoVm; spf=pass (imf18.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717127; a=rsa-sha256; cv=none; b=2H3D1ISQWF4Qxq7KKc9hjzW5p1/Tcex/HYpem8l7e1KADXDL96ClGgmToVqeGUp+MX/Ns8 5hCDQrYMbk2G6Mmqx1LbM9EBu6Kxu39krnfwNUFG4kZAiSYAJMjgOiFEnyCicY0tR30J2L nv0MVUNW40np+9gpDRoT9W+fx1uzGDk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A67E2CE0BBB; Tue, 23 Jul 2024 06:45:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB686C4AF0B; Tue, 23 Jul 2024 06:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721717159; bh=rbVckViSVk+mWr74pnwR2o+U7UjRpaIJSEgglVAH+jA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S2VpYoVmHlTiPzU8OqPPA83vMOFMf/PIBBBHYwi5Wo+QDdtmOGBN5Sscv5TCpLxgN NZO/x31toKmJYKIOruH56bVAhmJIg6nm0awNn5f/75Hd+0paV3Uw+mTYwKmGwaC8Zq wb7M9OglSTyQU+edoI3r5AnDjjNVZA7pNqCl13LuGKJXc4OhXnw5Y2jv+06YxhonfG 2hX1hXiw8/5LQKlf61IepqOIywzamX/NcfHLYTl5mEaMJIfQdGJ1cGB68C0lPPiz8c IoYAnoWIrKfPiDCSKfBVWMaTsbhpQXAwtUx1ww+ePFzxX42z9MKcussciG9QVw3dBx XAvULj29Krlrw== 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 Subject: [PATCH v2 19/25] mm: introduce numa_emulation Date: Tue, 23 Jul 2024 09:41:50 +0300 Message-ID: <20240723064156.4009477-20-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-Stat-Signature: u1fq991kc55jit398gcbtzazsrcf7xa5 X-Rspam-User: X-Rspamd-Queue-Id: 664451C0025 X-Rspamd-Server: rspam02 X-HE-Tag: 1721717162-216887 X-HE-Meta: U2FsdGVkX1+ca7MPlwDfklg1pdtzBGWmckeg+UtQ3MoC0RJkv+zks64Vt1cE52Lliu+D3eOA+crRtd6xW2aX8oGNPglpBLppx8aJKeMTY77BGFAMFybdZiQxp76TeBG/efF++Lu4klPU5eOTwVjgIm+jIBLPNBPLremAfl6bP4E9RRklC49HPBQZ+BH4eDzRYy8Wasn2y6sjAGMAQ+g5peibgpXe49T8MC3PpPSrgWCsO6iHfXD7qTNJUejBMm6ZmOLBFItTISth18VuZOifYicKOiAXj7hhbK2uplrIFQCZ5zKQPIrB2C2BosYJxj2O/Q9ITXeEXcuAitNcACxTlOKmz5sElC4D7Wx8J3GCLn6U2ZtjqSX5IFVDAS1PFpA4nVcY/nrykc7acQ/qHp1O1gnZWzuuY6eCy1HRsmrBViN0i29UvobAXBxohZglIdnLogu/frCbOpWwSponiACTqCQkwfE7vBQVPXQN+LaC/RMvua4cfi1jovn7EhUF2IZvnWvo9WLuArsOscbroekut02EEO0zxtX87NbS5VK0SWJ6gFN4w7ASE5+/MaeP1HYMkapNdkxHALIIiFjuKftsy/ymQOrbt+ZyPRCt+4Ga7eidV/+S74sU2qRj9ihqJ+S3LKvgV4sl8R1FwSGVU1X50oiHup+r/ZTErszb5DOH2NEPTl7dJBlIEDzmawOtY5unuYGM24nxzcU7NCMtTzUN3mAQ0R5GoDNvWdBrBgdzdWS3TCpiLhpaMgP4Yik6WXyhv8lE4ZNvC5gqBAdVtF96Tb0EPIZQ6cMRALBGGfkoD1mjoOJgGU0T5LWN78R6+6JwLHoHnwHtEQBmSg3w0d9eO/G8Kgqg9wk/zKIYYRmpjDfXUQyhdjZ2aY1Ih9AJHIVQfdujKuJvqfQBA+rWZEPlXd6eizNM+WCj3lR93gDH65+LR12OiTiLR86fBqgKkKtjXkZQqpk8s6w+FKyvsuq ARZNGLvW NHy6JarDyP9+oA/RNWcV5xswCKoPKpYLullqfsz3jHiIXutPy1tEI1XSJce0C3bviNYIpkjVrpqqjd3k4Jwr8qZ4cima6ubgopYzwjjBEvmjjKFkXOix9wluCarXZ/kkFT0pJ1Ds/EJgwZx8hqDicoRrs33hzbg2sdHyHmRS7QB73eYOc46k+JOOvqKuDJ1+E26zTTerXmZI+xx62sswXQmwwiDco7z/6YIA6+mYsHAkjsI8b9vU1TMRObJ8enPGF2x0W9bNjcrA4TOR0fZJs58q7BbBtMFU92bcTPwsUZHMyjDU2fvR+GFEBQnmpB7VwGcvc 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)" Move numa_emulation codfrom arch/x86 to mm/numa_emulation.c This code will be later reused by arch_numa. No functional changes. Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/Kconfig | 8 -------- arch/x86/include/asm/numa.h | 12 ------------ arch/x86/mm/Makefile | 1 - arch/x86/mm/numa_internal.h | 11 ----------- include/linux/numa_memblks.h | 17 +++++++++++++++++ mm/Kconfig | 8 ++++++++ mm/Makefile | 1 + {arch/x86/mm => mm}/numa_emulation.c | 4 +--- 8 files changed, 27 insertions(+), 35 deletions(-) rename {arch/x86/mm => mm}/numa_emulation.c (99%) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index d8084f37157c..a42735c126fa 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1592,14 +1592,6 @@ config X86_64_ACPI_NUMA help Enable ACPI SRAT based node topology detection. -config NUMA_EMU - bool "NUMA emulation" - depends on NUMA - help - Enable NUMA emulation. A flat machine will be split - into virtual nodes when booted with "numa=fake=N", where N is the - number of nodes. This is only useful for debugging. - config NODES_SHIFT int "Maximum NUMA Nodes (as a power of 2)" if !MAXSMP range 1 10 diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 203100500f24..5469d7a7c40f 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -65,16 +65,4 @@ static inline void init_gi_nodes(void) { } void debug_cpumask_set_cpu(unsigned int cpu, int node, bool enable); #endif -#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); -u64 __init numa_emu_dma_end(void); -#else /* CONFIG_NUMA_EMU */ -static inline int numa_emu_cmdline(char *str) -{ - return -EINVAL; -} -#endif /* CONFIG_NUMA_EMU */ - #endif /* _ASM_X86_NUMA_H */ diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index 8d3a00e5c528..690fbf48e853 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile @@ -57,7 +57,6 @@ obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o obj-$(CONFIG_AMD_NUMA) += amdtopology.o obj-$(CONFIG_ACPI_NUMA) += srat.o -obj-$(CONFIG_NUMA_EMU) += numa_emulation.o obj-$(CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS) += pkeys.o obj-$(CONFIG_RANDOMIZE_MEMORY) += kaslr.o diff --git a/arch/x86/mm/numa_internal.h b/arch/x86/mm/numa_internal.h index 249e3aaeadce..11e1ff370c10 100644 --- a/arch/x86/mm/numa_internal.h +++ b/arch/x86/mm/numa_internal.h @@ -7,15 +7,4 @@ void __init x86_numa_init(void); -struct numa_meminfo; - -#ifdef CONFIG_NUMA_EMU -void __init numa_emulation(struct numa_meminfo *numa_meminfo, - int numa_dist_cnt); -#else -static inline void numa_emulation(struct numa_meminfo *numa_meminfo, - int numa_dist_cnt) -{ } -#endif - #endif /* __X86_MM_NUMA_INTERNAL_H */ diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h index 968a590535ac..f81f98678074 100644 --- a/include/linux/numa_memblks.h +++ b/include/linux/numa_memblks.h @@ -34,6 +34,23 @@ int __init numa_register_meminfo(struct numa_meminfo *mi); void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, const struct numa_meminfo *mi); +#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); +u64 __init numa_emu_dma_end(void); +void __init numa_emulation(struct numa_meminfo *numa_meminfo, + int numa_dist_cnt); +#else +static inline void numa_emulation(struct numa_meminfo *numa_meminfo, + int numa_dist_cnt) +{ } +static inline int numa_emu_cmdline(char *str) +{ + return -EINVAL; +} +#endif /* CONFIG_NUMA_EMU */ + #endif /* CONFIG_NUMA_MEMBLKS */ #endif /* __NUMA_MEMBLKS_H */ diff --git a/mm/Kconfig b/mm/Kconfig index 15c6efbaa1df..ae58eecdefdc 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1252,6 +1252,14 @@ config EXECMEM config NUMA_MEMBLKS bool +config NUMA_EMU + bool "NUMA emulation" + depends on NUMA_MEMBLKS + help + Enable NUMA emulation. A flat machine will be split + into virtual nodes when booted with "numa=fake=N", where N is the + number of nodes. This is only useful for debugging. + source "mm/damon/Kconfig" endmenu diff --git a/mm/Makefile b/mm/Makefile index 17bc4013a2c5..d5b1b30f76e3 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -141,3 +141,4 @@ obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o obj-$(CONFIG_EXECMEM) += execmem.o obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_NUMA_MEMBLKS) += numa_memblks.o +obj-$(CONFIG_NUMA_EMU) += numa_emulation.o diff --git a/arch/x86/mm/numa_emulation.c b/mm/numa_emulation.c similarity index 99% rename from arch/x86/mm/numa_emulation.c rename to mm/numa_emulation.c index 33610026b7a3..031fb9961bf7 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/mm/numa_emulation.c @@ -7,9 +7,7 @@ #include #include #include -#include - -#include "numa_internal.h" +#include #define FAKE_NODE_MIN_SIZE ((u64)32 << 20) #define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))