提交 0999f119 编写于 作者: J Jiang Liu 提交者: Linus Torvalds

mm/s390: 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>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 5d585e5c
...@@ -42,11 +42,10 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE))); ...@@ -42,11 +42,10 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE)));
unsigned long empty_zero_page, zero_page_mask; unsigned long empty_zero_page, zero_page_mask;
EXPORT_SYMBOL(empty_zero_page); EXPORT_SYMBOL(empty_zero_page);
static unsigned long __init setup_zero_pages(void) static void __init setup_zero_pages(void)
{ {
struct cpuid cpu_id; struct cpuid cpu_id;
unsigned int order; unsigned int order;
unsigned long size;
struct page *page; struct page *page;
int i; int i;
...@@ -83,14 +82,11 @@ static unsigned long __init setup_zero_pages(void) ...@@ -83,14 +82,11 @@ static unsigned long __init 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);
for (i = 1 << order; i > 0; i--) { for (i = 1 << order; i > 0; i--) {
SetPageReserved(page); mark_page_reserved(page);
page++; page++;
} }
size = PAGE_SIZE << order; zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK;
zero_page_mask = (size - 1) & PAGE_MASK;
return 1UL << order;
} }
/* /*
...@@ -147,7 +143,7 @@ void __init mem_init(void) ...@@ -147,7 +143,7 @@ void __init mem_init(void)
/* this will put all low memory onto the freelists */ /* this will put all low memory onto the freelists */
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 = 0; reservedpages = 0;
...@@ -166,34 +162,15 @@ void __init mem_init(void) ...@@ -166,34 +162,15 @@ void __init mem_init(void)
PFN_ALIGN((unsigned long)&_eshared) - 1); PFN_ALIGN((unsigned long)&_eshared) - 1);
} }
void free_init_pages(char *what, unsigned long begin, unsigned long end)
{
unsigned long addr = begin;
if (begin >= end)
return;
for (; addr < end; addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
init_page_count(virt_to_page(addr));
memset((void *)(addr & PAGE_MASK), POISON_FREE_INITMEM,
PAGE_SIZE);
free_page(addr);
totalram_pages++;
}
printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
}
void free_initmem(void) void free_initmem(void)
{ {
free_init_pages("unused kernel memory", free_initmem_default(0);
(unsigned long)&__init_begin,
(unsigned long)&__init_end);
} }
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end) void __init free_initrd_mem(unsigned long start, unsigned long end)
{ {
free_init_pages("initrd memory", start, end); free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
} }
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册