From patchwork Wed Dec 12 17:40:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 1869141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id BEB1EDF266 for ; Wed, 12 Dec 2012 17:44:08 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TiqJ5-00028s-91; Wed, 12 Dec 2012 17:41:19 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TiqIy-00026u-Q3 for linux-arm-kernel@lists.infradead.org; Wed, 12 Dec 2012 17:41:13 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 12 Dec 2012 17:41:10 +0000 Received: from e103986-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 12 Dec 2012 17:41:09 +0000 From: Steve Capper To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 1/3] ARM: mm: Add discontiguous memory support. Date: Wed, 12 Dec 2012 17:40:47 +0000 Message-Id: <1355334049-10247-2-git-send-email-steve.capper@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1355334049-10247-1-git-send-email-steve.capper@arm.com> References: <1355334049-10247-1-git-send-email-steve.capper@arm.com> X-OriginalArrivalTime: 12 Dec 2012 17:41:09.0389 (UTC) FILETIME=[DED2C3D0:01CDD88F] X-MC-Unique: 112121217411006001 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121212_124113_150043_29DB572C X-CRM114-Status: GOOD ( 18.60 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [91.220.42.44 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Steve Capper X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds support for discontiguous memory, with a view to each discontiguous block being assigned to a NUMA node (in a future patch). Discontiguous memory should only be used to back NUMA on systems where sparse memory is not available. Signed-off-by: Steve Capper --- arch/arm/Kconfig | 15 +++++++++++++ arch/arm/include/asm/mmzone.h | 37 ++++++++++++++++++++++++++++++ arch/arm/mm/Makefile | 2 ++ arch/arm/mm/init.c | 9 ++++++++ arch/arm/mm/numa.c | 50 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+) create mode 100644 arch/arm/include/asm/mmzone.h create mode 100644 arch/arm/mm/numa.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9759fec..9846d89 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1159,8 +1159,23 @@ config ARM_TIMER_SP804 select CLKSRC_MMIO select HAVE_SCHED_CLOCK +config ARCH_FLATMEM_ENABLE + bool + depends on MMU + default y + +config ARCH_DISCONTIGMEM_ENABLE + bool + depends on MMU + default y + source arch/arm/mm/Kconfig +config NUMA_ALLOC_NODES + bool + depends on DISCONTIGMEM + default y + config ARM_NR_BANKS int default 16 if ARCH_EP93XX diff --git a/arch/arm/include/asm/mmzone.h b/arch/arm/include/asm/mmzone.h new file mode 100644 index 0000000..f6d7337 --- /dev/null +++ b/arch/arm/include/asm/mmzone.h @@ -0,0 +1,37 @@ +/* + * Discontiguous memory and NUMA support, based on the PowerPC implementation. + * + * Copyright (C) 2012 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef __ASM_ARM_MMZONE_H_ +#define __ASM_ARM_MMZONE_H_ +#ifdef __KERNEL__ + +#include + +#ifdef CONFIG_NUMA_ALLOC_NODES +#define NODE_DATA(nid) (node_data[nid]) +extern void __init arm_numa_alloc_nodes(unsigned long max_low); +extern struct pglist_data *node_data[]; +#else +#define arm_numa_alloc_nodes(_mlow) do {} while (0) +#endif + +#define pfn_to_nid(pfn) (0) + +#endif /* __KERNEL__ */ +#endif /* __ASM_ARM_MMZONE_H_ */ diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile index 8a9c4cb..57a7055 100644 --- a/arch/arm/mm/Makefile +++ b/arch/arm/mm/Makefile @@ -96,3 +96,5 @@ obj-$(CONFIG_CACHE_FEROCEON_L2) += cache-feroceon-l2.o obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o obj-$(CONFIG_CACHE_XSC3L2) += cache-xsc3l2.o obj-$(CONFIG_CACHE_TAUROS2) += cache-tauros2.o + +obj-$(CONFIG_NUMA_ALLOC_NODES) += numa.o diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index abe4eae..98488ee 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -33,6 +33,7 @@ #include #include +#include #include "mm.h" @@ -178,6 +179,12 @@ static void __init arm_bootmem_init(unsigned long start_pfn, pg_data_t *pgdat; /* + * If we have NUMA or discontiguous memory, allocate the required + * nodes by reserving memblocks. + */ + arm_numa_alloc_nodes(end_pfn); + + /* * Allocate the bootmem bitmap page. This must be in a region * of memory which has already been mapped. */ @@ -620,7 +627,9 @@ void __init mem_init(void) extern u32 itcm_end; #endif +#ifdef CONFIG_FLATMEM max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map; +#endif /* this will put all unused low memory onto the freelists */ free_unused_memmap(&meminfo); diff --git a/arch/arm/mm/numa.c b/arch/arm/mm/numa.c new file mode 100644 index 0000000..5141134 --- /dev/null +++ b/arch/arm/mm/numa.c @@ -0,0 +1,50 @@ +/* + * Discontiguous memory and NUMA support, based on the PowerPC implementation. + * + * Copyright (C) 2012 ARM Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +struct pglist_data *node_data[MAX_NUMNODES]; +EXPORT_SYMBOL(node_data); + +static unsigned int numa_node_count = 1; + +void __init arm_numa_alloc_nodes(unsigned long max_low) +{ + int node; + + for (node = 0; node < numa_node_count; node++) { + phys_addr_t pa = memblock_alloc_base(sizeof(pg_data_t), + L1_CACHE_BYTES, __pfn_to_phys(max_low)); + + NODE_DATA(node) = __va(pa); + memset(NODE_DATA(node), 0, sizeof(pg_data_t)); + NODE_DATA(node)->bdata = &bootmem_node_data[node]; + } +}