From patchwork Thu Nov 19 00:38:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11916277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FBBCC6369E for ; Thu, 19 Nov 2020 00:40:43 +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 8A10022266 for ; Thu, 19 Nov 2020 00:40:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uNRp9hGI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="AbhKUj1F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A10022266 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+linux-arm-kernel=archiver.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=sR6FRcHQvcVR2e+VXw95PM1aHFVfYbuR5Hx+PKnW9dY=; b=uNRp9hGI0zuSlElfGL0eLbxop wLvHTHJiV/dV46TIYVtGVHfy5kAs8+AtudZBlVh5kvgqIq0tzFulJS2S0GKKYsCkDjMbUgxTq+N5S kU6a0kSvAFsO5wBGyJiFskO4JSkTDieRkKMzzANmJ6yM7p5FPOXZXbsFFJRtduSgDUxOKtPgOusoJ SbVujgzVBRDzNKQTOte4PU+LKwJNqSCVzNK0zU+z65nFUbmAIIhGcBzIB6v4BXYROGP8rOyHwNIiC v/OdVC9hMXKLWfFVJGu/hceco1V5KomuDog8YdHBEyCBD30dD8S1zI2k2yuwT17fadieaPYfnl/tb jz/DaXOCQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfXye-0006GR-9M; Thu, 19 Nov 2020 00:39:08 +0000 Received: from esa2.hgst.iphmx.com ([68.232.143.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfXyC-0006CJ-8W; Thu, 19 Nov 2020 00:38:41 +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=1605746719; x=1637282719; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CVYs1x4munyNqisP8RehwwbQA5Cb71FF96jIzbOi7/A=; b=AbhKUj1FPTu2nGPgzHw9Hx/RGxg1M4ktRa/zZbvKybj27UJau9M2velN dJUaJgxFIFc/dWKsdOtilB+tqc/03deflY1H2LGlx2AEMZUcv4sIN4JNZ vgUf9oxxvv3gdeK0FWnZlnOBLGv516d44/gK2nob6gaG4pFwXXiASROyQ eKHOHjvibOhsqXCJHoNucBlSSkxJEf71zjc6dsvhmiHqwD5ejB9KTZkzq 1g/mNVbhFiANEky9kMxu8aYjUzdubi7H2LMLBt5ncd23DiiA/Aq2me4mz rmRnbYH6SahFPzPZ02o3V7+FZUMBjjndth0BZ+kb397xjdLEB7KfA5BbI w==; IronPort-SDR: vj8lJKU5PyFUY8BbRnyhhCt2G1BFgpa1oLPTDwW4hlMnhbnQJKEYRJ7g9JdQnBLgWo+/NZy2P/ eY3nbpIa1fd3gKbyScgPrcpmdv2VeK4sYfZ/KcLBhB436rYK8sPIkvt/6cGwkk117NdU+DZPXI Qn/BWGaCPu+ga6dZU/RPA0Ry8E2rGU6t+7Z93IW3AVwAQrXxqy/aRD9FpWmrHyGzBs9WcjK01u 2CFq1m5To6veUTIjyFf0EgngFXvVcYZklsdvEcfiA0PeSJ6nhM2Q1TosbmukWaKc6IFTW+pIop Doo= X-IronPort-AV: E=Sophos;i="5.77,488,1596470400"; d="scan'208";a="256529104" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Nov 2020 08:45:16 +0800 IronPort-SDR: btwnLYP5hlGvylH1iJ1OfAJojOKjQgtTJZ+8kOBrbfg7LvRI+lLUGXX7zt6mVI+auamWXazKUk PHtqU0PGWDWi0LPspbXeQv8dnpuc7XjbVakLRlbmbYtp7WafGPrleGh/tGWaNJ+0RDCyGpVF29 9Dk8NvPGgqTAp/86eZea9DomtlxvcQ25Ag6tLZZCY5P1l3j9cPucdFfazXTj0YIvfa0QXxm307 NSIjhaUoGNAdgJa8dO5LIZxMmn65DeZJ01ImsIt0k8y/p0WT/ytYJIbHAE/M6EfEdO320JYapo 0XVEsGHqAM7zZLY7yS+L3chs Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2020 16:23:08 -0800 IronPort-SDR: BDXAQ107e5nYkAadgPiLauOOmd79ned360nZAHxRg1wqiOC/zpBY8BhFU2FaauwYJHhYLIv+56 5p73aQ+agfwfJGeI939XGTVy8JPxQ0R9cch3t00FYbfu7LPN3up5F91tzw0qyqAzGov27u3UrT KMxfCraJgnkQnbcH5DrdgSCNpYwEs4QsmsKFX8qn03H6338Z/QurNN1dB+5WsFiI0Z6WNxdsVj EGig8XMnfFNvXg+sCnPDiTfwzWRpUfDMza1GnqPhCSAvIRuAPuKuontM68ROv+b1jVb2aW7/p4 4kM= WDCIronportException: Internal Received: from 6hj08h2.ad.shared (HELO jedi-01.hgst.com) ([10.86.61.71]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Nov 2020 16:38:36 -0800 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v5 2/5] numa: Move numa implementation to common code Date: Wed, 18 Nov 2020 16:38:26 -0800 Message-Id: <20201119003829.1282810-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201119003829.1282810-1-atish.patra@wdc.com> References: <20201119003829.1282810-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-20201118_193840_470362_38639898 X-CRM114-Status: GOOD ( 22.43 ) 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 , Jonathan Cameron , Atish Patra , linux-riscv@lists.infradead.org, Will Deacon , Ard Biesheuvel , linux-arch@vger.kernel.org, Zhengyuan Liu , Baoquan He , Anup Patel , Daniel Lezcano , Steven Price , Greentime Hu , Albert Ou , Arnd Bergmann , Anshuman Khandual , Paul Walmsley , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , Palmer Dabbelt , Andrew Morton , Mike Rapoport Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.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 Acked-by: Jonathan Cameron Tested-by: Jonathan Cameron Acked-by: Catalin Marinas --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/numa.h | 48 +---------------- 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 | 52 +++++++++++++++++++ 7 files changed, 61 insertions(+), 48 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 1515f6f153a0..4ebef80274fd 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -990,6 +990,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 ffc1dcdf1871..8c8cf4297cc3 100644 --- a/arch/arm64/include/asm/numa.h +++ b/arch/arm64/include/asm/numa.h @@ -3,52 +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) -{ - if (node == NUMA_NO_NODE) - return cpu_all_mask; - - return node_to_cpumask_map[node]; -} -#endif - -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); -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 arch_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 5ead3c3de3b6..cd60e4fed78f 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) += ptdump.o obj-$(CONFIG_PTDUMP_DEBUGFS) += ptdump_debugfs.o -obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o obj-$(CONFIG_ARM64_MTE) += mteswap.o KASAN_SANITIZE_physaddr.o += n diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 8d7001712062..c5956c8845cc 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 41369fc7004f..7d65ea07de65 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..1a3ad6d29833 --- /dev/null +++ b/include/asm-generic/numa.h @@ -0,0 +1,52 @@ +/* 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) +{ + if (node == NUMA_NO_NODE) + return cpu_all_mask; + + return node_to_cpumask_map[node]; +} +#endif + +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); +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 arch_numa_init(void) { } +static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { } + +#endif /* CONFIG_NUMA */ + +#endif /* __ASM_GENERIC_NUMA_H */