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

mm/MIPS: use common help functions to free reserved pages

Use common help functions to free reserved pages.
Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7beb5987
...@@ -77,10 +77,9 @@ EXPORT_SYMBOL_GPL(empty_zero_page); ...@@ -77,10 +77,9 @@ EXPORT_SYMBOL_GPL(empty_zero_page);
/* /*
* Not static inline because used by IP27 special magic initialization code * Not static inline because used by IP27 special magic initialization code
*/ */
unsigned long setup_zero_pages(void) void setup_zero_pages(void)
{ {
unsigned int order; unsigned int order, i;
unsigned long size;
struct page *page; struct page *page;
if (cpu_has_vce) if (cpu_has_vce)
...@@ -94,15 +93,10 @@ unsigned long setup_zero_pages(void) ...@@ -94,15 +93,10 @@ unsigned long setup_zero_pages(void)
page = virt_to_page((void *)empty_zero_page); page = virt_to_page((void *)empty_zero_page);
split_page(page, order); split_page(page, order);
while (page < virt_to_page((void *)(empty_zero_page + (PAGE_SIZE << order)))) { for (i = 0; i < (1 << order); i++, page++)
SetPageReserved(page); mark_page_reserved(page);
page++;
}
size = PAGE_SIZE << order;
zero_page_mask = (size - 1) & PAGE_MASK;
return 1UL << order; zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK;
} }
#ifdef CONFIG_MIPS_MT_SMTC #ifdef CONFIG_MIPS_MT_SMTC
...@@ -380,7 +374,7 @@ void __init mem_init(void) ...@@ -380,7 +374,7 @@ void __init mem_init(void)
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
totalram_pages += free_all_bootmem(); totalram_pages += free_all_bootmem();
totalram_pages -= setup_zero_pages(); /* Setup zeroed pages. */ setup_zero_pages(); /* Setup zeroed pages. */
reservedpages = ram = 0; reservedpages = ram = 0;
for (tmp = 0; tmp < max_low_pfn; tmp++) for (tmp = 0; tmp < max_low_pfn; tmp++)
...@@ -440,11 +434,8 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end) ...@@ -440,11 +434,8 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
struct page *page = pfn_to_page(pfn); struct page *page = pfn_to_page(pfn);
void *addr = phys_to_virt(PFN_PHYS(pfn)); void *addr = phys_to_virt(PFN_PHYS(pfn));
ClearPageReserved(page);
init_page_count(page);
memset(addr, POISON_FREE_INITMEM, PAGE_SIZE); memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
__free_page(page); free_reserved_page(page);
totalram_pages++;
} }
printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10); printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
} }
...@@ -452,18 +443,14 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end) ...@@ -452,18 +443,14 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end) void free_initrd_mem(unsigned long start, unsigned long end)
{ {
free_init_pages("initrd memory", free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
virt_to_phys((void *)start),
virt_to_phys((void *)end));
} }
#endif #endif
void __init_refok free_initmem(void) void __init_refok free_initmem(void)
{ {
prom_free_prom_memory(); prom_free_prom_memory();
free_init_pages("unused kernel memory", free_initmem_default(POISON_FREE_INITMEM);
__pa_symbol(&__init_begin),
__pa_symbol(&__init_end));
} }
#ifndef CONFIG_MIPS_PGD_C0_CONTEXT #ifndef CONFIG_MIPS_PGD_C0_CONTEXT
......
...@@ -457,7 +457,7 @@ void __init prom_free_prom_memory(void) ...@@ -457,7 +457,7 @@ void __init prom_free_prom_memory(void)
/* We got nothing to free here ... */ /* We got nothing to free here ... */
} }
extern unsigned long setup_zero_pages(void); extern void setup_zero_pages(void);
void __init paging_init(void) void __init paging_init(void)
{ {
...@@ -492,7 +492,7 @@ void __init mem_init(void) ...@@ -492,7 +492,7 @@ void __init mem_init(void)
totalram_pages += free_all_bootmem_node(NODE_DATA(node)); totalram_pages += free_all_bootmem_node(NODE_DATA(node));
} }
totalram_pages -= setup_zero_pages(); /* This comes from node 0 */ setup_zero_pages(); /* This comes from node 0 */
codesize = (unsigned long) &_etext - (unsigned long) &_text; codesize = (unsigned long) &_etext - (unsigned long) &_text;
datasize = (unsigned long) &_edata - (unsigned long) &_etext; datasize = (unsigned long) &_edata - (unsigned long) &_etext;
......
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