mm/score: use common help functions to free reserved pages
authorJiang Liu <liuj97@gmail.com>
Mon, 29 Apr 2013 22:06:49 +0000 (15:06 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 29 Apr 2013 22:54:31 +0000 (15:54 -0700)
Use common help functions to free reserved pages.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Chen Liqin <liqin.chen@sunplusct.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/score/mm/init.c

index cee6bce1e30c3663490e05d66725f89c907e62a9..1592aad7dbc4ade31b94314cfd3dc15915a3a288 100644 (file)
@@ -43,7 +43,7 @@ EXPORT_SYMBOL_GPL(empty_zero_page);
 
 static struct kcore_list kcore_mem, kcore_vmalloc;
 
-static unsigned long setup_zero_page(void)
+static void setup_zero_page(void)
 {
        struct page *page;
 
@@ -52,9 +52,7 @@ static unsigned long setup_zero_page(void)
                panic("Oh boy, that early out of memory?");
 
        page = virt_to_page((void *) empty_zero_page);
-       SetPageReserved(page);
-
-       return 1UL;
+       mark_page_reserved(page);
 }
 
 #ifndef CONFIG_NEED_MULTIPLE_NODES
@@ -84,7 +82,7 @@ void __init mem_init(void)
 
        high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
        totalram_pages += free_all_bootmem();
-       totalram_pages -= setup_zero_page();    /* Setup zeroed pages. */
+       setup_zero_page();      /* Setup zeroed pages. */
        reservedpages = 0;
 
        for (tmp = 0; tmp < max_low_pfn; tmp++)
@@ -109,37 +107,16 @@ void __init mem_init(void)
 }
 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
 
-static void free_init_pages(const char *what, unsigned long begin, unsigned long end)
-{
-       unsigned long pfn;
-
-       for (pfn = PFN_UP(begin); pfn < PFN_DOWN(end); pfn++) {
-               struct page *page = pfn_to_page(pfn);
-               void *addr = phys_to_virt(PFN_PHYS(pfn));
-
-               ClearPageReserved(page);
-               init_page_count(page);
-               memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
-               __free_page(page);
-               totalram_pages++;
-       }
-       printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
-}
-
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-       free_init_pages("initrd memory",
-               virt_to_phys((void *) start),
-               virt_to_phys((void *) end));
+       free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
 }
 #endif
 
 void __init_refok free_initmem(void)
 {
-       free_init_pages("unused kernel memory",
-       __pa(&__init_begin),
-       __pa(&__init_end));
+       free_initmem_default(POISON_FREE_INITMEM);
 }
 
 unsigned long pgd_current;