From patchwork Tue Jul 16 11:13:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734341 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 38BE7C3DA49 for ; Tue, 16 Jul 2024 11:16:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C67FE6B0093; Tue, 16 Jul 2024 07:16:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C18B06B009C; Tue, 16 Jul 2024 07:16:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE08F6B00AB; Tue, 16 Jul 2024 07:16:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 901E96B0093 for ; Tue, 16 Jul 2024 07:16:34 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4E7A0A052D for ; Tue, 16 Jul 2024 11:16:34 +0000 (UTC) X-FDA: 82345362708.14.4AF126F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id E4CE81C001A for ; Tue, 16 Jul 2024 11:16:31 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KRpLrrVg; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128564; a=rsa-sha256; cv=none; b=RSFqIIIfNFMau+S15JE/GmcuWy3FArdncGnUIhznWeHL8ykdUJk9/bqlt/sBR9OWwvJUJV i0aouD4pCi6x4MvEz5YKCUvZD/Ffa69Sibs+6JD/wMMVtPNtSwhMVvwINXIwI8ddlB3LmK 7RN55NU9tH2pbwYI9JJOAcPC51S+pfs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KRpLrrVg; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721128564; 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=Ybr38rBGNipKtypADjBZ7WIYAFVlTwCKFesuNC2cEuU=; b=UpCV2xTnopJL/dM+rAQlO250NF437RZppID73p+kvO5A0bid+JQIYMsNqjgYkiD86TtYkC QTIfbiy98NfXxibrgfEEKJAdlF814R5/pXJriQ5c4FjrQ2nSqviZRviiGcyRU8m0PdkstW i92+7o9EOQSnT66P5P99hPb8zWrO6GQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 513AFCE0C68; Tue, 16 Jul 2024 11:16:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C776CC4AF0D; Tue, 16 Jul 2024 11:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128588; bh=J5LEqR4AoCvU/KZiQsAwdFPUPPx4+6cXxvN58f3qL14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KRpLrrVgs49iPdPeTlsZTWXyagoaSsHx1E5C93i5+9P8SBlnn7Z12NbhmT4tPpRpJ 0zI+BO3Nppe5LLSfYA4/YJraT3JXfCwhgn8es8kezNFA5tq+VGZs0z3yKJaNH88eeY ko/ZZr/J/iuMNP63MEa1Cz8SPM5bEZgddW3tOQDKBjZZ6IRrZzzrI/1IH19/F20lWd U4anRDTclZV9ZpdtUMrjnLxeBd4fO7FcnGM+dt98tawWilGeWcPF4NK8RCMxjjkijt 61SQDh1+30pevGJ+NuacABT3RBSTFUm2AWNy8CJd82u176925JGY/GFFjGvjXBldU6 /v8D8XbcQ1KyQ== 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 14/17] mm: introduce numa_emulation Date: Tue, 16 Jul 2024 14:13:43 +0300 Message-ID: <20240716111346.3676969-15-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: E4CE81C001A X-Rspam-User: X-Rsp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f0dRRWLlVEVK+qmvwGrNTGOXu1faIHxVSVoyFNOeO6/tKePW0buOAE3AEhWxvw0vRa0wj3y8dvGon9/WYeSAw2i3/df8dj9tBC8Gs/jsZ2QldH+CU92dsMjPDjU/B2XggRODxIRxCxqFks0cXqmb1LESyBZFHbuL95NrMeU87KAl+MHoPY99lyzGwiDKTOAaxrMNm1o4bRjIR3Kdz03H5AEn1Eq7ZOInYjivEOIRBVHhgNMZzkjOd49bb7L1hkW2jyGsjt4ez+lD 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 + mm/numa_emulation.c | 4 +--- 8 files changed, 27 insertions(+), 35 deletions(-) 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 6e9a50bf03d4..c6e232e3c303 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -67,16 +67,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/mm/numa_emulation.c b/mm/numa_emulation.c index 33610026b7a3..031fb9961bf7 100644 --- a/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))