Commit a0e7b805 authored by Jiang Liu's avatar Jiang Liu Committed by Linus Torvalds

mm/m32r: prepare for removing num_physpages and simplify mem_init()

Prepare for removing num_physpages and simplify mem_init().
Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent de4bcddc
...@@ -129,11 +129,10 @@ unsigned long __init setup_memory(void) ...@@ -129,11 +129,10 @@ unsigned long __init setup_memory(void)
#define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn) #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
unsigned long __init zone_sizes_init(void) void __init zone_sizes_init(void)
{ {
unsigned long zones_size[MAX_NR_ZONES], zholes_size[MAX_NR_ZONES]; unsigned long zones_size[MAX_NR_ZONES], zholes_size[MAX_NR_ZONES];
unsigned long low, start_pfn; unsigned long low, start_pfn;
unsigned long holes = 0;
int nid, i; int nid, i;
mem_prof_t *mp; mem_prof_t *mp;
...@@ -147,7 +146,6 @@ unsigned long __init zone_sizes_init(void) ...@@ -147,7 +146,6 @@ unsigned long __init zone_sizes_init(void)
low = MAX_LOW_PFN(nid); low = MAX_LOW_PFN(nid);
zones_size[ZONE_DMA] = low - start_pfn; zones_size[ZONE_DMA] = low - start_pfn;
zholes_size[ZONE_DMA] = mp->holes; zholes_size[ZONE_DMA] = mp->holes;
holes += zholes_size[ZONE_DMA];
node_set_state(nid, N_NORMAL_MEMORY); node_set_state(nid, N_NORMAL_MEMORY);
free_area_init_node(nid, zones_size, start_pfn, zholes_size); free_area_init_node(nid, zones_size, start_pfn, zholes_size);
...@@ -161,6 +159,4 @@ unsigned long __init zone_sizes_init(void) ...@@ -161,6 +159,4 @@ unsigned long __init zone_sizes_init(void)
NODE_DATA(1)->node_zones->watermark[WMARK_MIN] = 0; NODE_DATA(1)->node_zones->watermark[WMARK_MIN] = 0;
NODE_DATA(1)->node_zones->watermark[WMARK_LOW] = 0; NODE_DATA(1)->node_zones->watermark[WMARK_LOW] = 0;
NODE_DATA(1)->node_zones->watermark[WMARK_HIGH] = 0; NODE_DATA(1)->node_zones->watermark[WMARK_HIGH] = 0;
return holes;
} }
...@@ -40,7 +40,6 @@ unsigned long mmu_context_cache_dat; ...@@ -40,7 +40,6 @@ unsigned long mmu_context_cache_dat;
#else #else
unsigned long mmu_context_cache_dat[NR_CPUS]; unsigned long mmu_context_cache_dat[NR_CPUS];
#endif #endif
static unsigned long hole_pages;
/* /*
* function prototype * function prototype
...@@ -57,7 +56,7 @@ void free_initrd_mem(unsigned long, unsigned long); ...@@ -57,7 +56,7 @@ void free_initrd_mem(unsigned long, unsigned long);
#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
#ifndef CONFIG_DISCONTIGMEM #ifndef CONFIG_DISCONTIGMEM
unsigned long __init zone_sizes_init(void) void __init zone_sizes_init(void)
{ {
unsigned long zones_size[MAX_NR_ZONES] = {0, }; unsigned long zones_size[MAX_NR_ZONES] = {0, };
unsigned long max_dma; unsigned long max_dma;
...@@ -83,11 +82,9 @@ unsigned long __init zone_sizes_init(void) ...@@ -83,11 +82,9 @@ unsigned long __init zone_sizes_init(void)
#endif /* CONFIG_MMU */ #endif /* CONFIG_MMU */
free_area_init_node(0, zones_size, start_pfn, 0); free_area_init_node(0, zones_size, start_pfn, 0);
return 0;
} }
#else /* CONFIG_DISCONTIGMEM */ #else /* CONFIG_DISCONTIGMEM */
extern unsigned long zone_sizes_init(void); extern void zone_sizes_init(void);
#endif /* CONFIG_DISCONTIGMEM */ #endif /* CONFIG_DISCONTIGMEM */
/*======================================================================* /*======================================================================*
...@@ -105,24 +102,7 @@ void __init paging_init(void) ...@@ -105,24 +102,7 @@ void __init paging_init(void)
for (i = 0 ; i < USER_PTRS_PER_PGD * 2 ; i++) for (i = 0 ; i < USER_PTRS_PER_PGD * 2 ; i++)
pgd_val(pg_dir[i]) = 0; pgd_val(pg_dir[i]) = 0;
#endif /* CONFIG_MMU */ #endif /* CONFIG_MMU */
hole_pages = zone_sizes_init(); zone_sizes_init();
}
int __init reservedpages_count(void)
{
int reservedpages, nid, i;
reservedpages = 0;
for_each_online_node(nid) {
unsigned long flags;
pgdat_resize_lock(NODE_DATA(nid), &flags);
for (i = 0 ; i < MAX_LOW_PFN(nid) - START_PFN(nid) ; i++)
if (PageReserved(nid_page_nr(nid, i)))
reservedpages++;
pgdat_resize_unlock(NODE_DATA(nid), &flags);
}
return reservedpages;
} }
/*======================================================================* /*======================================================================*
...@@ -131,20 +111,13 @@ int __init reservedpages_count(void) ...@@ -131,20 +111,13 @@ int __init reservedpages_count(void)
*======================================================================*/ *======================================================================*/
void __init mem_init(void) void __init mem_init(void)
{ {
int codesize, reservedpages, datasize, initsize;
int nid; int nid;
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
extern unsigned long memory_end; extern unsigned long memory_end;
#endif #endif
num_physpages = 0;
for_each_online_node(nid)
num_physpages += MAX_LOW_PFN(nid) - START_PFN(nid) + 1;
num_physpages -= hole_pages;
#ifndef CONFIG_DISCONTIGMEM #ifndef CONFIG_DISCONTIGMEM
max_mapnr = num_physpages; max_mapnr = get_num_physpages();
#endif /* CONFIG_DISCONTIGMEM */ #endif /* CONFIG_DISCONTIGMEM */
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
...@@ -160,19 +133,7 @@ void __init mem_init(void) ...@@ -160,19 +133,7 @@ void __init mem_init(void)
for_each_online_node(nid) for_each_online_node(nid)
free_all_bootmem_node(NODE_DATA(nid)); free_all_bootmem_node(NODE_DATA(nid));
reservedpages = reservedpages_count() - hole_pages; mem_init_print_info(NULL);
codesize = (unsigned long) &_etext - (unsigned long)&_text;
datasize = (unsigned long) &_edata - (unsigned long)&_etext;
initsize = (unsigned long) &__init_end - (unsigned long)&__init_begin;
printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
"%dk reserved, %dk data, %dk init)\n",
nr_free_pages() << (PAGE_SHIFT-10),
num_physpages << (PAGE_SHIFT-10),
codesize >> 10,
reservedpages << (PAGE_SHIFT-10),
datasize >> 10,
initsize >> 10);
} }
/*======================================================================* /*======================================================================*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment