diff options
author | Jiang Liu <liuj97@gmail.com> | 2013-04-29 18:06:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 18:54:30 -0400 |
commit | 0999f1193a51de6317171b340a19a1af70d7ecb0 (patch) | |
tree | 767f2cfcdd13bdd7a9f3f3859eda4f97181e3af0 /arch/s390/mm | |
parent | 5d585e5c4840381112011aa257c7a94b2b66f9de (diff) |
mm/s390: 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>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/s390/mm')
-rw-r--r-- | arch/s390/mm/init.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 9f9c315b4c07..0b09b2342302 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c | |||
@@ -42,11 +42,10 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE))); | |||
42 | unsigned long empty_zero_page, zero_page_mask; | 42 | unsigned long empty_zero_page, zero_page_mask; |
43 | EXPORT_SYMBOL(empty_zero_page); | 43 | EXPORT_SYMBOL(empty_zero_page); |
44 | 44 | ||
45 | static unsigned long __init setup_zero_pages(void) | 45 | static void __init setup_zero_pages(void) |
46 | { | 46 | { |
47 | struct cpuid cpu_id; | 47 | struct cpuid cpu_id; |
48 | unsigned int order; | 48 | unsigned int order; |
49 | unsigned long size; | ||
50 | struct page *page; | 49 | struct page *page; |
51 | int i; | 50 | int i; |
52 | 51 | ||
@@ -83,14 +82,11 @@ static unsigned long __init setup_zero_pages(void) | |||
83 | page = virt_to_page((void *) empty_zero_page); | 82 | page = virt_to_page((void *) empty_zero_page); |
84 | split_page(page, order); | 83 | split_page(page, order); |
85 | for (i = 1 << order; i > 0; i--) { | 84 | for (i = 1 << order; i > 0; i--) { |
86 | SetPageReserved(page); | 85 | mark_page_reserved(page); |
87 | page++; | 86 | page++; |
88 | } | 87 | } |
89 | 88 | ||
90 | size = PAGE_SIZE << order; | 89 | zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK; |
91 | zero_page_mask = (size - 1) & PAGE_MASK; | ||
92 | |||
93 | return 1UL << order; | ||
94 | } | 90 | } |
95 | 91 | ||
96 | /* | 92 | /* |
@@ -147,7 +143,7 @@ void __init mem_init(void) | |||
147 | 143 | ||
148 | /* this will put all low memory onto the freelists */ | 144 | /* this will put all low memory onto the freelists */ |
149 | totalram_pages += free_all_bootmem(); | 145 | totalram_pages += free_all_bootmem(); |
150 | totalram_pages -= setup_zero_pages(); /* Setup zeroed pages. */ | 146 | setup_zero_pages(); /* Setup zeroed pages. */ |
151 | 147 | ||
152 | reservedpages = 0; | 148 | reservedpages = 0; |
153 | 149 | ||
@@ -166,34 +162,15 @@ void __init mem_init(void) | |||
166 | PFN_ALIGN((unsigned long)&_eshared) - 1); | 162 | PFN_ALIGN((unsigned long)&_eshared) - 1); |
167 | } | 163 | } |
168 | 164 | ||
169 | void free_init_pages(char *what, unsigned long begin, unsigned long end) | ||
170 | { | ||
171 | unsigned long addr = begin; | ||
172 | |||
173 | if (begin >= end) | ||
174 | return; | ||
175 | for (; addr < end; addr += PAGE_SIZE) { | ||
176 | ClearPageReserved(virt_to_page(addr)); | ||
177 | init_page_count(virt_to_page(addr)); | ||
178 | memset((void *)(addr & PAGE_MASK), POISON_FREE_INITMEM, | ||
179 | PAGE_SIZE); | ||
180 | free_page(addr); | ||
181 | totalram_pages++; | ||
182 | } | ||
183 | printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); | ||
184 | } | ||
185 | |||
186 | void free_initmem(void) | 165 | void free_initmem(void) |
187 | { | 166 | { |
188 | free_init_pages("unused kernel memory", | 167 | free_initmem_default(0); |
189 | (unsigned long)&__init_begin, | ||
190 | (unsigned long)&__init_end); | ||
191 | } | 168 | } |
192 | 169 | ||
193 | #ifdef CONFIG_BLK_DEV_INITRD | 170 | #ifdef CONFIG_BLK_DEV_INITRD |
194 | void __init free_initrd_mem(unsigned long start, unsigned long end) | 171 | void __init free_initrd_mem(unsigned long start, unsigned long end) |
195 | { | 172 | { |
196 | free_init_pages("initrd memory", start, end); | 173 | free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd"); |
197 | } | 174 | } |
198 | #endif | 175 | #endif |
199 | 176 | ||