提交 70affe45 编写于 作者: J Jiang Liu 提交者: Linus Torvalds

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

Use common help functions to free reserved pages.
Signed-off-by: NJiang Liu <jiang.liu@huawei.com>
Acked-by: NDavid S. Miller <davem@davemloft.net>
Acked-by: NSam Ravnborg <sam@ravnborg.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 0f47c942
...@@ -253,24 +253,15 @@ void __init leon_smp_done(void) ...@@ -253,24 +253,15 @@ void __init leon_smp_done(void)
/* Free unneeded trap tables */ /* Free unneeded trap tables */
if (!cpu_present(1)) { if (!cpu_present(1)) {
ClearPageReserved(virt_to_page(&trapbase_cpu1)); free_reserved_page(virt_to_page(&trapbase_cpu1));
init_page_count(virt_to_page(&trapbase_cpu1));
free_page((unsigned long)&trapbase_cpu1);
totalram_pages++;
num_physpages++; num_physpages++;
} }
if (!cpu_present(2)) { if (!cpu_present(2)) {
ClearPageReserved(virt_to_page(&trapbase_cpu2)); free_reserved_page(virt_to_page(&trapbase_cpu2));
init_page_count(virt_to_page(&trapbase_cpu2));
free_page((unsigned long)&trapbase_cpu2);
totalram_pages++;
num_physpages++; num_physpages++;
} }
if (!cpu_present(3)) { if (!cpu_present(3)) {
ClearPageReserved(virt_to_page(&trapbase_cpu3)); free_reserved_page(virt_to_page(&trapbase_cpu3));
init_page_count(virt_to_page(&trapbase_cpu3));
free_page((unsigned long)&trapbase_cpu3);
totalram_pages++;
num_physpages++; num_physpages++;
} }
/* Ok, they are spinning and ready to go. */ /* Ok, they are spinning and ready to go. */
......
...@@ -366,45 +366,14 @@ void __init mem_init(void) ...@@ -366,45 +366,14 @@ void __init mem_init(void)
void free_initmem (void) void free_initmem (void)
{ {
unsigned long addr; num_physpages += free_initmem_default(POISON_FREE_INITMEM);
unsigned long freed;
addr = (unsigned long)(&__init_begin);
freed = (unsigned long)(&__init_end) - addr;
for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
struct page *p;
memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
p = virt_to_page(addr);
ClearPageReserved(p);
init_page_count(p);
__free_page(p);
totalram_pages++;
num_physpages++;
}
printk(KERN_INFO "Freeing unused kernel memory: %ldk freed\n",
freed >> 10);
} }
#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)
{ {
if (start < end) num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM,
printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", "initrd");
(end - start) >> 10);
for (; start < end; start += PAGE_SIZE) {
struct page *p;
memset((void *)start, POISON_FREE_INITMEM, PAGE_SIZE);
p = virt_to_page(start);
ClearPageReserved(p);
init_page_count(p);
__free_page(p);
totalram_pages++;
num_physpages++;
}
} }
#endif #endif
......
...@@ -2059,8 +2059,7 @@ void __init mem_init(void) ...@@ -2059,8 +2059,7 @@ void __init mem_init(void)
/* We subtract one to account for the mem_map_zero page /* We subtract one to account for the mem_map_zero page
* allocated below. * allocated below.
*/ */
totalram_pages -= 1; num_physpages = totalram_pages - 1;
num_physpages = totalram_pages;
/* /*
* Set up the zero page, mark it reserved, so that page count * Set up the zero page, mark it reserved, so that page count
...@@ -2071,7 +2070,7 @@ void __init mem_init(void) ...@@ -2071,7 +2070,7 @@ void __init mem_init(void)
prom_printf("paging_init: Cannot alloc zero page.\n"); prom_printf("paging_init: Cannot alloc zero page.\n");
prom_halt(); prom_halt();
} }
SetPageReserved(mem_map_zero); mark_page_reserved(mem_map_zero);
codepages = (((unsigned long) _etext) - ((unsigned long) _start)); codepages = (((unsigned long) _etext) - ((unsigned long) _start));
codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT; codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT;
...@@ -2111,37 +2110,22 @@ void free_initmem(void) ...@@ -2111,37 +2110,22 @@ void free_initmem(void)
initend = (unsigned long)(__init_end) & PAGE_MASK; initend = (unsigned long)(__init_end) & PAGE_MASK;
for (; addr < initend; addr += PAGE_SIZE) { for (; addr < initend; addr += PAGE_SIZE) {
unsigned long page; unsigned long page;
struct page *p;
page = (addr + page = (addr +
((unsigned long) __va(kern_base)) - ((unsigned long) __va(kern_base)) -
((unsigned long) KERNBASE)); ((unsigned long) KERNBASE));
memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
if (do_free) { if (do_free)
p = virt_to_page(page); free_reserved_page(virt_to_page(page));
ClearPageReserved(p);
init_page_count(p);
__free_page(p);
totalram_pages++;
}
} }
} }
#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)
{ {
if (start < end) num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM,
printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10); "initrd");
for (; start < end; start += PAGE_SIZE) {
struct page *p = virt_to_page(start);
ClearPageReserved(p);
init_page_count(p);
__free_page(p);
totalram_pages++;
}
} }
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册