summaryrefslogtreecommitdiff
path: root/arch/x86
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2011-03-05 07:32:45 +0100
committerIngo Molnar <mingo@elte.hu>2011-03-05 07:32:45 +0100
commitca764aaf025d2c83054191895b366fa81a9ccf48 (patch)
treee8e3bc880f4b269c924ccdf51ba8d6f3ff33b765 /arch/x86
parentd04c579f971bf7d995db1ef7a7161c0143068859 (diff)
parent078a198906c796981f93ff100c210506e91aade5 (diff)
Merge branch 'x86-mm' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc into x86/mm
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/page_types.h2
-rw-r--r--arch/x86/kernel/setup.c8
-rw-r--r--arch/x86/mm/init_64.c54
-rw-r--r--arch/x86/mm/numa_64.c96
-rw-r--r--arch/x86/mm/numa_emulation.c20
5 files changed, 79 insertions, 101 deletions
diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h
index 97e6007e4edd..bce688d54c12 100644
--- a/arch/x86/include/asm/page_types.h
+++ b/arch/x86/include/asm/page_types.h
@@ -54,8 +54,6 @@ static inline phys_addr_t get_max_mapped(void)
extern unsigned long init_memory_mapping(unsigned long start,
unsigned long end);
-void init_memory_mapping_high(void);
-
extern void initmem_init(void);
extern void free_initmem(void);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 46e684f85b36..c3a606c41ce0 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -963,6 +963,14 @@ void __init setup_arch(char **cmdline_p)
max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT);
max_pfn_mapped = max_low_pfn_mapped;
+#ifdef CONFIG_X86_64
+ if (max_pfn > max_low_pfn) {
+ max_pfn_mapped = init_memory_mapping(1UL<<32,
+ max_pfn<<PAGE_SHIFT);
+ /* can we preseve max_low_pfn ?*/
+ max_low_pfn = max_pfn;
+ }
+#endif
memblock.current_limit = get_max_mapped();
/*
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 470cc4704a9a..c8813aa39740 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -606,63 +606,9 @@ kernel_physical_mapping_init(unsigned long start,
void __init initmem_init(void)
{
memblock_x86_register_active_regions(0, 0, max_pfn);
- init_memory_mapping_high();
}
#endif
-struct mapping_work_data {
- unsigned long start;
- unsigned long end;
- unsigned long pfn_mapped;
-};
-
-static int __init_refok
-mapping_work_fn(unsigned long start_pfn, unsigned long end_pfn, void *datax)
-{
- struct mapping_work_data *data = datax;
- unsigned long pfn_mapped;
- unsigned long final_start, final_end;
-
- final_start = max_t(unsigned long, start_pfn<<PAGE_SHIFT, data->start);
- final_end = min_t(unsigned long, end_pfn<<PAGE_SHIFT, data->end);
-
- if (final_end <= final_start)
- return 0;
-
- pfn_mapped = init_memory_mapping(final_start, final_end);
-
- if (pfn_mapped > data->pfn_mapped)
- data->pfn_mapped = pfn_mapped;
-
- return 0;
-}
-
-static unsigned long __init_refok
-init_memory_mapping_active_regions(unsigned long start, unsigned long end)
-{
- struct mapping_work_data data;
-
- data.start = start;
- data.end = end;
- data.pfn_mapped = 0;
-
- work_with_active_regions(MAX_NUMNODES, mapping_work_fn, &data);
-
- return data.pfn_mapped;
-}
-
-void __init_refok init_memory_mapping_high(void)
-{
- if (max_pfn > max_low_pfn) {
- max_pfn_mapped = init_memory_mapping_active_regions(1UL<<32,
- max_pfn<<PAGE_SHIFT);
- /* can we preserve max_low_pfn ? */
- max_low_pfn = max_pfn;
-
- memblock.current_limit = get_max_mapped();
- }
-}
-
void __init paging_init(void)
{
unsigned long max_zone_pfns[MAX_NR_ZONES];
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index 74064e8ae79f..9ec0f209a6a4 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -543,8 +543,6 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
if (!numa_meminfo_cover_memory(mi))
return -EINVAL;
- init_memory_mapping_high();
-
/* Finally register nodes. */
for_each_node_mask(nid, node_possible_map) {
u64 start = (u64)max_pfn << PAGE_SHIFT;
@@ -564,6 +562,15 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
return 0;
}
+/**
+ * dummy_numma_init - Fallback dummy NUMA init
+ *
+ * Used if there's no underlying NUMA architecture, NUMA initialization
+ * fails, or NUMA is disabled on the command line.
+ *
+ * Must online at least one node and add memory blocks that cover all
+ * allowed memory. This function must not fail.
+ */
static int __init dummy_numa_init(void)
{
printk(KERN_INFO "%s\n",
@@ -577,57 +584,64 @@ static int __init dummy_numa_init(void)
return 0;
}
-void __init initmem_init(void)
+static int __init numa_init(int (*init_func)(void))
{
- int (*numa_init[])(void) = { [2] = dummy_numa_init };
- int i, j;
+ int i;
+ int ret;
- if (!numa_off) {
-#ifdef CONFIG_ACPI_NUMA
- numa_init[0] = x86_acpi_numa_init;
-#endif
-#ifdef CONFIG_AMD_NUMA
- numa_init[1] = amd_numa_init;
-#endif
- }
+ for (i = 0; i < MAX_LOCAL_APIC; i++)
+ set_apicid_to_node(i, NUMA_NO_NODE);
- for (i = 0; i < ARRAY_SIZE(numa_init); i++) {
- if (!numa_init[i])
- continue;
+ nodes_clear(numa_nodes_parsed);
+ nodes_clear(node_possible_map);
+ nodes_clear(node_online_map);
+ memset(&numa_meminfo, 0, sizeof(numa_meminfo));
+ remove_all_active_ranges();
+ numa_reset_distance();
- for (j = 0; j < MAX_LOCAL_APIC; j++)
- set_apicid_to_node(j, NUMA_NO_NODE);
+ ret = init_func();
+ if (ret < 0)
+ return ret;
+ ret = numa_cleanup_meminfo(&numa_meminfo);
+ if (ret < 0)
+ return ret;
- nodes_clear(numa_nodes_parsed);
- nodes_clear(node_possible_map);
- nodes_clear(node_online_map);
- memset(&numa_meminfo, 0, sizeof(numa_meminfo));
- remove_all_active_ranges();
- numa_reset_distance();
+ numa_emulation(&numa_meminfo, numa_distance_cnt);
- if (numa_init[i]() < 0)
- continue;
+ ret = numa_register_memblks(&numa_meminfo);
+ if (ret < 0)
+ return ret;
- if (numa_cleanup_meminfo(&numa_meminfo) < 0)
- continue;
+ for (i = 0; i < nr_cpu_ids; i++) {
+ int nid = early_cpu_to_node(i);
- numa_emulation(&numa_meminfo, numa_distance_cnt);
-
- if (numa_register_memblks(&numa_meminfo) < 0)
+ if (nid == NUMA_NO_NODE)
continue;
+ if (!node_online(nid))
+ numa_clear_node(i);
+ }
+ numa_init_array();
+ return 0;
+}
- for (j = 0; j < nr_cpu_ids; j++) {
- int nid = early_cpu_to_node(j);
+void __init initmem_init(void)
+{
+ int ret;
- if (nid == NUMA_NO_NODE)
- continue;
- if (!node_online(nid))
- numa_clear_node(j);
- }
- numa_init_array();
- return;
+ if (!numa_off) {
+#ifdef CONFIG_ACPI_NUMA
+ ret = numa_init(x86_acpi_numa_init);
+ if (!ret)
+ return;
+#endif
+#ifdef CONFIG_AMD_NUMA
+ ret = numa_init(amd_numa_init);
+ if (!ret)
+ return;
+#endif
}
- BUG();
+
+ numa_init(dummy_numa_init);
}
unsigned long __init numa_free_all_bootmem(void)
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index aeecea93820f..3696be0c2204 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -301,6 +301,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
const u64 max_addr = max_pfn << PAGE_SHIFT;
u8 *phys_dist = NULL;
size_t phys_size = numa_dist_cnt * numa_dist_cnt * sizeof(phys_dist[0]);
+ int dfl_phys_nid;
int i, j, ret;
if (!emu_cmdline)
@@ -357,6 +358,19 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
node_distance(i, j);
}
+ /* determine the default phys nid to use for unmapped nodes */
+ dfl_phys_nid = NUMA_NO_NODE;
+ for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++) {
+ if (emu_nid_to_phys[i] != NUMA_NO_NODE) {
+ dfl_phys_nid = emu_nid_to_phys[i];
+ break;
+ }
+ }
+ if (dfl_phys_nid == NUMA_NO_NODE) {
+ pr_warning("NUMA: Warning: can't determine default physical node, disabling emulation\n");
+ goto no_emu;
+ }
+
/* commit */
*numa_meminfo = ei;
@@ -377,7 +391,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
/* make sure all emulated nodes are mapped to a physical node */
for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)
if (emu_nid_to_phys[i] == NUMA_NO_NODE)
- emu_nid_to_phys[i] = 0;
+ emu_nid_to_phys[i] = dfl_phys_nid;
/*
* Transform distance table. numa_set_distance() ignores all
@@ -417,9 +431,7 @@ void __cpuinit numa_add_cpu(int cpu)
{
int physnid, nid;
- nid = numa_cpu_node(cpu);
- if (nid == NUMA_NO_NODE)
- nid = early_cpu_to_node(cpu);
+ nid = early_cpu_to_node(cpu);
BUG_ON(nid == NUMA_NO_NODE || !node_online(nid));
physnid = emu_nid_to_phys[nid];