Commit 3f2b73c3 authored by Jiang Liu's avatar Jiang Liu Committed by Linus Torvalds

mm/frv: 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: David Howells <dhowells@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4e422de9
...@@ -876,6 +876,7 @@ late_initcall(setup_arch_serial); ...@@ -876,6 +876,7 @@ late_initcall(setup_arch_serial);
static void __init setup_linux_memory(void) static void __init setup_linux_memory(void)
{ {
unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem; unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem;
unsigned long physpages;
kstart = (unsigned long) &__kernel_image_start - PAGE_OFFSET; kstart = (unsigned long) &__kernel_image_start - PAGE_OFFSET;
kend = (unsigned long) &__kernel_image_end - PAGE_OFFSET; kend = (unsigned long) &__kernel_image_end - PAGE_OFFSET;
...@@ -893,19 +894,19 @@ static void __init setup_linux_memory(void) ...@@ -893,19 +894,19 @@ static void __init setup_linux_memory(void)
); );
/* pass the memory that the kernel can immediately use over to the bootmem allocator */ /* pass the memory that the kernel can immediately use over to the bootmem allocator */
max_mapnr = num_physpages = (memory_end - memory_start) >> PAGE_SHIFT; max_mapnr = physpages = (memory_end - memory_start) >> PAGE_SHIFT;
low_top_pfn = (KERNEL_LOWMEM_END - KERNEL_LOWMEM_START) >> PAGE_SHIFT; low_top_pfn = (KERNEL_LOWMEM_END - KERNEL_LOWMEM_START) >> PAGE_SHIFT;
high_mem = 0; high_mem = 0;
if (num_physpages > low_top_pfn) { if (physpages > low_top_pfn) {
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
high_mem = num_physpages - low_top_pfn; high_mem = physpages - low_top_pfn;
#else #else
max_mapnr = num_physpages = low_top_pfn; max_mapnr = physpages = low_top_pfn;
#endif #endif
} }
else { else {
low_top_pfn = num_physpages; low_top_pfn = physpages;
} }
min_low_pfn = memory_start >> PAGE_SHIFT; min_low_pfn = memory_start >> PAGE_SHIFT;
...@@ -979,7 +980,7 @@ static void __init setup_uclinux_memory(void) ...@@ -979,7 +980,7 @@ static void __init setup_uclinux_memory(void)
free_bootmem(memory_start, memory_end - memory_start); free_bootmem(memory_start, memory_end - memory_start);
high_memory = (void *) (memory_end & PAGE_MASK); high_memory = (void *) (memory_end & PAGE_MASK);
max_mapnr = num_physpages = ((unsigned long) high_memory - PAGE_OFFSET) >> PAGE_SHIFT; max_mapnr = ((unsigned long) high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
min_low_pfn = memory_start >> PAGE_SHIFT; min_low_pfn = memory_start >> PAGE_SHIFT;
max_low_pfn = memory_end >> PAGE_SHIFT; max_low_pfn = memory_end >> PAGE_SHIFT;
......
...@@ -78,7 +78,7 @@ void __init paging_init(void) ...@@ -78,7 +78,7 @@ void __init paging_init(void)
memset((void *) empty_zero_page, 0, PAGE_SIZE); memset((void *) empty_zero_page, 0, PAGE_SIZE);
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
if (num_physpages - num_mappedpages) { if (get_num_physpages() - num_mappedpages) {
pgd_t *pge; pgd_t *pge;
pud_t *pue; pud_t *pue;
pmd_t *pme; pmd_t *pme;
...@@ -96,7 +96,7 @@ void __init paging_init(void) ...@@ -96,7 +96,7 @@ void __init paging_init(void)
*/ */
zones_size[ZONE_NORMAL] = max_low_pfn - min_low_pfn; zones_size[ZONE_NORMAL] = max_low_pfn - min_low_pfn;
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
zones_size[ZONE_HIGHMEM] = num_physpages - num_mappedpages; zones_size[ZONE_HIGHMEM] = get_num_physpages() - num_mappedpages;
#endif #endif
free_area_init(zones_size); free_area_init(zones_size);
...@@ -114,45 +114,24 @@ void __init paging_init(void) ...@@ -114,45 +114,24 @@ void __init paging_init(void)
*/ */
void __init mem_init(void) void __init mem_init(void)
{ {
unsigned long npages = (memory_end - memory_start) >> PAGE_SHIFT; unsigned long code_size = _etext - _stext;
unsigned long tmp;
#ifdef CONFIG_MMU
unsigned long loop, pfn;
int datapages = 0;
#endif
int codek = 0, datak = 0;
/* this will put all low memory onto the freelists */ /* this will put all low memory onto the freelists */
free_all_bootmem(); free_all_bootmem();
#if defined(CONFIG_MMU) && defined(CONFIG_HIGHMEM)
{
unsigned long pfn;
#ifdef CONFIG_MMU for (pfn = get_num_physpages() - 1;
for (loop = 0 ; loop < npages ; loop++) pfn >= num_mappedpages; pfn--)
if (PageReserved(&mem_map[loop])) free_highmem_page(&mem_map[pfn]);
datapages++; }
#ifdef CONFIG_HIGHMEM
for (pfn = num_physpages - 1; pfn >= num_mappedpages; pfn--)
free_highmem_page(&mem_map[pfn]);
#endif
codek = ((unsigned long) &_etext - (unsigned long) &_stext) >> 10;
datak = datapages << (PAGE_SHIFT - 10);
#else
codek = (_etext - _stext) >> 10;
datak = 0; //(__bss_stop - _sdata) >> 10;
#endif #endif
tmp = nr_free_pages() << PAGE_SHIFT; mem_init_print_info(NULL);
printk("Memory available: %luKiB/%luKiB RAM, %luKiB/%luKiB ROM (%dKiB kernel code, %dKiB data)\n", if (rom_length > 0 && rom_length >= code_size)
tmp >> 10, printk("Memory available: %luKiB/%luKiB ROM\n",
npages << (PAGE_SHIFT - 10), (rom_length - code_size) >> 10, rom_length >> 10);
(rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
rom_length >> 10,
codek,
datak
);
} /* end mem_init() */ } /* end mem_init() */
/*****************************************************************************/ /*****************************************************************************/
......
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