From: Tejun Heo <tj@kernel.org>
To: mingo@redhat.com, yinghai@kernel.org, rientjes@google.com,
tglx@linutronix.de, hpa@zytor.com, x86@kernel.org,
linux-kernel@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 21/25] x86, NUMA: Make 32bit use common NUMA init path
Date: Fri, 29 Apr 2011 17:28:40 +0200 [thread overview]
Message-ID: <1304090924-8197-22-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1304090924-8197-1-git-send-email-tj@kernel.org>
With both _numa_init() methods converted and the rest of init code
adjusted, numa_32.c now can switch from the 32bit only init code to
the common one in numa.c.
* Shim get_memcfg_*()'s are dropped and initmem_init() calls
x86_numa_init(), which is updated to handle NUMAQ.
* All boilerplate operations including node range limiting, pgdat
alloc/init are handled by numa_init(). 32bit only implementation is
removed.
* 32bit numa_add_memblk(), numa_set_distance() and
memory_add_physaddr_to_nid() removed and common versions in
numa_32.c enabled for 32bit.
This change causes the following behavior changes.
* NODE_DATA()->node_start_pfn/node_spanned_pages properly initialized
for 32bit too.
* Much more sanity checks and configuration cleanups.
* Proper handling of node distances.
* The same NUMA init messages as 64bit.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/include/asm/topology.h | 7 -
arch/x86/mm/numa.c | 10 +-
arch/x86/mm/numa_32.c | 232 +--------------------------------------
3 files changed, 7 insertions(+), 242 deletions(-)
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 8dba769..c006924 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -93,18 +93,11 @@ extern void setup_node_to_cpumask_map(void);
#define pcibus_to_node(bus) __pcibus_to_node(bus)
#ifdef CONFIG_X86_32
-extern unsigned long node_start_pfn[];
-extern unsigned long node_end_pfn[];
-#define node_has_online_mem(nid) (node_start_pfn[nid] != node_end_pfn[nid])
-
# define SD_CACHE_NICE_TRIES 1
# define SD_IDLE_IDX 1
-
#else
-
# define SD_CACHE_NICE_TRIES 2
# define SD_IDLE_IDX 2
-
#endif
/* sched_domains SD_NODE_INIT for NUMA machines */
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index a37b382..e6bc804 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -173,7 +173,6 @@ void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi)
(mi->nr_blks - idx) * sizeof(mi->blk[0]));
}
-#ifdef CONFIG_X86_64
/**
* numa_add_memblk - Add one numa_memblk to numa_meminfo
* @nid: NUMA node ID of the new memblk
@@ -189,7 +188,6 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)
{
return numa_add_memblk_to(nid, start, end, &numa_meminfo);
}
-#endif
/* Initialize bootmem allocator for a node */
static void __init setup_node_bootmem(int nid, u64 start, u64 end)
@@ -413,7 +411,6 @@ static int __init numa_alloc_distance(void)
return 0;
}
-#ifdef CONFIG_X86_64
/**
* numa_set_distance - Set NUMA distance from one NUMA to another
* @from: the 'from' node to set distance
@@ -452,7 +449,6 @@ void __init numa_set_distance(int from, int to, int distance)
numa_distance[from * numa_distance_cnt + to] = distance;
}
-#endif
int __node_distance(int from, int to)
{
@@ -626,6 +622,10 @@ static int __init dummy_numa_init(void)
void __init x86_numa_init(void)
{
if (!numa_off) {
+#ifdef CONFIG_X86_NUMAQ
+ if (!numa_init(numaq_numa_init))
+ return;
+#endif
#ifdef CONFIG_ACPI_NUMA
if (!numa_init(x86_acpi_numa_init))
return;
@@ -810,7 +810,7 @@ EXPORT_SYMBOL(cpumask_of_node);
#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
-#if defined(CONFIG_X86_64) && defined(CONFIG_MEMORY_HOTPLUG)
+#ifdef CONFIG_MEMORY_HOTPLUG
int memory_add_physaddr_to_nid(u64 start)
{
struct numa_meminfo *mi = &numa_meminfo;
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index fbd558f..c930e41 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -22,36 +22,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <linux/mm.h>
#include <linux/bootmem.h>
#include <linux/memblock.h>
-#include <linux/mmzone.h>
-#include <linux/highmem.h>
-#include <linux/initrd.h>
-#include <linux/nodemask.h>
-#include <linux/module.h>
-#include <linux/kexec.h>
-#include <linux/pfn.h>
-#include <linux/swap.h>
-#include <linux/acpi.h>
-
-#include <asm/e820.h>
-#include <asm/setup.h>
-#include <asm/mmzone.h>
-#include <asm/bios_ebda.h>
-#include <asm/proto.h>
-
-/*
- * numa interface - we expect the numa architecture specific code to have
- * populated the following initialisation.
- *
- * 1) node_online_map - the map of all nodes configured (online) in the system
- * 2) node_start_pfn - the starting page frame number for a node
- * 3) node_end_pfn - the ending page fram number for a node
- */
-unsigned long node_start_pfn[MAX_NUMNODES] __read_mostly;
-unsigned long node_end_pfn[MAX_NUMNODES] __read_mostly;
+#include "numa_internal.h"
#ifdef CONFIG_DISCONTIGMEM
/*
@@ -96,7 +70,6 @@ unsigned long node_memmap_size_bytes(int nid, unsigned long start_pfn,
}
#endif
-extern unsigned long find_max_low_pfn(void);
extern unsigned long highend_pfn, highstart_pfn;
#define LARGE_PAGE_BYTES (PTRS_PER_PTE * PAGE_SIZE)
@@ -105,68 +78,6 @@ static void *node_remap_start_vaddr[MAX_NUMNODES];
void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
/*
- * FLAT - support for basic PC memory model with discontig enabled, essentially
- * a single node with all available processors in it with a flat
- * memory map.
- */
-static int __init get_memcfg_numa_flat(void)
-{
- printk(KERN_DEBUG "NUMA - single node, flat memory mode\n");
-
- node_start_pfn[0] = 0;
- node_end_pfn[0] = max_pfn;
- memblock_x86_register_active_regions(0, 0, max_pfn);
-
- /* Indicate there is one node available. */
- nodes_clear(node_online_map);
- node_set_online(0);
- return 1;
-}
-
-/*
- * Find the highest page frame number we have available for the node
- */
-static void __init propagate_e820_map_node(int nid)
-{
- if (node_end_pfn[nid] > max_pfn)
- node_end_pfn[nid] = max_pfn;
- /*
- * if a user has given mem=XXXX, then we need to make sure
- * that the node _starts_ before that, too, not just ends
- */
- if (node_start_pfn[nid] > max_pfn)
- node_start_pfn[nid] = max_pfn;
- BUG_ON(node_start_pfn[nid] > node_end_pfn[nid]);
-}
-
-/*
- * Allocate memory for the pg_data_t for this node via a crude pre-bootmem
- * method. For node zero take this from the bottom of memory, for
- * subsequent nodes place them at node_remap_start_vaddr which contains
- * node local data in physically node local memory. See setup_memory()
- * for details.
- */
-static void __init allocate_pgdat(int nid)
-{
- char buf[16];
-
- NODE_DATA(nid) = alloc_remap(nid, ALIGN(sizeof(pg_data_t), PAGE_SIZE));
- if (!NODE_DATA(nid)) {
- unsigned long pgdat_phys;
- pgdat_phys = memblock_find_in_range(min_low_pfn<<PAGE_SHIFT,
- max_pfn_mapped<<PAGE_SHIFT,
- sizeof(pg_data_t),
- PAGE_SIZE);
- NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(pgdat_phys>>PAGE_SHIFT));
- memset(buf, 0, sizeof(buf));
- sprintf(buf, "NODE_DATA %d", nid);
- memblock_x86_reserve_range(pgdat_phys, pgdat_phys + sizeof(pg_data_t), buf);
- }
- printk(KERN_DEBUG "allocate_pgdat: node %d NODE_DATA %08lx\n",
- nid, (unsigned long)NODE_DATA(nid));
-}
-
-/*
* Remap memory allocator
*/
static unsigned long node_remap_start_pfn[MAX_NUMNODES];
@@ -322,76 +233,9 @@ void __init init_alloc_remap(int nid, u64 start, u64 end)
nid, node_pa, node_pa + size, remap_va, remap_va + size);
}
-static int get_memcfg_numaq(void)
-{
-#ifdef CONFIG_X86_NUMAQ
- int nid;
-
- if (numa_off)
- return 0;
-
- if (numaq_numa_init() < 0) {
- nodes_clear(numa_nodes_parsed);
- remove_all_active_ranges();
- return 0;
- }
-
- for_each_node_mask(nid, numa_nodes_parsed)
- node_set_online(nid);
- sort_node_map();
- return 1;
-#else
- return 0;
-#endif
-}
-
-static int get_memcfg_from_srat(void)
-{
-#ifdef CONFIG_ACPI_NUMA
- int nid;
-
- if (numa_off)
- return 0;
-
- if (x86_acpi_numa_init() < 0) {
- nodes_clear(numa_nodes_parsed);
- remove_all_active_ranges();
- return 0;
- }
-
- for_each_node_mask(nid, numa_nodes_parsed)
- node_set_online(nid);
- sort_node_map();
- return 1;
-#else
- return 0;
-#endif
-}
-
-static void get_memcfg_numa(void)
-{
- if (get_memcfg_numaq())
- return;
- if (get_memcfg_from_srat())
- return;
- get_memcfg_numa_flat();
-}
-
void __init initmem_init(void)
{
- int nid;
-
- get_memcfg_numa();
- numa_init_array();
-
- for_each_online_node(nid) {
- u64 start = (u64)node_start_pfn[nid] << PAGE_SHIFT;
- u64 end = min((u64)node_end_pfn[nid] << PAGE_SHIFT,
- (u64)max_pfn << PAGE_SHIFT);
-
- if (start < end)
- init_alloc_remap(nid, start, end);
- }
+ x86_numa_init();
#ifdef CONFIG_HIGHMEM
highstart_pfn = highend_pfn = max_pfn;
@@ -412,81 +256,9 @@ void __init initmem_init(void)
printk(KERN_DEBUG "Low memory ends at vaddr %08lx\n",
(ulong) pfn_to_kaddr(max_low_pfn));
- for_each_online_node(nid)
- allocate_pgdat(nid);
printk(KERN_DEBUG "High memory starts at vaddr %08lx\n",
(ulong) pfn_to_kaddr(highstart_pfn));
- for_each_online_node(nid)
- propagate_e820_map_node(nid);
-
- for_each_online_node(nid) {
- memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
- NODE_DATA(nid)->node_id = nid;
- }
setup_bootmem_allocator();
}
-
-#ifdef CONFIG_MEMORY_HOTPLUG
-static int paddr_to_nid(u64 addr)
-{
- int nid;
- unsigned long pfn = PFN_DOWN(addr);
-
- for_each_node(nid)
- if (node_start_pfn[nid] <= pfn &&
- pfn < node_end_pfn[nid])
- return nid;
-
- return -1;
-}
-
-/*
- * This function is used to ask node id BEFORE memmap and mem_section's
- * initialization (pfn_to_nid() can't be used yet).
- * If _PXM is not defined on ACPI's DSDT, node id must be found by this.
- */
-int memory_add_physaddr_to_nid(u64 addr)
-{
- int nid = paddr_to_nid(addr);
- return (nid >= 0) ? nid : 0;
-}
-
-EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
-#endif
-
-/* temporary shim, will go away soon */
-int __init numa_add_memblk(int nid, u64 start, u64 end)
-{
- unsigned long start_pfn = start >> PAGE_SHIFT;
- unsigned long end_pfn = end >> PAGE_SHIFT;
-
- printk(KERN_DEBUG "nid %d start_pfn %08lx end_pfn %08lx\n",
- nid, start_pfn, end_pfn);
-
- if (start >= (u64)max_pfn << PAGE_SHIFT) {
- printk(KERN_INFO "Ignoring SRAT pfns: %08lx - %08lx\n",
- start_pfn, end_pfn);
- return 0;
- }
-
- node_set_online(nid);
- memblock_x86_register_active_regions(nid, start_pfn,
- min(end_pfn, max_pfn));
-
- if (!node_has_online_mem(nid)) {
- node_start_pfn[nid] = start_pfn;
- node_end_pfn[nid] = end_pfn;
- } else {
- node_start_pfn[nid] = min(node_start_pfn[nid], start_pfn);
- node_end_pfn[nid] = max(node_end_pfn[nid], end_pfn);
- }
- return 0;
-}
-
-/* temporary shim, will go away soon */
-void __init numa_set_distance(int from, int to, int distance)
-{
- /* nada */
-}
--
1.7.1
next prev parent reply other threads:[~2011-04-29 15:30 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-29 15:28 [PATCHSET tip] x86, NUMA: Unify 32 and 64bit NUMA initialization Tejun Heo
2011-04-29 15:28 ` [PATCH 01/25] x86-64, NUMA: Simplify hotadd memory handling Tejun Heo
2011-04-29 15:28 ` [PATCH 02/25] x86-64, NUMA: trivial cleanups for setup_node_bootmem() Tejun Heo
2011-04-29 15:28 ` [PATCH 03/25] x86-64, NUMA: simplify nodedata allocation Tejun Heo
2011-04-29 17:23 ` Yinghai Lu
2011-04-30 12:02 ` Tejun Heo
2011-04-29 15:28 ` [PATCH 04/25] x86-32, NUMA: Automatically set apicid -> node in setup_local_APIC() Tejun Heo
2011-04-29 15:28 ` [PATCH 05/25] x86, NUMA: Unify 32/64bit numa_cpu_node() implementation Tejun Heo
2011-04-29 15:28 ` [PATCH 06/25] x86-32, NUMA: Make apic->x86_32_numa_cpu_node() optional Tejun Heo
2011-04-29 15:28 ` [PATCH 07/25] x86-32, NUMA: use sparse_memory_present_with_active_regions() Tejun Heo
2011-04-29 15:28 ` [PATCH 08/25] x86, NUMA: trivial cleanups Tejun Heo
2011-04-29 17:25 ` Yinghai Lu
2011-04-30 12:03 ` Tejun Heo
2011-04-30 16:24 ` Yinghai Lu
2011-04-30 18:00 ` Tejun Heo
2011-04-30 23:10 ` Yinghai Lu
2011-04-30 23:11 ` [PATCH] x86, numa: Rename setup_node_bootmem to setup_node_data Yinghai Lu
2011-04-29 15:28 ` [PATCH 09/25] x86, NUMA: rename srat_64.c to srat.c Tejun Heo
2011-04-29 15:28 ` [PATCH 10/25] x86, NUMA: make srat.c 32bit safe Tejun Heo
2011-04-29 15:28 ` [PATCH 11/25] x86-32, NUMA: Move get_memcfg_numa() into numa_32.c Tejun Heo
2011-04-29 15:28 ` [PATCH 12/25] x86, NUMA: Move numa_nodes_parsed to numa.[hc] Tejun Heo
2011-04-29 15:28 ` [PATCH 13/25] x86-32, NUMA: implement temporary NUMA init shims Tejun Heo
2011-04-29 15:28 ` [PATCH 14/25] x86-32, NUMA: Replace srat_32.c with srat.c Tejun Heo
2011-04-29 15:28 ` [PATCH 15/25] x86-32, NUMA: Update numaq to use new NUMA init protocol Tejun Heo
2011-04-29 15:28 ` [PATCH 16/25] x86, NUMA: Move NUMA init logic from numa_64.c to numa.c Tejun Heo
2011-04-29 15:28 ` [PATCH 17/25] x86, NUMA: Enable build of generic NUMA init code on 32bit Tejun Heo
2011-04-29 15:28 ` [PATCH 18/25] x86, NUMA: Remove long 64bit assumption from numa.c Tejun Heo
2011-04-29 15:28 ` [PATCH 19/25] x86-32, NUMA: Add @start and @end to init_alloc_remap() Tejun Heo
2011-04-29 15:28 ` [PATCH 20/25] x86, NUMA: Initialize and use remap allocator from setup_node_bootmem() Tejun Heo
2011-04-29 15:28 ` Tejun Heo [this message]
2011-04-29 15:28 ` [PATCH 22/25] x86, NUMA: Make numa_init_array() static Tejun Heo
2011-04-29 15:28 ` [PATCH 23/25] x86, NUMA: Rename amdtopology_64.c to amdtopology.c Tejun Heo
2011-04-29 15:28 ` [PATCH 24/25] x86, NUMA: Enable CONFIG_AMD_NUMA on 32bit too Tejun Heo
2011-04-29 15:28 ` [PATCH 25/25] x86, NUMA: Enable emulation " Tejun Heo
2011-04-29 18:15 ` [PATCHSET tip] x86, NUMA: Unify 32 and 64bit NUMA initialization Ingo Molnar
2011-04-29 20:14 ` Yinghai Lu
2011-04-30 12:17 ` Tejun Heo
2011-04-30 12:33 ` [PATCH] x86, NUMA: Fix empty memblk detection in numa_cleanup_meminfo() Tejun Heo
2011-04-30 12:35 ` Tejun Heo
2011-05-01 0:43 ` Yinghai Lu
2011-05-01 10:20 ` Tejun Heo
2011-05-01 19:44 ` [PATCH] x86, numa: Trim numa meminfo with max_pfn in separated loop Yinghai Lu
2011-04-30 16:31 ` [PATCHSET tip] x86, NUMA: Unify 32 and 64bit NUMA initialization Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1304090924-8197-22-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rientjes@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.