From patchwork Fri Aug 14 21:47:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11715213 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CE4A618 for ; Fri, 14 Aug 2020 21:50:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7D4020716 for ; Fri, 14 Aug 2020 21:50:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PzSgel60"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="dFjf1hQc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7D4020716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ayAVQWfxn2gZWyX952eqCok+U8bK2oqS+NoNNWZlo98=; b=PzSgel60ZACG2SvMAZE/G0E39 K7aZUlPtgdP6gLl3O7R6wghFZeu2Tkvg+jTifPTZt62RlNCOporpcMAFMmAsxrQ4YnrfsCtoRGtS1 +nFQk61PhlESLjqba7eMbBzpA0/iu9DhTd/8Dw5yg08GmJnyqTuygdOPQHTjARKiJ17uTJT+WAkx7 EbPDFZCxJL+WJ0fvgJMgtPmmP9acauaX5xav+MROmd3qk8hUQkjOfsgY/y9rTOHjbZwnO+2S+qMGU JC264Mz53Hhfjea0y69Wx4rNZZ83/3o3SWz9xkORf/wyHYwWtHmhuqu03rdYxlV+ZQWxKQC8iJ8IR LzUpej0og==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hZ1-0008Lw-Cp; Fri, 14 Aug 2020 21:48:39 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hYt-0008IJ-Fh; Fri, 14 Aug 2020 21:48:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1597441711; x=1628977711; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SJ0t1sPROiBG0ybrpqvJwUR8k08JOqtJS9YP0pE5HbI=; b=dFjf1hQcHgTjMfGrNOFOubCnEIGcfzKOZWOJIn4gdMOC0J2Wb2iAr91N 6NIuqZqtv/OTxBRCK4RGQJyqvphp+51TpWRziu0+k5vGBXUk6/sczIURY DIXlBuAipf0gCbquh19xoEAbbajcWrpVhwDVIZufEKmiRhBVFIDm51Q7c 3rp8vlBkGeErZ/6wF/ke16oxDrN5FutvIMQf6RT4qzfx7evdBxlV9VtaP C06TdGcxFCmytKTPIFU13lw6FsJbgmMvRt5TpyvAOkRjz5HsruRstqRbA Q/cxLdMmTbwR1MzMgfTRe3RK4Qvl+Pm+3XKidCbEhOxZhISvEMMslJDZ3 A==; IronPort-SDR: 1tS2I8LJVzbD9ZRVo3cMwrE6RgOX4mT6JdlzQKwtwJifP6zXauTKiJnznf3VwVX9qWzWeq9EnC Cow7HqPJvyZ5If9KJiS/crwQkMugEOTI3YVsUX6ERKFyk+2zCbJIAGBUHc7ql7ZMxhXZpreuW9 iEH6CkFOzRP9mwtvGwzEcrj3hq1nvp775GrsrFJ63616VOuRwtDth4wxbh7PQ9NFCJv+jCjoGf Ia0Q8vAToJnfO9WOaga4eCjCjt9z8w3FDlmmpaYgrlxFH2rM9Frtg+hF1EzGmX1KaJdJU/PHG7 fkU= X-IronPort-AV: E=Sophos;i="5.76,313,1592841600"; d="scan'208";a="254397125" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Aug 2020 05:48:28 +0800 IronPort-SDR: yaZtaxD6QsjlLa8/DO7WMW0Nu6P4pE8A5MvXfjMTjZA47pYYaniJQDjvF+0Rdks/xJRoIc2N8/ jmi6K53cjbyg== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 14:35:34 -0700 IronPort-SDR: xffce0VAhCB97N3lScrDgWYFuEDqStOodwz6NuYrdbRda0C1irpZ5qtGu/MYexgJM39mnWmD8l W9+3tcwmpHpA== WDCIronportException: Internal Received: from cnf006060.ad.shared (HELO jedi-01.hgst.com) ([10.86.59.56]) by uls-op-cesaip01.wdc.com with ESMTP; 14 Aug 2020 14:48:27 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFC/RFT PATCH 1/6] numa: Move numa implementation to common code Date: Fri, 14 Aug 2020 14:47:20 -0700 Message-Id: <20200814214725.28818-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200814214725.28818-1-atish.patra@wdc.com> References: <20200814214725.28818-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_174831_775913_FB6743B1 X-CRM114-Status: GOOD ( 21.19 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.141.245 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Catalin Marinas , Atish Patra , Zong Li , linux-riscv@lists.infradead.org, Will Deacon , linux-arch@vger.kernel.org, Rob Herring , Lorenzo Pieralisi , Ganapatrao Kulkarni , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Nick Hu , Greg Kroah-Hartman , Anup Patel , Palmer Dabbelt , Andrew Morton , Mike Rapoport Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org ARM64 numa implementation is generic enough that RISC-V can reuse that implementation with very minor cosmetic changes. This will help both ARM64 and RISC-V in terms of maintanace and feature improvement Move the numa implementation code to common directory so that both ISAs can reuse this. This doesn't introduce any function changes for ARM64. Signed-off-by: Atish Patra --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/numa.h | 45 +--------------- arch/arm64/mm/Makefile | 1 - drivers/base/Kconfig | 6 +++ drivers/base/Makefile | 1 + .../mm/numa.c => drivers/base/arch_numa.c | 0 include/asm-generic/numa.h | 51 +++++++++++++++++++ 7 files changed, 60 insertions(+), 45 deletions(-) rename arch/arm64/mm/numa.c => drivers/base/arch_numa.c (100%) create mode 100644 include/asm-generic/numa.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 6d232837cbee..955a0cf75b16 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -960,6 +960,7 @@ config HOTPLUG_CPU # Common NUMA Features config NUMA bool "NUMA Memory Allocation and Scheduler Support" + select GENERIC_ARCH_NUMA select ACPI_NUMA if ACPI select OF_NUMA help diff --git a/arch/arm64/include/asm/numa.h b/arch/arm64/include/asm/numa.h index 626ad01e83bf..8c8cf4297cc3 100644 --- a/arch/arm64/include/asm/numa.h +++ b/arch/arm64/include/asm/numa.h @@ -3,49 +3,6 @@ #define __ASM_NUMA_H #include - -#ifdef CONFIG_NUMA - -#define NR_NODE_MEMBLKS (MAX_NUMNODES * 2) - -int __node_distance(int from, int to); -#define node_distance(a, b) __node_distance(a, b) - -extern nodemask_t numa_nodes_parsed __initdata; - -extern bool numa_off; - -/* Mappings between node number and cpus on that node. */ -extern cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; -void numa_clear_node(unsigned int cpu); - -#ifdef CONFIG_DEBUG_PER_CPU_MAPS -const struct cpumask *cpumask_of_node(int node); -#else -/* Returns a pointer to the cpumask of CPUs on Node 'node'. */ -static inline const struct cpumask *cpumask_of_node(int node) -{ - return node_to_cpumask_map[node]; -} -#endif - -void __init arm64_numa_init(void); -int __init numa_add_memblk(int nodeid, u64 start, u64 end); -void __init numa_set_distance(int from, int to, int distance); -void __init numa_free_distance(void); -void __init early_map_cpu_to_node(unsigned int cpu, int nid); -void numa_store_cpu_info(unsigned int cpu); -void numa_add_cpu(unsigned int cpu); -void numa_remove_cpu(unsigned int cpu); - -#else /* CONFIG_NUMA */ - -static inline void numa_store_cpu_info(unsigned int cpu) { } -static inline void numa_add_cpu(unsigned int cpu) { } -static inline void numa_remove_cpu(unsigned int cpu) { } -static inline void arm64_numa_init(void) { } -static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { } - -#endif /* CONFIG_NUMA */ +#include #endif /* __ASM_NUMA_H */ diff --git a/arch/arm64/mm/Makefile b/arch/arm64/mm/Makefile index d91030f0ffee..928c308b044b 100644 --- a/arch/arm64/mm/Makefile +++ b/arch/arm64/mm/Makefile @@ -6,7 +6,6 @@ obj-y := dma-mapping.o extable.o fault.o init.o \ obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_PTDUMP_CORE) += dump.o obj-$(CONFIG_PTDUMP_DEBUGFS) += ptdump_debugfs.o -obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o KASAN_SANITIZE_physaddr.o += n diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 8d7001712062..73c2151de194 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -210,4 +210,10 @@ config GENERIC_ARCH_TOPOLOGY appropriate scaling, sysfs interface for reading capacity values at runtime. +config GENERIC_ARCH_NUMA + bool + help + Enable support for generic numa implementation. Currently, RISC-V + and ARM64 uses it. + endmenu diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 157452080f3d..c3d02c644222 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_PINCTRL) += pinctrl.o obj-$(CONFIG_DEV_COREDUMP) += devcoredump.o obj-$(CONFIG_GENERIC_MSI_IRQ_DOMAIN) += platform-msi.o obj-$(CONFIG_GENERIC_ARCH_TOPOLOGY) += arch_topology.o +obj-$(CONFIG_GENERIC_ARCH_NUMA) += arch_numa.o obj-y += test/ diff --git a/arch/arm64/mm/numa.c b/drivers/base/arch_numa.c similarity index 100% rename from arch/arm64/mm/numa.c rename to drivers/base/arch_numa.c diff --git a/include/asm-generic/numa.h b/include/asm-generic/numa.h new file mode 100644 index 000000000000..0635c0724b7c --- /dev/null +++ b/include/asm-generic/numa.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_GENERIC_NUMA_H +#define __ASM_GENERIC_NUMA_H + +#ifdef CONFIG_NUMA + +#define NR_NODE_MEMBLKS (MAX_NUMNODES * 2) + +int __node_distance(int from, int to); +#define node_distance(a, b) __node_distance(a, b) + +extern nodemask_t numa_nodes_parsed __initdata; + +extern bool numa_off; + +/* Mappings between node number and cpus on that node. */ +extern cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; +void numa_clear_node(unsigned int cpu); + +#ifdef CONFIG_DEBUG_PER_CPU_MAPS +const struct cpumask *cpumask_of_node(int node); +#else +/* Returns a pointer to the cpumask of CPUs on Node 'node'. */ +static inline const struct cpumask *cpumask_of_node(int node) +{ + return node_to_cpumask_map[node]; +} +#endif + +void __init arm64_numa_init(void); +int __init numa_add_memblk(int nodeid, u64 start, u64 end); +void __init numa_set_distance(int from, int to, int distance); +void __init numa_free_distance(void); +void __init early_map_cpu_to_node(unsigned int cpu, int nid); +void numa_store_cpu_info(unsigned int cpu); +void numa_add_cpu(unsigned int cpu); +void numa_remove_cpu(unsigned int cpu); + +#else /* CONFIG_NUMA */ + +static inline void numa_store_cpu_info(unsigned int cpu) { } +static inline void numa_add_cpu(unsigned int cpu) { } +static inline void numa_remove_cpu(unsigned int cpu) { } +static inline void arm64_numa_init(void) { } +static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { } + +#endif /* CONFIG_NUMA */ + +#include + +#endif /* __ASM_GENERIC_NUMA_H */ From patchwork Fri Aug 14 21:47:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11715205 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2EE8618 for ; Fri, 14 Aug 2020 21:48:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C7AEB20716 for ; Fri, 14 Aug 2020 21:48:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mRIfbv5j"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="jSRwSQr6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7AEB20716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mbmkBvrJ1yOyZX62kYiCtic8ScTLotSgu97vrCT/2Uw=; b=mRIfbv5jUwNIwtvUHtbk3SNlh pdEKZPHRNGRVu1JP/i6hBBGIcNfpkkyozy2247UCY1l/1jopaGYVcJl9PAyz1TXF4ZOEkd4OYbTfe 79Y9UGA8/5YVL5fRi9F6H58Lk79PXvw9puBGyv8pi28XMg4/43Cgefn73moECIMMP2IiIyVmhgeld 6JDqfY5kZbwQTU4kwcLl+87tiTTn/RjL+JTId7wpb9o6bjj0LyIsLQsAyOU6GN8fQxXoLrWq1vEQT jyxU5jWMWlzcASDiyd1DS9pcukBy9I/d5cf7N3rkQk5sCkDdGHmGYGSZPkQ6Pj3tFpxgONtzAjfHZ x5O2ar64Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hZ6-0008NK-E1; Fri, 14 Aug 2020 21:48:45 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hYu-0008Im-IC; Fri, 14 Aug 2020 21:48:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1597441712; x=1628977712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m0ccOUy/zHhyg/Evs7xmin4JSbqfjO8+1dBWk5YQiwo=; b=jSRwSQr64jdaqiC3Ynhre5kBxzIlz3K/hlcjCrpyBUwkNcuSq8dv18O5 nEd2tHOLWKxCGwiF8Aj3OwzeiMWYIpaWBb65H7nWVMFQTHbb5LQ9Rb1rk 5Nmm1Cn1uUMFdCfbYfvrANJ6rgNxz9v74/L4di7aETO8LOrBKyhr4rmbl /JIaVPgjXLrQC3fCA6y1z8UqG06E5Zt4x3gW5eh1HeqhCjfecQQbpzBN/ x/aPdMwpIHt+QsDEb00cTbyTx1qvy8WLpLyYYHQ3s+xACj9Y3vz4Xy6Ss gmZ6DjDgAM705xHq1oMg/Vtqm01HUuPLZ7KqsBHaukLonQQmzZYAuynXA g==; IronPort-SDR: BtPbD4b9df59uMKe/DfULewHf42AryRy39fAPBOqXzsjRPnESqVmAQP1ngcRjIDRICwvRS5dIz 7Q6hAz7SxM+bMDuZfHejuU0M0vVLTXXkaCEN5q8EiMoDvu+cOikP4TdW824Y/1h60cMiidmrLk dvQVe/X9m9difa1zLpE+nOojSz0EtS8i+ybwwJmr9j1GQDoqRgiCEcV3/Jzj/FeFtzu4xs6WCh ICr0O7b4d6am/xqE2Gn5uIEpJoBdkeRuX8x4Ps9Rym6jg2kS01HHNiQvKT8s5wxq4zbLDlvsdh 1RM= X-IronPort-AV: E=Sophos;i="5.76,313,1592841600"; d="scan'208";a="254397127" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Aug 2020 05:48:29 +0800 IronPort-SDR: eS2zB4tpOaaq/YuC9cGDWd8cgstBrVgLL8lnbgQvK/mHmLT5qUtRpdMG1bR6wdNwpJazKyZO7q REBbKVceSlyg== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 14:35:35 -0700 IronPort-SDR: 2DVjtT6pQ6aK8cobzGLIr5QvsxKqDYZY5QAG/Ddtcd0GZ8GIwoCQOm4wZ3qrCTJjgmFEssxSQT 4a2SYWxH1DIg== WDCIronportException: Internal Received: from cnf006060.ad.shared (HELO jedi-01.hgst.com) ([10.86.59.56]) by uls-op-cesaip01.wdc.com with ESMTP; 14 Aug 2020 14:48:28 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFC/RFT PATCH 2/6] arm64, numa: Change the numa init function name to be generic Date: Fri, 14 Aug 2020 14:47:21 -0700 Message-Id: <20200814214725.28818-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200814214725.28818-1-atish.patra@wdc.com> References: <20200814214725.28818-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_174832_778953_41543480 X-CRM114-Status: GOOD ( 16.80 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.141.245 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Catalin Marinas , Atish Patra , Zong Li , linux-riscv@lists.infradead.org, Will Deacon , linux-arch@vger.kernel.org, Rob Herring , Lorenzo Pieralisi , Ganapatrao Kulkarni , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Nick Hu , Greg Kroah-Hartman , Anup Patel , Palmer Dabbelt , Andrew Morton , Mike Rapoport Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org As we are using generic numa implementation code, modify the init function name to indicate that generic implementation. Signed-off-by: Atish Patra --- arch/arm64/mm/init.c | 4 ++-- drivers/base/arch_numa.c | 8 ++++++-- include/asm-generic/numa.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 481d22c32a2e..93b660229e1d 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -418,10 +418,10 @@ void __init bootmem_init(void) max_pfn = max_low_pfn = max; min_low_pfn = min; - arm64_numa_init(); + arch_numa_init(); /* - * must be done after arm64_numa_init() which calls numa_init() to + * must be done after arch_numa_init() which calls numa_init() to * initialize node_online_map that gets used in hugetlb_cma_reserve() * while allocating required CMA size across online nodes. */ diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index 73f8b49d485c..83341c807240 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -13,7 +13,9 @@ #include #include +#ifdef CONFIG_ARM64 #include +#endif #include struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; @@ -445,16 +447,18 @@ static int __init dummy_numa_init(void) } /** - * arm64_numa_init() - Initialize NUMA + * arch_numa_init() - Initialize NUMA * * Try each configured NUMA initialization method until one succeeds. The * last fallback is dummy single node config encomapssing whole memory. */ -void __init arm64_numa_init(void) +void __init arch_numa_init(void) { if (!numa_off) { +#ifdef CONFIG_ARM64 if (!acpi_disabled && !numa_init(arm64_acpi_numa_init)) return; +#endif if (acpi_disabled && !numa_init(of_numa_init)) return; } diff --git a/include/asm-generic/numa.h b/include/asm-generic/numa.h index 0635c0724b7c..309eca8c0b5d 100644 --- a/include/asm-generic/numa.h +++ b/include/asm-generic/numa.h @@ -27,7 +27,7 @@ static inline const struct cpumask *cpumask_of_node(int node) } #endif -void __init arm64_numa_init(void); +void __init arch_numa_init(void); int __init numa_add_memblk(int nodeid, u64 start, u64 end); void __init numa_set_distance(int from, int to, int distance); void __init numa_free_distance(void); @@ -41,7 +41,7 @@ void numa_remove_cpu(unsigned int cpu); static inline void numa_store_cpu_info(unsigned int cpu) { } static inline void numa_add_cpu(unsigned int cpu) { } static inline void numa_remove_cpu(unsigned int cpu) { } -static inline void arm64_numa_init(void) { } +static inline void arch_numa_init(void) { } static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { } #endif /* CONFIG_NUMA */ From patchwork Fri Aug 14 21:47:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11715207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58BD01392 for ; Fri, 14 Aug 2020 21:49:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C0BD20716 for ; Fri, 14 Aug 2020 21:49:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SPYn8Mw0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="dYHzppwK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C0BD20716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VzLUbXT78NjF+qS899TRp6tH3nALYrHurZv12h6suvA=; b=SPYn8Mw0485Kcg+Xvqdobu/Bs 3my+ZLqk0CszuPRbe4DtqruMMMnK4V/tc2ayjyIp5JtaXGJ8VLckmW8KJisM4z66zn/JPWBl3mFR9 FKhi7qvI5rc1lD1FgTzxao1i0ncSEKlUK8WipozhnmfCV+mDe3M3MDDoUI8adwNSz/2nMRZ4DUUkF UQ3zFIeSpNVw/PQF1qToe37Aca/GZT6pND7vmVE0Plfd58tWbnLkrhmpmDHWbwCNvDf7DDX6Zdish ViavV7YuqZDIOmQP/5LjC+sBvwehvJu1X41k4yz93hR2zHSflgX7UeS9TTHE8hnOXtz82LiQgEgQq 6/g9DGhrg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hZJ-0008Tm-L9; Fri, 14 Aug 2020 21:48:57 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hYv-0008IE-GE; Fri, 14 Aug 2020 21:48:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1597441713; x=1628977713; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0l8UMU0Nf80nnOcPq6fS4BA8LVPERcrIfgcS5BiLKhg=; b=dYHzppwKZRNTqari1W/+UMbO1/OuYaJ5tqoDuJlAlNhGU+ivBs6Lx1E3 gj5/6jmerslw6dx1BQeOSLaPoZwFSG24rraiDo8WwANP+f08mUYrgilOr I1LW707eXGiRzYX39GKQX/Js7eqlxUAe/poaJy3Ogaqf3qoin9Qw9YbV4 k24ktGJtypItrvhYx5zEt76ltXGbVWv/pTNneeeYwp6XbsMAVkn7PrghT ieOdp7PxtD+T97DJQFeo9LcXtmxngvd3aii7C2Df0uVksO4Wre+kpCoPG d60jt0TYgLYA/PVhibwXKuiOZaSU5Z1IfXzVMtdLPW5oIgYDl+6hm1//8 Q==; IronPort-SDR: nXqu3BIdOkQl8zeuy2mfK9whxVOREuMIhF+UNgRpMb6tAY3sDPEfFTgoxLpKEoKWlFzM2udEgN I4p1kcLfBTOai69nh4H9K+3TckqvR5pkqdicPy+Kv7ljEcKcgISY6YhnJFWqFDmf8+O7gXDIwd JcoxG3cjQKQxwx2FzuIBlwV1gdiIlE58WG079Eeh14v9nAMncXwoCj36IE2cmMS0TrYJExTybt f12T3rYzvDNGC8kfhEDrA8HmbHjwLArkBFCIW2U7H3GGnwzuHeQ2eb8X9mKzV6ZOrhazscRS/+ Sc8= X-IronPort-AV: E=Sophos;i="5.76,313,1592841600"; d="scan'208";a="254397130" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Aug 2020 05:48:30 +0800 IronPort-SDR: hLC02LxaymhKN8OZg9T2Z+5w76xfzAFyaiVBhS5CeoVfLTlkrVPoXAvG6dlVNalJjsbHdTJeyO yUiyWUUTqEdw== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 14:35:36 -0700 IronPort-SDR: GdemDOqwgj4kCAjq3L57gKGOb0BWT3gQzwEH1J+zYbKEVIRvsWAvkgfPVY9GgvZMY4uY0At5b4 uSyUDwfD8Rkg== WDCIronportException: Internal Received: from cnf006060.ad.shared (HELO jedi-01.hgst.com) ([10.86.59.56]) by uls-op-cesaip01.wdc.com with ESMTP; 14 Aug 2020 14:48:29 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFC/RFT PATCH 3/6] arm64, numa: Move pcibus_to_node definition to generic numa code Date: Fri, 14 Aug 2020 14:47:22 -0700 Message-Id: <20200814214725.28818-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200814214725.28818-1-atish.patra@wdc.com> References: <20200814214725.28818-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_174833_731334_38BF9EC8 X-CRM114-Status: GOOD ( 16.61 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.141.245 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Catalin Marinas , Atish Patra , Zong Li , linux-riscv@lists.infradead.org, Will Deacon , linux-arch@vger.kernel.org, Rob Herring , Lorenzo Pieralisi , Ganapatrao Kulkarni , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Nick Hu , Greg Kroah-Hartman , Anup Patel , Palmer Dabbelt , Andrew Morton , Mike Rapoport Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org pcibus_to_node is used only when numa is enabled and does not depend on ISA. Thus, it can be moved the generic numa implementation. Signed-off-by: Atish Patra --- arch/arm64/kernel/pci.c | 10 ---------- drivers/base/arch_numa.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 1006ed2d7c60..07c122946c11 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -54,16 +54,6 @@ int raw_pci_write(unsigned int domain, unsigned int bus, return b->ops->write(b, devfn, reg, len, val); } -#ifdef CONFIG_NUMA - -int pcibus_to_node(struct pci_bus *bus) -{ - return dev_to_node(&bus->dev); -} -EXPORT_SYMBOL(pcibus_to_node); - -#endif - #ifdef CONFIG_ACPI struct acpi_pci_generic_root_info { diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index 83341c807240..4ab1b20a615d 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #ifdef CONFIG_ARM64 @@ -60,6 +61,16 @@ EXPORT_SYMBOL(cpumask_of_node); #endif +#ifdef CONFIG_PCI + +int pcibus_to_node(struct pci_bus *bus) +{ + return dev_to_node(&bus->dev); +} +EXPORT_SYMBOL(pcibus_to_node); + +#endif + static void numa_update_cpu(unsigned int cpu, bool remove) { int nid = cpu_to_node(cpu); From patchwork Fri Aug 14 21:47:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11715215 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10DB8618 for ; Fri, 14 Aug 2020 21:50:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCD0E20716 for ; Fri, 14 Aug 2020 21:50:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pZoBQ+xe"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="IwX+9HHK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCD0E20716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sXZK5nEocZUnk+CJOr+85lYfAQ6fFJfjN+k2fPtX8vc=; b=pZoBQ+xeDzd1cKpYspJeArqy5 0GUYByJScZQL/MMHvZHD9QONNk+8aXA1flsWUmIiRtMMZ0Z/pGt4Mc+NfBP0mlp51GkUtO/+Zxl9G ynv4Favd8wcp4crkzShI04o6gvgyc/+4W2XokywovKarBuRxeiMW9ECkqp6dvDGkc617eH9FLdHHm aNIvuJV3eibd2G7gtybBpmrxvWgDV6TL9smeQBQtdr/JMjNP/R4JQDk6jsPYWX/Js/C9dXVu5lCZU OrbZWQIzOfcwE8mU7I73yTq9yfcARz63iuo4/DVLg88hLmr9/H6WUv9FNK1+7XUod3xWaGH/u0Lib gt55ck9Wg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hZM-0008Vb-Qm; Fri, 14 Aug 2020 21:49:00 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hYv-0008IJ-G8; Fri, 14 Aug 2020 21:48:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1597441713; x=1628977713; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=riQjp16BU3MGRmQFd57ikw/BK/iRNF+3tCmpWPLw6VM=; b=IwX+9HHKjmzG8OwMmiye5gXQw0wXjGJemUGSd/f3eliLOEyj5iXb/tdr phNlaNsl21bBwqHOBvPDPyH/pHfTgFzepiFmhN0koq1NZxszhtYOZUloS Th0nq1aMoP2/EL1buLxZtea5zt+AmrpJ2PsXdByqnH+WRAzW+mphuOa+h u9bU9SlT2Ct1U5hZWZAmTmOsOXW4x5yo7YbDxwag6yQb0qNCBdVklMGvx 0gULidPqwcOF/LMMOeYisDzveOg2js033iBk5+v3BH+3io/yGQiuB7/pQ piqGwTNjzW+VA511O8K+r8q7iwaBBur20HxKGb0rLoJq96YnA08S69eLK w==; IronPort-SDR: PNDzhXP1dse2Pd4uYQDTi8qS1TQp3y6wzZt3nwoln9rik8zrprnFtBHKYcCCDmk2guWRp0iAur dv/kWbUevn4dk02Vx6tDKehGZFkL7Zj7juH/MN/Eg5fBpuC8RH3BkV1eLKRDRmajGUQzLxg5tT z9KFsKrlgZdXwfc7rHNiE3WFikhATPsUMaBtXYrpVsJhqRcmg4YllF5w6MIcEcBxYB2YXhe7aq ST/oNXs8lkhqNudyRNf/eFWwrIGZvvjLU3VOfOpUYTC9QP9PkzaibYu4TkjyJxO/ZsVendSrNx jQM= X-IronPort-AV: E=Sophos;i="5.76,313,1592841600"; d="scan'208";a="254397133" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Aug 2020 05:48:31 +0800 IronPort-SDR: BmxxBkuU9taPbr0dtG34MgLbREnr6vLYG3tScQSCQCaGL5FFKQyzKYJdBlAo4QFnIoTlTMdpuS ihWYJvReUCOg== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 14:35:37 -0700 IronPort-SDR: 2qIF5Vqs6Zgae5cf+Vy+yHG7TJhk/dEiYuok3B/fYP/hVUpyilT7HsF7J4pS0Ix0FM311oNdZM CLhJfYjs37Rg== WDCIronportException: Internal Received: from cnf006060.ad.shared (HELO jedi-01.hgst.com) ([10.86.59.56]) by uls-op-cesaip01.wdc.com with ESMTP; 14 Aug 2020 14:48:30 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFC/RFT PATCH 4/6] riscv: Separate memory init from paging init Date: Fri, 14 Aug 2020 14:47:23 -0700 Message-Id: <20200814214725.28818-5-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200814214725.28818-1-atish.patra@wdc.com> References: <20200814214725.28818-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_174833_715919_CB64543E X-CRM114-Status: GOOD ( 15.04 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.141.245 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Catalin Marinas , Atish Patra , Zong Li , linux-riscv@lists.infradead.org, Will Deacon , linux-arch@vger.kernel.org, Rob Herring , Lorenzo Pieralisi , Ganapatrao Kulkarni , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Nick Hu , Greg Kroah-Hartman , Anup Patel , Palmer Dabbelt , Andrew Morton , Mike Rapoport Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently, we perform some memory init functions in paging init. But, that will be an issue for NUMA support where DT needs to be flattened before numa initialization and memblock_present can only be called after numa initialization. Move memory initialization related functions to a separate function. Signed-off-by: Atish Patra --- arch/riscv/include/asm/pgtable.h | 1 + arch/riscv/kernel/setup.c | 2 ++ arch/riscv/mm/init.c | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index eaea1f717010..515b42f98d34 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -466,6 +466,7 @@ static inline void __kernel_map_pages(struct page *page, int numpages, int enabl extern void *dtb_early_va; void setup_bootmem(void); void paging_init(void); +void misc_mem_init(void); #define FIRST_USER_ADDRESS 0 diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index f04373be54a6..32bb5a1bea05 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -79,6 +79,8 @@ void __init setup_arch(char **cmdline_p) #else unflatten_device_tree(); #endif + misc_mem_init(); + clint_init_boot_cpu(); #ifdef CONFIG_SWIOTLB diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 787c75f751a5..b8905ae2bbe7 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -570,8 +570,12 @@ static void __init resource_init(void) void __init paging_init(void) { setup_vm_final(); - sparse_init(); setup_zero_page(); +} + +void __init misc_mem_init(void) +{ + sparse_init(); zone_sizes_init(); resource_init(); } From patchwork Fri Aug 14 21:47:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11715209 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 966D1618 for ; Fri, 14 Aug 2020 21:49:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6104320866 for ; Fri, 14 Aug 2020 21:49:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oDU0S1yJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="P/xkM7Ke" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6104320866 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IINZOw7DWrxTKTdjXF1iLn7SejcK3rOCJ+rUB0/I9Xk=; b=oDU0S1yJoBYozBXHc6u4YT36K aj8vcjLZBRLylzeScTvzCejNzdT2V9dVEXas9tgQx7tNrtYOmPrQQ8fvVDDFgTh5gsKNCsXPmSuDq C7TBu78cDKjqWUMicnfvmuhWrlAIQJ4z50wmfidJ2KUAbbXrJdb2Ev25fzBYIJlI8tTVIFf9gefp/ OFYXcoby54TWm2r6NgZX4Z+i++wZr0xhDvFAC2t207zT9XH42HMTa1YnDYpLLFqxE8cao/jNSjlvO aNVw7sHh8T3uBaKce+olOvVbBl5KnTXwKbIzjDUjrpXaQucYamN/Qluqq54P4WYB8JZDOVTW+j2MP LDp9NBbQA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hZR-00006J-1q; Fri, 14 Aug 2020 21:49:05 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hYv-0008Im-Ps; Fri, 14 Aug 2020 21:48:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1597441713; x=1628977713; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UjeLYAGOcdXcIsgSttMVEHrk7RBdvzzoyHtETVrepjo=; b=P/xkM7Ken0tyPIpZTXb/JK0qLn1jvu5Al1qdimnzZTvjkNfxqIA24T9i nUkwS1DqFSVXfRdQpMrSVoMDsNI8VIhZzJM9HufVd2tzciUBtQNbMOW6Y 4gNM2pcXLTpLkBhzGQ7yMDyCpErp05eGWHc3N+om0OmmDoUuZDtNrS8Sg YyL6Ln14EoDW92y74bkbVDsEAUhACk2T+MxERtsRqFy/wtCUu/C1au4Us 8qaVpgvXm6zNs0khxjD/9xnZWJ0LzlJhEt2kveFtYUJEHtFFnLCMZKHII UeEE/LCYW8jQA4pPFyXdWVnYOuiadGpe3+UP9f4YbF1DPEyh2bKYdMo1f Q==; IronPort-SDR: oSiX8mroqiFVLPAT4tGax4A8GhMvByuwksRwrn9elC1dM2Zlmxl/V4susEK1lNtWUJeRXD78C7 SG25JdA4BaNYNanyoB0bVOJGaNCktdFcTn4RhLX2LwQY9dTFaOSEsZ0Mru3+Jiktg948b+91// xOLMlD7Hhd7pt5I3V/ys80Iv/ZbtDIaagh6Mxvf0sLCy+Tkt//7eSHlBRcJN4viY71wVqQfTb5 7kcQCmKfMr0eYt4Hy04y3uFaKcFxObzqU/Yo737OC1n3daHn/283X+d7Q4duN41ZMNDpOyOBnH xSA= X-IronPort-AV: E=Sophos;i="5.76,313,1592841600"; d="scan'208";a="254397136" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Aug 2020 05:48:32 +0800 IronPort-SDR: G6AW+sG6kjEyt8YbzfbFrFyC9SxvoUzBHVmjdpIZCTdVOCpeHOUWKZd15s81kXgkxxPmqw4Efb SyQqeGSsQYfg== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 14:35:37 -0700 IronPort-SDR: OiHQPqy3m8DvMgsYc0QMagm9siS9tQWyreMlyzSSKgLyP9TYhEfZkQosudZErrRfYErDIjVTC5 hyH3FpWbrN7Q== WDCIronportException: Internal Received: from cnf006060.ad.shared (HELO jedi-01.hgst.com) ([10.86.59.56]) by uls-op-cesaip01.wdc.com with ESMTP; 14 Aug 2020 14:48:31 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFC/RFT PATCH 5/6] riscv: Add support pte_protnone and pmd_protnone if CONFIG_NUMA_BALANCING Date: Fri, 14 Aug 2020 14:47:24 -0700 Message-Id: <20200814214725.28818-6-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200814214725.28818-1-atish.patra@wdc.com> References: <20200814214725.28818-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_174834_064938_9F9D7003 X-CRM114-Status: GOOD ( 13.90 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.141.245 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Catalin Marinas , Zong Li , linux-riscv@lists.infradead.org, Will Deacon , linux-arch@vger.kernel.org, Rob Herring , Lorenzo Pieralisi , Ganapatrao Kulkarni , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Nick Hu , Greg Kroah-Hartman , Anup Patel , Palmer Dabbelt , Andrew Morton , Mike Rapoport Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Greentime Hu These two functions are used to distinguish between PROT_NONENUMA protections and hinting fault protections. Signed-off-by: Greentime Hu --- arch/riscv/include/asm/pgtable.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 515b42f98d34..2751110675e6 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -183,6 +183,11 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) return (unsigned long)pfn_to_virt(pmd_val(pmd) >> _PAGE_PFN_SHIFT); } +static inline pte_t pmd_pte(pmd_t pmd) +{ + return __pte(pmd_val(pmd)); +} + /* Yields the page frame number (PFN) of a page table entry */ static inline unsigned long pte_pfn(pte_t pte) { @@ -286,6 +291,21 @@ static inline pte_t pte_mkhuge(pte_t pte) return pte; } +#ifdef CONFIG_NUMA_BALANCING +/* + * See the comment in include/asm-generic/pgtable.h + */ +static inline int pte_protnone(pte_t pte) +{ + return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE)) == _PAGE_PROT_NONE; +} + +static inline int pmd_protnone(pmd_t pmd) +{ + return pte_protnone(pmd_pte(pmd)); +} +#endif + /* Modify page protection bits */ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { From patchwork Fri Aug 14 21:47:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11715211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 450CD1392 for ; Fri, 14 Aug 2020 21:49:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1605F20716 for ; Fri, 14 Aug 2020 21:49:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ut32e//D"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="O+3folRK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1605F20716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=U5/Ne8e3mEGA+g/8MzSaQRkKaJPa4+xla1CIgXsQcHY=; b=ut32e//DvJ4yukZ5bqu//KMoY o2ZXq7Ebv9ZgILm4IUq/CL39pbDXg9o4oreEYsPa/cI8/cjOheORJBFz8EEarjT1g+gyelwO2S8nk GGrpNkkkpfZtpNUQi4AiPfLfYFLw8phX2nxgVnjjbAfmElhv59gtwNFxrc/+rOhURIxNAisTJnjDo 5Hzwivl8jzOH25HdnbkM02jH9gDk0lPrSF7C0V6WGsEnrr2y6Gwl/6n4Iwet1BrvC8d5yRM5guPuy w3NDFAwENhRefLeHkOFML5yPzkHzeFYN4FWcupYPqgeX8LHQjv9jb/IbqTGqA+nnk6aUHvksE0g7J zyXg5tA9w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hZb-0000CB-LK; Fri, 14 Aug 2020 21:49:16 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6hYx-0008IE-3d; Fri, 14 Aug 2020 21:48:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1597441714; x=1628977714; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bpKvYi5cx9vYWwDbNQ8jhGTPMfOv34iHRQFrh6Rdxoo=; b=O+3folRKaX+Pg54YPTFAgjt9WFR4r12S2sGAj5gLPlLoTqjDuTzaRyyk 6zlwEDavhhNFURPxWv5xAf9wOcbgngoo1bSWo5xAuDts/SNnvh63HTp4Q uYErV+2GazFcXpXnXNAx9va8xVSPhkiUFMMeahBWZFVIPCD3py5HsK9x8 yDCz4YFbiM7ZoSRdX4kDSMUL/pdr3W+WPAryR4+ynP136tBrWF5lNMdKA uhWaQIK+ggtdr3bQJpLefE8OTrgxFN5fzvEq3DOoX+x/4t3ddcCm9uLPs EEgfIFmljtvPC745EC7hoyve5X+CFBD2yR4tKGZ7JxnDdyAjvXxp5isqv Q==; IronPort-SDR: 1YubKhk9BcQUYbknMChj0ajrpqZERb3f9wRF6OUWVr17b9+OwWz16D7LSWrePd9ELu0urHNOig q/X6uCFBzvlf42Acv494NHMMKyw2Z/iIuWAQPvvUEDVDvZeXaPvrqTKnx0OGuRCLrj/xc+w67t m97EAqAp8tTHb9dzmsxc/5fFsBDNF58t5Dv00aU62sXyyaHAzUEyp19SFHgDsJnBN6y4evBv2Y lnPCTSpfBs4Id0y39aW+CgugLuZqB+aUqdjMuhQPx+1CVcllUT+vlNletc0EIRi+QGk/ldzQEF wH8= X-IronPort-AV: E=Sophos;i="5.76,313,1592841600"; d="scan'208";a="254397141" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Aug 2020 05:48:33 +0800 IronPort-SDR: I/DxlHr7BOHVy43BCuSpPG7JqAefyG4e3yee7BRyZvQiUDkuKZiknLxTX73YroFiX8AZ5j3wBs FZWfGoR/3BCg== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2020 14:35:38 -0700 IronPort-SDR: y4xadc0sFdmZtiUbZdLkblrbQ9WYPQZ6WosKZiphVX/7ztGGpCRL8DsBzLOgqMWU4VE2pokHET +WRi89OISuLg== WDCIronportException: Internal Received: from cnf006060.ad.shared (HELO jedi-01.hgst.com) ([10.86.59.56]) by uls-op-cesaip01.wdc.com with ESMTP; 14 Aug 2020 14:48:31 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFC/RFT PATCH 6/6] riscv: Add numa support for riscv64 platform Date: Fri, 14 Aug 2020 14:47:25 -0700 Message-Id: <20200814214725.28818-7-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200814214725.28818-1-atish.patra@wdc.com> References: <20200814214725.28818-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200814_174835_392145_1CA4050A X-CRM114-Status: GOOD ( 28.91 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.141.245 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Catalin Marinas , Atish Patra , Zong Li , linux-riscv@lists.infradead.org, Will Deacon , linux-arch@vger.kernel.org, Rob Herring , Lorenzo Pieralisi , Ganapatrao Kulkarni , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Nick Hu , Greg Kroah-Hartman , Anup Patel , Palmer Dabbelt , Andrew Morton , Mike Rapoport Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Use the generic numa implementation to add NUMA support for RISC-V. This is based on Greentime's patch[1] but modified to use generic NUMA implementation and few more fixes. [1] https://lkml.org/lkml/2020/1/10/233 Co-developed-by: Greentime Hu Signed-off-by: Greentime Hu Signed-off-by: Atish Patra --- arch/riscv/Kconfig | 31 ++++++++++++++++++++++++++++++- arch/riscv/include/asm/mmzone.h | 13 +++++++++++++ arch/riscv/include/asm/numa.h | 8 ++++++++ arch/riscv/include/asm/pci.h | 10 ++++++++++ arch/riscv/kernel/setup.c | 10 ++++++++-- arch/riscv/kernel/smpboot.c | 12 +++++++++++- arch/riscv/mm/init.c | 4 +++- 7 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 arch/riscv/include/asm/mmzone.h create mode 100644 arch/riscv/include/asm/numa.h diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 7b5905529146..4bd67f94aaac 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -137,7 +137,7 @@ config PAGE_OFFSET default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB config ARCH_FLATMEM_ENABLE - def_bool y + def_bool !NUMA config ARCH_SPARSEMEM_ENABLE def_bool y @@ -295,6 +295,35 @@ config TUNE_GENERIC endchoice +# Common NUMA Features +config NUMA + bool "Numa Memory Allocation and Scheduler Support" + select GENERIC_ARCH_NUMA + select OF_NUMA + select ARCH_SUPPORTS_NUMA_BALANCING + help + Enable NUMA (Non-Uniform Memory Access) support. + + The kernel will try to allocate memory used by a CPU on the + local memory of the CPU and add some more NUMA awareness to the kernel. + +config NODES_SHIFT + int "Maximum NUMA Nodes (as a power of 2)" + range 1 10 + default "2" + depends on NEED_MULTIPLE_NODES + help + Specify the maximum number of NUMA Nodes available on the target + system. Increases memory reserved to accommodate various tables. + +config USE_PERCPU_NUMA_NODE_ID + def_bool y + depends on NUMA + +config NEED_PER_CPU_EMBED_FIRST_CHUNK + def_bool y + depends on NUMA + config RISCV_ISA_C bool "Emit compressed instructions when building Linux" default y diff --git a/arch/riscv/include/asm/mmzone.h b/arch/riscv/include/asm/mmzone.h new file mode 100644 index 000000000000..fa17e01d9ab2 --- /dev/null +++ b/arch/riscv/include/asm/mmzone.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MMZONE_H +#define __ASM_MMZONE_H + +#ifdef CONFIG_NUMA + +#include + +extern struct pglist_data *node_data[]; +#define NODE_DATA(nid) (node_data[(nid)]) + +#endif /* CONFIG_NUMA */ +#endif /* __ASM_MMZONE_H */ diff --git a/arch/riscv/include/asm/numa.h b/arch/riscv/include/asm/numa.h new file mode 100644 index 000000000000..8c8cf4297cc3 --- /dev/null +++ b/arch/riscv/include/asm/numa.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_NUMA_H +#define __ASM_NUMA_H + +#include +#include + +#endif /* __ASM_NUMA_H */ diff --git a/arch/riscv/include/asm/pci.h b/arch/riscv/include/asm/pci.h index 1c473a1bd986..d6a0e59638c0 100644 --- a/arch/riscv/include/asm/pci.h +++ b/arch/riscv/include/asm/pci.h @@ -32,6 +32,16 @@ static inline int pci_proc_domain(struct pci_bus *bus) /* always show the domain in /proc */ return 1; } + +#ifdef CONFIG_NUMA +int pcibus_to_node(struct pci_bus *bus); +#ifndef cpumask_of_pcibus +#define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \ + cpu_all_mask : \ + cpumask_of_node(pcibus_to_node(bus))) +#endif +#endif /* CONFIG_NUMA */ + #endif /* CONFIG_PCI */ #endif /* _ASM_RISCV_PCI_H */ diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 32bb5a1bea05..1533ee5c6e56 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -104,13 +104,19 @@ void __init setup_arch(char **cmdline_p) static int __init topology_init(void) { - int i; + int i, ret; + + for_each_online_node(i) + register_one_node(i); for_each_possible_cpu(i) { struct cpu *cpu = &per_cpu(cpu_devices, i); cpu->hotpluggable = cpu_has_hotplug(i); - register_cpu(cpu, i); + ret = register_cpu(cpu, i); + if (unlikely(ret)) + pr_warn("Warning: %s: register_cpu %d failed (%d)\n", + __func__, i, ret); } return 0; diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 356825a57551..4e9bdb6230de 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -46,13 +47,18 @@ void __init smp_prepare_cpus(unsigned int max_cpus) { int cpuid; int ret; + unsigned int curr_cpuid; + + curr_cpuid = smp_processor_id(); + numa_store_cpu_info(curr_cpuid); + numa_add_cpu(curr_cpuid); /* This covers non-smp usecase mandated by "nosmp" option */ if (max_cpus == 0) return; for_each_possible_cpu(cpuid) { - if (cpuid == smp_processor_id()) + if (cpuid == curr_cpuid) continue; if (cpu_ops[cpuid]->cpu_prepare) { ret = cpu_ops[cpuid]->cpu_prepare(cpuid); @@ -60,6 +66,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) continue; } set_cpu_present(cpuid, true); + numa_store_cpu_info(cpuid); } } @@ -80,6 +87,7 @@ void __init setup_smp(void) if (hart == cpuid_to_hartid_map(0)) { BUG_ON(found_boot_cpu); found_boot_cpu = 1; + early_map_cpu_to_node(0, of_node_to_nid(dn)); continue; } if (cpuid >= NR_CPUS) { @@ -89,6 +97,7 @@ void __init setup_smp(void) } cpuid_to_hartid_map(cpuid) = hart; + early_map_cpu_to_node(cpuid, of_node_to_nid(dn)); cpuid++; } @@ -155,6 +164,7 @@ asmlinkage __visible void smp_callin(void) current->active_mm = mm; notify_cpu_starting(curr_cpuid); + numa_add_cpu(curr_cpuid); update_siblings_masks(curr_cpuid); set_cpu_online(curr_cpuid, 1); diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index b8905ae2bbe7..d1f4e94626aa 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "../kernel/head.h" @@ -190,7 +191,6 @@ void __init setup_bootmem(void) early_init_fdt_scan_reserved_mem(); memblock_allow_resize(); - memblock_dump_all(); for_each_memblock(memory, reg) { unsigned long start_pfn = memblock_region_memory_base_pfn(reg); @@ -575,9 +575,11 @@ void __init paging_init(void) void __init misc_mem_init(void) { + arch_numa_init(); sparse_init(); zone_sizes_init(); resource_init(); + memblock_dump_all(); } #ifdef CONFIG_SPARSEMEM_VMEMMAP