aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m32r
diff options
context:
space:
mode:
authorJiang Liu <liuj97@gmail.com>2013-07-03 18:03:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:36 -0400
commita0e7b805cd337d387373d197aa15d61a853e5ed7 (patch)
tree0e10d6286324c4ed191e4100ee67a36d2db05afb /arch/m32r
parentde4bcddc13be31c669fc74cd2b400e1e7a1fdbcf (diff)
mm/m32r: prepare for removing num_physpages and simplify mem_init()
Prepare for removing num_physpages and simplify mem_init(). Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Cc: Hirokazu Takata <takata@linux-m32r.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/m32r')
-rw-r--r--arch/m32r/mm/discontig.c6
-rw-r--r--arch/m32r/mm/init.c49
2 files changed, 6 insertions, 49 deletions
diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c
index 2c468e8b5853..27196303ce36 100644
--- a/arch/m32r/mm/discontig.c
+++ b/arch/m32r/mm/discontig.c
@@ -129,11 +129,10 @@ unsigned long __init setup_memory(void)
129#define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn) 129#define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
130#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) 130#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
131 131
132unsigned long __init zone_sizes_init(void) 132void __init zone_sizes_init(void)
133{ 133{
134 unsigned long zones_size[MAX_NR_ZONES], zholes_size[MAX_NR_ZONES]; 134 unsigned long zones_size[MAX_NR_ZONES], zholes_size[MAX_NR_ZONES];
135 unsigned long low, start_pfn; 135 unsigned long low, start_pfn;
136 unsigned long holes = 0;
137 int nid, i; 136 int nid, i;
138 mem_prof_t *mp; 137 mem_prof_t *mp;
139 138
@@ -147,7 +146,6 @@ unsigned long __init zone_sizes_init(void)
147 low = MAX_LOW_PFN(nid); 146 low = MAX_LOW_PFN(nid);
148 zones_size[ZONE_DMA] = low - start_pfn; 147 zones_size[ZONE_DMA] = low - start_pfn;
149 zholes_size[ZONE_DMA] = mp->holes; 148 zholes_size[ZONE_DMA] = mp->holes;
150 holes += zholes_size[ZONE_DMA];
151 149
152 node_set_state(nid, N_NORMAL_MEMORY); 150 node_set_state(nid, N_NORMAL_MEMORY);
153 free_area_init_node(nid, zones_size, start_pfn, zholes_size); 151 free_area_init_node(nid, zones_size, start_pfn, zholes_size);
@@ -161,6 +159,4 @@ unsigned long __init zone_sizes_init(void)
161 NODE_DATA(1)->node_zones->watermark[WMARK_MIN] = 0; 159 NODE_DATA(1)->node_zones->watermark[WMARK_MIN] = 0;
162 NODE_DATA(1)->node_zones->watermark[WMARK_LOW] = 0; 160 NODE_DATA(1)->node_zones->watermark[WMARK_LOW] = 0;
163 NODE_DATA(1)->node_zones->watermark[WMARK_HIGH] = 0; 161 NODE_DATA(1)->node_zones->watermark[WMARK_HIGH] = 0;
164
165 return holes;
166} 162}
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index a501838233ab..a4f8d934e25f 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -40,7 +40,6 @@ unsigned long mmu_context_cache_dat;
40#else 40#else
41unsigned long mmu_context_cache_dat[NR_CPUS]; 41unsigned long mmu_context_cache_dat[NR_CPUS];
42#endif 42#endif
43static unsigned long hole_pages;
44 43
45/* 44/*
46 * function prototype 45 * function prototype
@@ -57,7 +56,7 @@ void free_initrd_mem(unsigned long, unsigned long);
57#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) 56#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
58 57
59#ifndef CONFIG_DISCONTIGMEM 58#ifndef CONFIG_DISCONTIGMEM
60unsigned long __init zone_sizes_init(void) 59void __init zone_sizes_init(void)
61{ 60{
62 unsigned long zones_size[MAX_NR_ZONES] = {0, }; 61 unsigned long zones_size[MAX_NR_ZONES] = {0, };
63 unsigned long max_dma; 62 unsigned long max_dma;
@@ -83,11 +82,9 @@ unsigned long __init zone_sizes_init(void)
83#endif /* CONFIG_MMU */ 82#endif /* CONFIG_MMU */
84 83
85 free_area_init_node(0, zones_size, start_pfn, 0); 84 free_area_init_node(0, zones_size, start_pfn, 0);
86
87 return 0;
88} 85}
89#else /* CONFIG_DISCONTIGMEM */ 86#else /* CONFIG_DISCONTIGMEM */
90extern unsigned long zone_sizes_init(void); 87extern void zone_sizes_init(void);
91#endif /* CONFIG_DISCONTIGMEM */ 88#endif /* CONFIG_DISCONTIGMEM */
92 89
93/*======================================================================* 90/*======================================================================*
@@ -105,24 +102,7 @@ void __init paging_init(void)
105 for (i = 0 ; i < USER_PTRS_PER_PGD * 2 ; i++) 102 for (i = 0 ; i < USER_PTRS_PER_PGD * 2 ; i++)
106 pgd_val(pg_dir[i]) = 0; 103 pgd_val(pg_dir[i]) = 0;
107#endif /* CONFIG_MMU */ 104#endif /* CONFIG_MMU */
108 hole_pages = zone_sizes_init(); 105 zone_sizes_init();
109}
110
111int __init reservedpages_count(void)
112{
113 int reservedpages, nid, i;
114
115 reservedpages = 0;
116 for_each_online_node(nid) {
117 unsigned long flags;
118 pgdat_resize_lock(NODE_DATA(nid), &flags);
119 for (i = 0 ; i < MAX_LOW_PFN(nid) - START_PFN(nid) ; i++)
120 if (PageReserved(nid_page_nr(nid, i)))
121 reservedpages++;
122 pgdat_resize_unlock(NODE_DATA(nid), &flags);
123 }
124
125 return reservedpages;
126} 106}
127 107
128/*======================================================================* 108/*======================================================================*
@@ -131,20 +111,13 @@ int __init reservedpages_count(void)
131 *======================================================================*/ 111 *======================================================================*/
132void __init mem_init(void) 112void __init mem_init(void)
133{ 113{
134 int codesize, reservedpages, datasize, initsize;
135 int nid; 114 int nid;
136#ifndef CONFIG_MMU 115#ifndef CONFIG_MMU
137 extern unsigned long memory_end; 116 extern unsigned long memory_end;
138#endif 117#endif
139 118
140 num_physpages = 0;
141 for_each_online_node(nid)
142 num_physpages += MAX_LOW_PFN(nid) - START_PFN(nid) + 1;
143
144 num_physpages -= hole_pages;
145
146#ifndef CONFIG_DISCONTIGMEM 119#ifndef CONFIG_DISCONTIGMEM
147 max_mapnr = num_physpages; 120 max_mapnr = get_num_physpages();
148#endif /* CONFIG_DISCONTIGMEM */ 121#endif /* CONFIG_DISCONTIGMEM */
149 122
150#ifdef CONFIG_MMU 123#ifdef CONFIG_MMU
@@ -160,19 +133,7 @@ void __init mem_init(void)
160 for_each_online_node(nid) 133 for_each_online_node(nid)
161 free_all_bootmem_node(NODE_DATA(nid)); 134 free_all_bootmem_node(NODE_DATA(nid));
162 135
163 reservedpages = reservedpages_count() - hole_pages; 136 mem_init_print_info(NULL);
164 codesize = (unsigned long) &_etext - (unsigned long)&_text;
165 datasize = (unsigned long) &_edata - (unsigned long)&_etext;
166 initsize = (unsigned long) &__init_end - (unsigned long)&__init_begin;
167
168 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
169 "%dk reserved, %dk data, %dk init)\n",
170 nr_free_pages() << (PAGE_SHIFT-10),
171 num_physpages << (PAGE_SHIFT-10),
172 codesize >> 10,
173 reservedpages << (PAGE_SHIFT-10),
174 datasize >> 10,
175 initsize >> 10);
176} 137}
177 138
178/*======================================================================* 139/*======================================================================*