aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2005-06-23 03:08:03 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-23 12:45:06 -0400
commit145e664231648121026d470094c200851a446a73 (patch)
treec9362f4ec3e3114afb9b7134ae89152cbbc73cd4
parent74b30be2e183bd9a12d0350698996e3d1969f290 (diff)
[PATCH] ppc64: sparsemem memory model
Provide the architecture specific implementation for SPARSEMEM for PPC64 systems. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Dave Hansen <haveblue@us.ibm.com> Signed-off-by: Mike Kravetz <kravetz@us.ibm.com> (in part) Signed-off-by: Martin Bligh <mbligh@aracnet.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/ppc64/Kconfig13
-rw-r--r--arch/ppc64/kernel/setup.c1
-rw-r--r--arch/ppc64/mm/Makefile2
-rw-r--r--arch/ppc64/mm/init.c18
-rw-r--r--include/asm-ppc64/mmzone.h36
-rw-r--r--include/asm-ppc64/page.h3
-rw-r--r--include/asm-ppc64/sparsemem.h16
7 files changed, 68 insertions, 21 deletions
diff --git a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
index c92d48fe06e5..6448231cb106 100644
--- a/arch/ppc64/Kconfig
+++ b/arch/ppc64/Kconfig
@@ -198,6 +198,13 @@ config HMT
198 This option enables hardware multithreading on RS64 cpus. 198 This option enables hardware multithreading on RS64 cpus.
199 pSeries systems p620 and p660 have such a cpu type. 199 pSeries systems p620 and p660 have such a cpu type.
200 200
201config ARCH_SELECT_MEMORY_MODEL
202 def_bool y
203
204config ARCH_FLATMEM_ENABLE
205 def_bool y
206 depends on !NUMA
207
201config ARCH_DISCONTIGMEM_ENABLE 208config ARCH_DISCONTIGMEM_ENABLE
202 def_bool y 209 def_bool y
203 depends on SMP && PPC_PSERIES 210 depends on SMP && PPC_PSERIES
@@ -209,6 +216,10 @@ config ARCH_DISCONTIGMEM_DEFAULT
209config ARCH_FLATMEM_ENABLE 216config ARCH_FLATMEM_ENABLE
210 def_bool y 217 def_bool y
211 218
219config ARCH_SPARSEMEM_ENABLE
220 def_bool y
221 depends on ARCH_DISCONTIGMEM_ENABLE
222
212source "mm/Kconfig" 223source "mm/Kconfig"
213 224
214config HAVE_ARCH_EARLY_PFN_TO_NID 225config HAVE_ARCH_EARLY_PFN_TO_NID
@@ -229,7 +240,7 @@ config NODES_SPAN_OTHER_NODES
229 240
230config NUMA 241config NUMA
231 bool "NUMA support" 242 bool "NUMA support"
232 depends on DISCONTIGMEM 243 default y if DISCONTIGMEM || SPARSEMEM
233 244
234config SCHED_SMT 245config SCHED_SMT
235 bool "SMT (Hyperthreading) scheduler support" 246 bool "SMT (Hyperthreading) scheduler support"
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c
index 8e439a817642..9e70ac90dec1 100644
--- a/arch/ppc64/kernel/setup.c
+++ b/arch/ppc64/kernel/setup.c
@@ -1055,6 +1055,7 @@ void __init setup_arch(char **cmdline_p)
1055 1055
1056 /* set up the bootmem stuff with available memory */ 1056 /* set up the bootmem stuff with available memory */
1057 do_init_bootmem(); 1057 do_init_bootmem();
1058 sparse_init();
1058 1059
1059 /* initialize the syscall map in systemcfg */ 1060 /* initialize the syscall map in systemcfg */
1060 setup_syscall_map(); 1061 setup_syscall_map();
diff --git a/arch/ppc64/mm/Makefile b/arch/ppc64/mm/Makefile
index ac522d57b2a7..3695d00d347f 100644
--- a/arch/ppc64/mm/Makefile
+++ b/arch/ppc64/mm/Makefile
@@ -6,6 +6,6 @@ EXTRA_CFLAGS += -mno-minimal-toc
6 6
7obj-y := fault.o init.o imalloc.o hash_utils.o hash_low.o tlb.o \ 7obj-y := fault.o init.o imalloc.o hash_utils.o hash_low.o tlb.o \
8 slb_low.o slb.o stab.o mmap.o 8 slb_low.o slb.o stab.o mmap.o
9obj-$(CONFIG_DISCONTIGMEM) += numa.o 9obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o
10obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 10obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
11obj-$(CONFIG_PPC_MULTIPLATFORM) += hash_native.o 11obj-$(CONFIG_PPC_MULTIPLATFORM) += hash_native.o
diff --git a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c
index 29dbe084c21f..b50b3a446dbe 100644
--- a/arch/ppc64/mm/init.c
+++ b/arch/ppc64/mm/init.c
@@ -531,7 +531,7 @@ EXPORT_SYMBOL(page_is_ram);
531 * Initialize the bootmem system and give it all the memory we 531 * Initialize the bootmem system and give it all the memory we
532 * have available. 532 * have available.
533 */ 533 */
534#ifndef CONFIG_DISCONTIGMEM 534#ifndef CONFIG_NEED_MULTIPLE_NODES
535void __init do_init_bootmem(void) 535void __init do_init_bootmem(void)
536{ 536{
537 unsigned long i; 537 unsigned long i;
@@ -553,12 +553,20 @@ void __init do_init_bootmem(void)
553 553
554 max_pfn = max_low_pfn; 554 max_pfn = max_low_pfn;
555 555
556 /* add all physical memory to the bootmem map. Also find the first */ 556 /* Add all physical memory to the bootmem map, mark each area
557 * present.
558 */
557 for (i=0; i < lmb.memory.cnt; i++) { 559 for (i=0; i < lmb.memory.cnt; i++) {
558 unsigned long physbase, size; 560 unsigned long physbase, size;
561 unsigned long start_pfn, end_pfn;
559 562
560 physbase = lmb.memory.region[i].physbase; 563 physbase = lmb.memory.region[i].physbase;
561 size = lmb.memory.region[i].size; 564 size = lmb.memory.region[i].size;
565
566 start_pfn = physbase >> PAGE_SHIFT;
567 end_pfn = start_pfn + (size >> PAGE_SHIFT);
568 memory_present(0, start_pfn, end_pfn);
569
562 free_bootmem(physbase, size); 570 free_bootmem(physbase, size);
563 } 571 }
564 572
@@ -597,7 +605,7 @@ void __init paging_init(void)
597 free_area_init_node(0, NODE_DATA(0), zones_size, 605 free_area_init_node(0, NODE_DATA(0), zones_size,
598 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size); 606 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size);
599} 607}
600#endif /* CONFIG_DISCONTIGMEM */ 608#endif /* ! CONFIG_NEED_MULTIPLE_NODES */
601 609
602static struct kcore_list kcore_vmem; 610static struct kcore_list kcore_vmem;
603 611
@@ -628,7 +636,7 @@ module_init(setup_kcore);
628 636
629void __init mem_init(void) 637void __init mem_init(void)
630{ 638{
631#ifdef CONFIG_DISCONTIGMEM 639#ifdef CONFIG_NEED_MULTIPLE_NODES
632 int nid; 640 int nid;
633#endif 641#endif
634 pg_data_t *pgdat; 642 pg_data_t *pgdat;
@@ -639,7 +647,7 @@ void __init mem_init(void)
639 num_physpages = max_low_pfn; /* RAM is assumed contiguous */ 647 num_physpages = max_low_pfn; /* RAM is assumed contiguous */
640 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); 648 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
641 649
642#ifdef CONFIG_DISCONTIGMEM 650#ifdef CONFIG_NEED_MULTIPLE_NODES
643 for_each_online_node(nid) { 651 for_each_online_node(nid) {
644 if (NODE_DATA(nid)->node_spanned_pages != 0) { 652 if (NODE_DATA(nid)->node_spanned_pages != 0) {
645 printk("freeing bootmem node %x\n", nid); 653 printk("freeing bootmem node %x\n", nid);
diff --git a/include/asm-ppc64/mmzone.h b/include/asm-ppc64/mmzone.h
index ecc4b07507d6..ed473f4b0152 100644
--- a/include/asm-ppc64/mmzone.h
+++ b/include/asm-ppc64/mmzone.h
@@ -10,9 +10,20 @@
10#include <linux/config.h> 10#include <linux/config.h>
11#include <asm/smp.h> 11#include <asm/smp.h>
12 12
13#ifdef CONFIG_DISCONTIGMEM 13/* generic non-linear memory support:
14 *
15 * 1) we will not split memory into more chunks than will fit into the
16 * flags field of the struct page
17 */
18
19
20#ifdef CONFIG_NEED_MULTIPLE_NODES
14 21
15extern struct pglist_data *node_data[]; 22extern struct pglist_data *node_data[];
23/*
24 * Return a pointer to the node data for node n.
25 */
26#define NODE_DATA(nid) (node_data[nid])
16 27
17/* 28/*
18 * Following are specific to this numa platform. 29 * Following are specific to this numa platform.
@@ -47,30 +58,27 @@ static inline int pa_to_nid(unsigned long pa)
47 return nid; 58 return nid;
48} 59}
49 60
50#define pfn_to_nid(pfn) pa_to_nid((pfn) << PAGE_SHIFT)
51
52/*
53 * Return a pointer to the node data for node n.
54 */
55#define NODE_DATA(nid) (node_data[nid])
56
57#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn) 61#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
58 62
59/* 63/*
60 * Following are macros that each numa implmentation must define. 64 * Following are macros that each numa implmentation must define.
61 */ 65 */
62 66
63/*
64 * Given a kernel address, find the home node of the underlying memory.
65 */
66#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
67
68#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 67#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
69#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn) 68#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
70 69
71#define local_mapnr(kvaddr) \ 70#define local_mapnr(kvaddr) \
72 ( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr)) 71 ( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr))
73 72
73#ifdef CONFIG_DISCONTIGMEM
74
75/*
76 * Given a kernel address, find the home node of the underlying memory.
77 */
78#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
79
80#define pfn_to_nid(pfn) pa_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
81
74/* Written this way to avoid evaluating arguments twice */ 82/* Written this way to avoid evaluating arguments twice */
75#define discontigmem_pfn_to_page(pfn) \ 83#define discontigmem_pfn_to_page(pfn) \
76({ \ 84({ \
@@ -91,6 +99,8 @@ static inline int pa_to_nid(unsigned long pa)
91 99
92#endif /* CONFIG_DISCONTIGMEM */ 100#endif /* CONFIG_DISCONTIGMEM */
93 101
102#endif /* CONFIG_NEED_MULTIPLE_NODES */
103
94#ifdef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID 104#ifdef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
95#define early_pfn_to_nid(pfn) pa_to_nid(((unsigned long)pfn) << PAGE_SHIFT) 105#define early_pfn_to_nid(pfn) pa_to_nid(((unsigned long)pfn) << PAGE_SHIFT)
96#endif 106#endif
diff --git a/include/asm-ppc64/page.h b/include/asm-ppc64/page.h
index 257d87eb7c34..a5893a305a09 100644
--- a/include/asm-ppc64/page.h
+++ b/include/asm-ppc64/page.h
@@ -217,7 +217,8 @@ extern u64 ppc64_pft_size; /* Log 2 of page table size */
217#define page_to_pfn(page) discontigmem_page_to_pfn(page) 217#define page_to_pfn(page) discontigmem_page_to_pfn(page)
218#define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn) 218#define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn)
219#define pfn_valid(pfn) discontigmem_pfn_valid(pfn) 219#define pfn_valid(pfn) discontigmem_pfn_valid(pfn)
220#else 220#endif
221#ifdef CONFIG_FLATMEM
221#define pfn_to_page(pfn) (mem_map + (pfn)) 222#define pfn_to_page(pfn) (mem_map + (pfn))
222#define page_to_pfn(page) ((unsigned long)((page) - mem_map)) 223#define page_to_pfn(page) ((unsigned long)((page) - mem_map))
223#define pfn_valid(pfn) ((pfn) < max_mapnr) 224#define pfn_valid(pfn) ((pfn) < max_mapnr)
diff --git a/include/asm-ppc64/sparsemem.h b/include/asm-ppc64/sparsemem.h
new file mode 100644
index 000000000000..c5bd47e57f17
--- /dev/null
+++ b/include/asm-ppc64/sparsemem.h
@@ -0,0 +1,16 @@
1#ifndef _ASM_PPC64_SPARSEMEM_H
2#define _ASM_PPC64_SPARSEMEM_H 1
3
4#ifdef CONFIG_SPARSEMEM
5/*
6 * SECTION_SIZE_BITS 2^N: how big each section will be
7 * MAX_PHYSADDR_BITS 2^N: how much physical address space we have
8 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space
9 */
10#define SECTION_SIZE_BITS 24
11#define MAX_PHYSADDR_BITS 38
12#define MAX_PHYSMEM_BITS 36
13
14#endif /* CONFIG_SPARSEMEM */
15
16#endif /* _ASM_PPC64_SPARSEMEM_H */