diff options
author | Jiang Liu <liuj97@gmail.com> | 2013-05-07 19:18:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-07 21:38:26 -0400 |
commit | 70affe4520c6f22f5b22b58b589c6ebbe3f8cbc9 (patch) | |
tree | a5d791be3fa2b58e9c527c9a1e0e0cfa2a94663f /arch/sparc/mm | |
parent | 0f47c9423c0fe468d0b5b153f9b9d6e8e20707eb (diff) |
mm/SPARC: use common help functions to free reserved pages
Use common help functions to free reserved pages.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sparc/mm')
-rw-r--r-- | arch/sparc/mm/init_32.c | 37 | ||||
-rw-r--r-- | arch/sparc/mm/init_64.c | 28 |
2 files changed, 9 insertions, 56 deletions
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index 4490c397bb5b..af472cf7c69a 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c | |||
@@ -366,45 +366,14 @@ void __init mem_init(void) | |||
366 | 366 | ||
367 | void free_initmem (void) | 367 | void free_initmem (void) |
368 | { | 368 | { |
369 | unsigned long addr; | 369 | num_physpages += free_initmem_default(POISON_FREE_INITMEM); |
370 | unsigned long freed; | ||
371 | |||
372 | addr = (unsigned long)(&__init_begin); | ||
373 | freed = (unsigned long)(&__init_end) - addr; | ||
374 | for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) { | ||
375 | struct page *p; | ||
376 | |||
377 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); | ||
378 | p = virt_to_page(addr); | ||
379 | |||
380 | ClearPageReserved(p); | ||
381 | init_page_count(p); | ||
382 | __free_page(p); | ||
383 | totalram_pages++; | ||
384 | num_physpages++; | ||
385 | } | ||
386 | printk(KERN_INFO "Freeing unused kernel memory: %ldk freed\n", | ||
387 | freed >> 10); | ||
388 | } | 370 | } |
389 | 371 | ||
390 | #ifdef CONFIG_BLK_DEV_INITRD | 372 | #ifdef CONFIG_BLK_DEV_INITRD |
391 | void free_initrd_mem(unsigned long start, unsigned long end) | 373 | void free_initrd_mem(unsigned long start, unsigned long end) |
392 | { | 374 | { |
393 | if (start < end) | 375 | num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM, |
394 | printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", | 376 | "initrd"); |
395 | (end - start) >> 10); | ||
396 | for (; start < end; start += PAGE_SIZE) { | ||
397 | struct page *p; | ||
398 | |||
399 | memset((void *)start, POISON_FREE_INITMEM, PAGE_SIZE); | ||
400 | p = virt_to_page(start); | ||
401 | |||
402 | ClearPageReserved(p); | ||
403 | init_page_count(p); | ||
404 | __free_page(p); | ||
405 | totalram_pages++; | ||
406 | num_physpages++; | ||
407 | } | ||
408 | } | 377 | } |
409 | #endif | 378 | #endif |
410 | 379 | ||
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index cf72a8a5b3aa..a7171997adfd 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c | |||
@@ -2059,8 +2059,7 @@ void __init mem_init(void) | |||
2059 | /* We subtract one to account for the mem_map_zero page | 2059 | /* We subtract one to account for the mem_map_zero page |
2060 | * allocated below. | 2060 | * allocated below. |
2061 | */ | 2061 | */ |
2062 | totalram_pages -= 1; | 2062 | num_physpages = totalram_pages - 1; |
2063 | num_physpages = totalram_pages; | ||
2064 | 2063 | ||
2065 | /* | 2064 | /* |
2066 | * Set up the zero page, mark it reserved, so that page count | 2065 | * Set up the zero page, mark it reserved, so that page count |
@@ -2071,7 +2070,7 @@ void __init mem_init(void) | |||
2071 | prom_printf("paging_init: Cannot alloc zero page.\n"); | 2070 | prom_printf("paging_init: Cannot alloc zero page.\n"); |
2072 | prom_halt(); | 2071 | prom_halt(); |
2073 | } | 2072 | } |
2074 | SetPageReserved(mem_map_zero); | 2073 | mark_page_reserved(mem_map_zero); |
2075 | 2074 | ||
2076 | codepages = (((unsigned long) _etext) - ((unsigned long) _start)); | 2075 | codepages = (((unsigned long) _etext) - ((unsigned long) _start)); |
2077 | codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT; | 2076 | codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT; |
@@ -2111,37 +2110,22 @@ void free_initmem(void) | |||
2111 | initend = (unsigned long)(__init_end) & PAGE_MASK; | 2110 | initend = (unsigned long)(__init_end) & PAGE_MASK; |
2112 | for (; addr < initend; addr += PAGE_SIZE) { | 2111 | for (; addr < initend; addr += PAGE_SIZE) { |
2113 | unsigned long page; | 2112 | unsigned long page; |
2114 | struct page *p; | ||
2115 | 2113 | ||
2116 | page = (addr + | 2114 | page = (addr + |
2117 | ((unsigned long) __va(kern_base)) - | 2115 | ((unsigned long) __va(kern_base)) - |
2118 | ((unsigned long) KERNBASE)); | 2116 | ((unsigned long) KERNBASE)); |
2119 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); | 2117 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); |
2120 | 2118 | ||
2121 | if (do_free) { | 2119 | if (do_free) |
2122 | p = virt_to_page(page); | 2120 | free_reserved_page(virt_to_page(page)); |
2123 | |||
2124 | ClearPageReserved(p); | ||
2125 | init_page_count(p); | ||
2126 | __free_page(p); | ||
2127 | totalram_pages++; | ||
2128 | } | ||
2129 | } | 2121 | } |
2130 | } | 2122 | } |
2131 | 2123 | ||
2132 | #ifdef CONFIG_BLK_DEV_INITRD | 2124 | #ifdef CONFIG_BLK_DEV_INITRD |
2133 | void free_initrd_mem(unsigned long start, unsigned long end) | 2125 | void free_initrd_mem(unsigned long start, unsigned long end) |
2134 | { | 2126 | { |
2135 | if (start < end) | 2127 | num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM, |
2136 | printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10); | 2128 | "initrd"); |
2137 | for (; start < end; start += PAGE_SIZE) { | ||
2138 | struct page *p = virt_to_page(start); | ||
2139 | |||
2140 | ClearPageReserved(p); | ||
2141 | init_page_count(p); | ||
2142 | __free_page(p); | ||
2143 | totalram_pages++; | ||
2144 | } | ||
2145 | } | 2129 | } |
2146 | #endif | 2130 | #endif |
2147 | 2131 | ||