diff options
author | Jiang Liu <liuj97@gmail.com> | 2013-07-03 18:03:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:33 -0400 |
commit | 0c988534737a358fdff42fcce78f0ff1a12dbfc5 (patch) | |
tree | 8327783ebf8d9905b00e51908a210134dc55a035 | |
parent | 3dcc0571cd64816309765b7c7e4691a4cadf2ee7 (diff) |
mm: concentrate modification of totalram_pages into the mm core
Concentrate code to modify totalram_pages into the mm core, so the arch
memory initialized code doesn't need to take care of it. With these
changes applied, only following functions from mm core modify global
variable totalram_pages: free_bootmem_late(), free_all_bootmem(),
free_all_bootmem_node(), adjust_managed_page_count().
With this patch applied, it will be much more easier for us to keep
totalram_pages and zone->managed_pages in consistence.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: David Howells <dhowells@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: <sworddragon2@aol.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Jianguo Wu <wujianguo@huawei.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Michel Lespinasse <walken@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wen Congyang <wency@cn.fujitsu.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
36 files changed, 50 insertions, 46 deletions
diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c index 218c29c14bb3..eee47a453d7d 100644 --- a/arch/alpha/mm/init.c +++ b/arch/alpha/mm/init.c | |||
@@ -309,7 +309,7 @@ void __init | |||
309 | mem_init(void) | 309 | mem_init(void) |
310 | { | 310 | { |
311 | max_mapnr = num_physpages = max_low_pfn; | 311 | max_mapnr = num_physpages = max_low_pfn; |
312 | totalram_pages += free_all_bootmem(); | 312 | free_all_bootmem(); |
313 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); | 313 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); |
314 | 314 | ||
315 | printk_memory_info(); | 315 | printk_memory_info(); |
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c index 33885048fa36..857452c13c4d 100644 --- a/arch/alpha/mm/numa.c +++ b/arch/alpha/mm/numa.c | |||
@@ -334,7 +334,7 @@ void __init mem_init(void) | |||
334 | /* | 334 | /* |
335 | * This will free up the bootmem, ie, slot 0 memory | 335 | * This will free up the bootmem, ie, slot 0 memory |
336 | */ | 336 | */ |
337 | totalram_pages += free_all_bootmem_node(NODE_DATA(nid)); | 337 | free_all_bootmem_node(NODE_DATA(nid)); |
338 | 338 | ||
339 | pfn = NODE_DATA(nid)->node_start_pfn; | 339 | pfn = NODE_DATA(nid)->node_start_pfn; |
340 | for (i = 0; i < node_spanned_pages(nid); i++, pfn++) | 340 | for (i = 0; i < node_spanned_pages(nid); i++, pfn++) |
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index f9c707712096..c668a600f652 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c | |||
@@ -111,7 +111,7 @@ void __init mem_init(void) | |||
111 | 111 | ||
112 | high_memory = (void *)(CONFIG_LINUX_LINK_BASE + arc_mem_sz); | 112 | high_memory = (void *)(CONFIG_LINUX_LINK_BASE + arc_mem_sz); |
113 | 113 | ||
114 | totalram_pages = free_all_bootmem(); | 114 | free_all_bootmem(); |
115 | 115 | ||
116 | /* count all reserved pages [kernel code/data/mem_map..] */ | 116 | /* count all reserved pages [kernel code/data/mem_map..] */ |
117 | reserved_pages = 0; | 117 | reserved_pages = 0; |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 2070651c1bb4..06e9ce17d1d2 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -596,8 +596,7 @@ void __init mem_init(void) | |||
596 | 596 | ||
597 | /* this will put all unused low memory onto the freelists */ | 597 | /* this will put all unused low memory onto the freelists */ |
598 | free_unused_memmap(&meminfo); | 598 | free_unused_memmap(&meminfo); |
599 | 599 | free_all_bootmem(); | |
600 | totalram_pages += free_all_bootmem(); | ||
601 | 600 | ||
602 | #ifdef CONFIG_SA1111 | 601 | #ifdef CONFIG_SA1111 |
603 | /* now that our DMA memory is actually so designated, we can free it */ | 602 | /* now that our DMA memory is actually so designated, we can free it */ |
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index a398eb9018bb..93de98afedd7 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c | |||
@@ -284,7 +284,7 @@ void __init mem_init(void) | |||
284 | free_unused_memmap(); | 284 | free_unused_memmap(); |
285 | #endif | 285 | #endif |
286 | 286 | ||
287 | totalram_pages += free_all_bootmem(); | 287 | free_all_bootmem(); |
288 | 288 | ||
289 | reserved_pages = free_pages = 0; | 289 | reserved_pages = free_pages = 0; |
290 | 290 | ||
diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c index b079e04f6954..af6890fd7319 100644 --- a/arch/avr32/mm/init.c +++ b/arch/avr32/mm/init.c | |||
@@ -117,8 +117,6 @@ void __init mem_init(void) | |||
117 | if (pgdat->node_spanned_pages != 0) | 117 | if (pgdat->node_spanned_pages != 0) |
118 | node_pages = free_all_bootmem_node(pgdat); | 118 | node_pages = free_all_bootmem_node(pgdat); |
119 | 119 | ||
120 | totalram_pages += node_pages; | ||
121 | |||
122 | for (i = 0; i < node_pages; i++) | 120 | for (i = 0; i < node_pages; i++) |
123 | if (PageReserved(pgdat->node_mem_map + i)) | 121 | if (PageReserved(pgdat->node_mem_map + i)) |
124 | reservedpages++; | 122 | reservedpages++; |
diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c index fa241f5a7dcf..c73d80ef564f 100644 --- a/arch/blackfin/mm/init.c +++ b/arch/blackfin/mm/init.c | |||
@@ -104,7 +104,7 @@ void __init mem_init(void) | |||
104 | printk(KERN_DEBUG "Kernel managed physical pages: %lu\n", num_physpages); | 104 | printk(KERN_DEBUG "Kernel managed physical pages: %lu\n", num_physpages); |
105 | 105 | ||
106 | /* This will put all low memory onto the freelists. */ | 106 | /* This will put all low memory onto the freelists. */ |
107 | totalram_pages = free_all_bootmem(); | 107 | free_all_bootmem(); |
108 | 108 | ||
109 | reservedpages = 0; | 109 | reservedpages = 0; |
110 | for (tmp = ARCH_PFN_OFFSET; tmp < max_mapnr; tmp++) | 110 | for (tmp = ARCH_PFN_OFFSET; tmp < max_mapnr; tmp++) |
diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c index 3987a20fdee6..c9ae8ce731d5 100644 --- a/arch/c6x/mm/init.c +++ b/arch/c6x/mm/init.c | |||
@@ -65,7 +65,7 @@ void __init mem_init(void) | |||
65 | high_memory = (void *)(memory_end & PAGE_MASK); | 65 | high_memory = (void *)(memory_end & PAGE_MASK); |
66 | 66 | ||
67 | /* this will put all memory onto the freelists */ | 67 | /* this will put all memory onto the freelists */ |
68 | totalram_pages = free_all_bootmem(); | 68 | free_all_bootmem(); |
69 | 69 | ||
70 | codek = (_etext - _stext) >> 10; | 70 | codek = (_etext - _stext) >> 10; |
71 | datak = (_end - _sdata) >> 10; | 71 | datak = (_end - _sdata) >> 10; |
diff --git a/arch/cris/mm/init.c b/arch/cris/mm/init.c index 8fec26392ae7..52b8b56ae305 100644 --- a/arch/cris/mm/init.c +++ b/arch/cris/mm/init.c | |||
@@ -33,7 +33,7 @@ mem_init(void) | |||
33 | max_mapnr = num_physpages = max_low_pfn - min_low_pfn; | 33 | max_mapnr = num_physpages = max_low_pfn - min_low_pfn; |
34 | 34 | ||
35 | /* this will put all memory onto the freelists */ | 35 | /* this will put all memory onto the freelists */ |
36 | totalram_pages = free_all_bootmem(); | 36 | free_all_bootmem(); |
37 | 37 | ||
38 | reservedpages = 0; | 38 | reservedpages = 0; |
39 | for (tmp = 0; tmp < max_mapnr; tmp++) { | 39 | for (tmp = 0; tmp < max_mapnr; tmp++) { |
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c index 8ba9d22d0d91..3dcc88803a4f 100644 --- a/arch/frv/mm/init.c +++ b/arch/frv/mm/init.c | |||
@@ -123,7 +123,7 @@ void __init mem_init(void) | |||
123 | int codek = 0, datak = 0; | 123 | int codek = 0, datak = 0; |
124 | 124 | ||
125 | /* this will put all low memory onto the freelists */ | 125 | /* this will put all low memory onto the freelists */ |
126 | totalram_pages = free_all_bootmem(); | 126 | free_all_bootmem(); |
127 | 127 | ||
128 | #ifdef CONFIG_MMU | 128 | #ifdef CONFIG_MMU |
129 | for (loop = 0 ; loop < npages ; loop++) | 129 | for (loop = 0 ; loop < npages ; loop++) |
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c index c831f1dba132..a506dd4724e0 100644 --- a/arch/h8300/mm/init.c +++ b/arch/h8300/mm/init.c | |||
@@ -140,7 +140,7 @@ void __init mem_init(void) | |||
140 | max_mapnr = num_physpages = MAP_NR(high_memory); | 140 | max_mapnr = num_physpages = MAP_NR(high_memory); |
141 | 141 | ||
142 | /* this will put all low memory onto the freelists */ | 142 | /* this will put all low memory onto the freelists */ |
143 | totalram_pages = free_all_bootmem(); | 143 | free_all_bootmem(); |
144 | 144 | ||
145 | codek = (_etext - _stext) >> 10; | 145 | codek = (_etext - _stext) >> 10; |
146 | datak = (__bss_stop - _sdata) >> 10; | 146 | datak = (__bss_stop - _sdata) >> 10; |
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c index 2561d259a296..0ab5b4350e93 100644 --- a/arch/hexagon/mm/init.c +++ b/arch/hexagon/mm/init.c | |||
@@ -70,7 +70,7 @@ unsigned long long kmap_generation; | |||
70 | void __init mem_init(void) | 70 | void __init mem_init(void) |
71 | { | 71 | { |
72 | /* No idea where this is actually declared. Seems to evade LXR. */ | 72 | /* No idea where this is actually declared. Seems to evade LXR. */ |
73 | totalram_pages += free_all_bootmem(); | 73 | free_all_bootmem(); |
74 | num_physpages = bootmem_lastpg-ARCH_PFN_OFFSET; | 74 | num_physpages = bootmem_lastpg-ARCH_PFN_OFFSET; |
75 | 75 | ||
76 | printk(KERN_INFO "totalram_pages = %ld\n", totalram_pages); | 76 | printk(KERN_INFO "totalram_pages = %ld\n", totalram_pages); |
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index f8a4f38b0ad5..d141f7ea0be5 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c | |||
@@ -622,7 +622,7 @@ mem_init (void) | |||
622 | 622 | ||
623 | for_each_online_pgdat(pgdat) | 623 | for_each_online_pgdat(pgdat) |
624 | if (pgdat->bdata->node_bootmem_map) | 624 | if (pgdat->bdata->node_bootmem_map) |
625 | totalram_pages += free_all_bootmem_node(pgdat); | 625 | free_all_bootmem_node(pgdat); |
626 | 626 | ||
627 | reserved_pages = 0; | 627 | reserved_pages = 0; |
628 | efi_memmap_walk(count_reserved_pages, &reserved_pages); | 628 | efi_memmap_walk(count_reserved_pages, &reserved_pages); |
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c index cca87d918436..a501838233ab 100644 --- a/arch/m32r/mm/init.c +++ b/arch/m32r/mm/init.c | |||
@@ -158,7 +158,7 @@ void __init mem_init(void) | |||
158 | 158 | ||
159 | /* this will put all low memory onto the freelists */ | 159 | /* this will put all low memory onto the freelists */ |
160 | for_each_online_node(nid) | 160 | for_each_online_node(nid) |
161 | totalram_pages += free_all_bootmem_node(NODE_DATA(nid)); | 161 | free_all_bootmem_node(NODE_DATA(nid)); |
162 | 162 | ||
163 | reservedpages = reservedpages_count() - hole_pages; | 163 | reservedpages = reservedpages_count() - hole_pages; |
164 | codesize = (unsigned long) &_etext - (unsigned long)&_text; | 164 | codesize = (unsigned long) &_etext - (unsigned long)&_text; |
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c index ab0b54ca5d85..614c60a04459 100644 --- a/arch/m68k/mm/init.c +++ b/arch/m68k/mm/init.c | |||
@@ -155,11 +155,11 @@ void __init mem_init(void) | |||
155 | int i; | 155 | int i; |
156 | 156 | ||
157 | /* this will put all memory onto the freelists */ | 157 | /* this will put all memory onto the freelists */ |
158 | totalram_pages = num_physpages = 0; | 158 | num_physpages = 0; |
159 | for_each_online_pgdat(pgdat) { | 159 | for_each_online_pgdat(pgdat) { |
160 | num_physpages += pgdat->node_present_pages; | 160 | num_physpages += pgdat->node_present_pages; |
161 | 161 | ||
162 | totalram_pages += free_all_bootmem_node(pgdat); | 162 | free_all_bootmem_node(pgdat); |
163 | for (i = 0; i < pgdat->node_spanned_pages; i++) { | 163 | for (i = 0; i < pgdat->node_spanned_pages; i++) { |
164 | struct page *page = pgdat->node_mem_map + i; | 164 | struct page *page = pgdat->node_mem_map + i; |
165 | char *addr = page_to_virt(page); | 165 | char *addr = page_to_virt(page); |
diff --git a/arch/metag/mm/init.c b/arch/metag/mm/init.c index d7595f58fad5..ce81d7c43983 100644 --- a/arch/metag/mm/init.c +++ b/arch/metag/mm/init.c | |||
@@ -393,14 +393,11 @@ void __init mem_init(void) | |||
393 | 393 | ||
394 | for_each_online_node(nid) { | 394 | for_each_online_node(nid) { |
395 | pg_data_t *pgdat = NODE_DATA(nid); | 395 | pg_data_t *pgdat = NODE_DATA(nid); |
396 | unsigned long node_pages = 0; | ||
397 | 396 | ||
398 | num_physpages += pgdat->node_present_pages; | 397 | num_physpages += pgdat->node_present_pages; |
399 | 398 | ||
400 | if (pgdat->node_spanned_pages) | 399 | if (pgdat->node_spanned_pages) |
401 | node_pages = free_all_bootmem_node(pgdat); | 400 | free_all_bootmem_node(pgdat); |
402 | |||
403 | totalram_pages += node_pages; | ||
404 | } | 401 | } |
405 | 402 | ||
406 | pr_info("Memory: %luk/%luk available\n", | 403 | pr_info("Memory: %luk/%luk available\n", |
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index d149e0ebb767..b384cbc2c8f2 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c | |||
@@ -252,7 +252,7 @@ void __init mem_init(void) | |||
252 | high_memory = (void *)__va(memory_start + lowmem_size - 1); | 252 | high_memory = (void *)__va(memory_start + lowmem_size - 1); |
253 | 253 | ||
254 | /* this will put all memory onto the freelists */ | 254 | /* this will put all memory onto the freelists */ |
255 | totalram_pages += free_all_bootmem(); | 255 | free_all_bootmem(); |
256 | 256 | ||
257 | for_each_online_pgdat(pgdat) { | 257 | for_each_online_pgdat(pgdat) { |
258 | unsigned long i; | 258 | unsigned long i; |
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 268f2a94031b..e7333f15b1b7 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c | |||
@@ -374,7 +374,7 @@ void __init mem_init(void) | |||
374 | #endif | 374 | #endif |
375 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); | 375 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); |
376 | 376 | ||
377 | totalram_pages += free_all_bootmem(); | 377 | free_all_bootmem(); |
378 | setup_zero_pages(); /* Setup zeroed pages. */ | 378 | setup_zero_pages(); /* Setup zeroed pages. */ |
379 | 379 | ||
380 | reservedpages = ram = 0; | 380 | reservedpages = ram = 0; |
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index 1230f56429d7..aecac4a08360 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c | |||
@@ -489,7 +489,7 @@ void __init mem_init(void) | |||
489 | /* | 489 | /* |
490 | * This will free up the bootmem, ie, slot 0 memory. | 490 | * This will free up the bootmem, ie, slot 0 memory. |
491 | */ | 491 | */ |
492 | totalram_pages += free_all_bootmem_node(NODE_DATA(node)); | 492 | free_all_bootmem_node(NODE_DATA(node)); |
493 | } | 493 | } |
494 | 494 | ||
495 | setup_zero_pages(); /* This comes from node 0 */ | 495 | setup_zero_pages(); /* This comes from node 0 */ |
diff --git a/arch/mn10300/mm/init.c b/arch/mn10300/mm/init.c index e19049d1f2b9..7590d91627f2 100644 --- a/arch/mn10300/mm/init.c +++ b/arch/mn10300/mm/init.c | |||
@@ -114,7 +114,7 @@ void __init mem_init(void) | |||
114 | memset(empty_zero_page, 0, PAGE_SIZE); | 114 | memset(empty_zero_page, 0, PAGE_SIZE); |
115 | 115 | ||
116 | /* this will put all low memory onto the freelists */ | 116 | /* this will put all low memory onto the freelists */ |
117 | totalram_pages += free_all_bootmem(); | 117 | free_all_bootmem(); |
118 | 118 | ||
119 | reservedpages = 0; | 119 | reservedpages = 0; |
120 | for (tmp = 0; tmp < num_physpages; tmp++) | 120 | for (tmp = 0; tmp < num_physpages; tmp++) |
diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index c371e4a0fcac..16c1e135cf34 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c | |||
@@ -207,7 +207,7 @@ static int __init free_pages_init(void) | |||
207 | int reservedpages, pfn; | 207 | int reservedpages, pfn; |
208 | 208 | ||
209 | /* this will put all low memory onto the freelists */ | 209 | /* this will put all low memory onto the freelists */ |
210 | totalram_pages = free_all_bootmem(); | 210 | free_all_bootmem(); |
211 | 211 | ||
212 | reservedpages = 0; | 212 | reservedpages = 0; |
213 | for (pfn = 0; pfn < max_low_pfn; pfn++) { | 213 | for (pfn = 0; pfn < max_low_pfn; pfn++) { |
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index ebac7bd76b56..d8aaaf06ede2 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c | |||
@@ -593,13 +593,13 @@ void __init mem_init(void) | |||
593 | 593 | ||
594 | #ifndef CONFIG_DISCONTIGMEM | 594 | #ifndef CONFIG_DISCONTIGMEM |
595 | max_mapnr = page_to_pfn(virt_to_page(high_memory - 1)) + 1; | 595 | max_mapnr = page_to_pfn(virt_to_page(high_memory - 1)) + 1; |
596 | totalram_pages += free_all_bootmem(); | 596 | free_all_bootmem(); |
597 | #else | 597 | #else |
598 | { | 598 | { |
599 | int i; | 599 | int i; |
600 | 600 | ||
601 | for (i = 0; i < npmem_ranges; i++) | 601 | for (i = 0; i < npmem_ranges; i++) |
602 | totalram_pages += free_all_bootmem_node(NODE_DATA(i)); | 602 | free_all_bootmem_node(NODE_DATA(i)); |
603 | } | 603 | } |
604 | #endif | 604 | #endif |
605 | 605 | ||
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 7f47a05f55af..3bcfc0d0d322 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -318,13 +318,12 @@ void __init mem_init(void) | |||
318 | for_each_online_node(nid) { | 318 | for_each_online_node(nid) { |
319 | if (NODE_DATA(nid)->node_spanned_pages != 0) { | 319 | if (NODE_DATA(nid)->node_spanned_pages != 0) { |
320 | printk("freeing bootmem node %d\n", nid); | 320 | printk("freeing bootmem node %d\n", nid); |
321 | totalram_pages += | 321 | free_all_bootmem_node(NODE_DATA(nid)); |
322 | free_all_bootmem_node(NODE_DATA(nid)); | ||
323 | } | 322 | } |
324 | } | 323 | } |
325 | #else | 324 | #else |
326 | max_mapnr = max_pfn; | 325 | max_mapnr = max_pfn; |
327 | totalram_pages += free_all_bootmem(); | 326 | free_all_bootmem(); |
328 | #endif | 327 | #endif |
329 | for_each_online_pgdat(pgdat) { | 328 | for_each_online_pgdat(pgdat) { |
330 | for (i = 0; i < pgdat->node_spanned_pages; i++) { | 329 | for (i = 0; i < pgdat->node_spanned_pages; i++) { |
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index bf01d18422ec..a2aafe1b2300 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c | |||
@@ -144,7 +144,7 @@ void __init mem_init(void) | |||
144 | cmma_init(); | 144 | cmma_init(); |
145 | 145 | ||
146 | /* this will put all low memory onto the freelists */ | 146 | /* this will put all low memory onto the freelists */ |
147 | totalram_pages += free_all_bootmem(); | 147 | free_all_bootmem(); |
148 | setup_zero_pages(); /* Setup zeroed pages. */ | 148 | setup_zero_pages(); /* Setup zeroed pages. */ |
149 | 149 | ||
150 | reservedpages = 0; | 150 | reservedpages = 0; |
diff --git a/arch/score/mm/init.c b/arch/score/mm/init.c index f5dd61eb4544..a8b917742dec 100644 --- a/arch/score/mm/init.c +++ b/arch/score/mm/init.c | |||
@@ -79,7 +79,7 @@ void __init mem_init(void) | |||
79 | unsigned long tmp, ram = 0; | 79 | unsigned long tmp, ram = 0; |
80 | 80 | ||
81 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); | 81 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); |
82 | totalram_pages += free_all_bootmem(); | 82 | free_all_bootmem(); |
83 | setup_zero_page(); /* Setup zeroed pages. */ | 83 | setup_zero_page(); /* Setup zeroed pages. */ |
84 | reservedpages = 0; | 84 | reservedpages = 0; |
85 | 85 | ||
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index d3af56b7a098..fc0c8e1c32a7 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c | |||
@@ -422,7 +422,7 @@ void __init mem_init(void) | |||
422 | num_physpages += pgdat->node_present_pages; | 422 | num_physpages += pgdat->node_present_pages; |
423 | 423 | ||
424 | if (pgdat->node_spanned_pages) | 424 | if (pgdat->node_spanned_pages) |
425 | totalram_pages += free_all_bootmem_node(pgdat); | 425 | free_all_bootmem_node(pgdat); |
426 | 426 | ||
427 | 427 | ||
428 | node_high_memory = (void *)__va((pgdat->node_start_pfn + | 428 | node_high_memory = (void *)__va((pgdat->node_start_pfn + |
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index d5f9c023826f..a438abb5495e 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c | |||
@@ -323,8 +323,7 @@ void __init mem_init(void) | |||
323 | 323 | ||
324 | max_mapnr = last_valid_pfn - pfn_base; | 324 | max_mapnr = last_valid_pfn - pfn_base; |
325 | high_memory = __va(max_low_pfn << PAGE_SHIFT); | 325 | high_memory = __va(max_low_pfn << PAGE_SHIFT); |
326 | 326 | free_all_bootmem(); | |
327 | totalram_pages = free_all_bootmem(); | ||
328 | 327 | ||
329 | for (i = 0; sp_banks[i].num_bytes != 0; i++) { | 328 | for (i = 0; sp_banks[i].num_bytes != 0; i++) { |
330 | unsigned long start_pfn = sp_banks[i].base_addr >> PAGE_SHIFT; | 329 | unsigned long start_pfn = sp_banks[i].base_addr >> PAGE_SHIFT; |
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 8269deb84eda..752d73837f9e 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c | |||
@@ -2061,7 +2061,7 @@ void __init mem_init(void) | |||
2061 | high_memory = __va(last_valid_pfn << PAGE_SHIFT); | 2061 | high_memory = __va(last_valid_pfn << PAGE_SHIFT); |
2062 | 2062 | ||
2063 | register_page_bootmem_info(); | 2063 | register_page_bootmem_info(); |
2064 | totalram_pages = free_all_bootmem(); | 2064 | free_all_bootmem(); |
2065 | 2065 | ||
2066 | /* We subtract one to account for the mem_map_zero page | 2066 | /* We subtract one to account for the mem_map_zero page |
2067 | * allocated below. | 2067 | * allocated below. |
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c index ccfeb3f2e769..45ce26d4e474 100644 --- a/arch/tile/mm/init.c +++ b/arch/tile/mm/init.c | |||
@@ -846,7 +846,7 @@ void __init mem_init(void) | |||
846 | set_max_mapnr_init(); | 846 | set_max_mapnr_init(); |
847 | 847 | ||
848 | /* this will put all bootmem onto the freelists */ | 848 | /* this will put all bootmem onto the freelists */ |
849 | totalram_pages += free_all_bootmem(); | 849 | free_all_bootmem(); |
850 | 850 | ||
851 | #ifndef CONFIG_64BIT | 851 | #ifndef CONFIG_64BIT |
852 | /* count all remaining LOWMEM and give all HIGHMEM to page allocator */ | 852 | /* count all remaining LOWMEM and give all HIGHMEM to page allocator */ |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 8ff0b7ae8ec0..b0c763094ffb 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -65,7 +65,7 @@ void __init mem_init(void) | |||
65 | uml_reserved = brk_end; | 65 | uml_reserved = brk_end; |
66 | 66 | ||
67 | /* this will put all low memory onto the freelists */ | 67 | /* this will put all low memory onto the freelists */ |
68 | totalram_pages = free_all_bootmem(); | 68 | free_all_bootmem(); |
69 | max_low_pfn = totalram_pages; | 69 | max_low_pfn = totalram_pages; |
70 | #ifdef CONFIG_HIGHMEM | 70 | #ifdef CONFIG_HIGHMEM |
71 | setup_highmem(end_iomem, highmem); | 71 | setup_highmem(end_iomem, highmem); |
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index df9b8abcb6a5..7d1356c466b9 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c | |||
@@ -392,7 +392,7 @@ void __init mem_init(void) | |||
392 | free_unused_memmap(&meminfo); | 392 | free_unused_memmap(&meminfo); |
393 | 393 | ||
394 | /* this will put all unused low memory onto the freelists */ | 394 | /* this will put all unused low memory onto the freelists */ |
395 | totalram_pages += free_all_bootmem(); | 395 | free_all_bootmem(); |
396 | 396 | ||
397 | reserved_pages = free_pages = 0; | 397 | reserved_pages = free_pages = 0; |
398 | 398 | ||
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 3ac7e319918d..9fa46baada27 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c | |||
@@ -759,7 +759,7 @@ void __init mem_init(void) | |||
759 | set_highmem_pages_init(); | 759 | set_highmem_pages_init(); |
760 | 760 | ||
761 | /* this will put all low memory onto the freelists */ | 761 | /* this will put all low memory onto the freelists */ |
762 | totalram_pages += free_all_bootmem(); | 762 | free_all_bootmem(); |
763 | 763 | ||
764 | reservedpages = 0; | 764 | reservedpages = 0; |
765 | for (tmp = 0; tmp < max_low_pfn; tmp++) | 765 | for (tmp = 0; tmp < max_low_pfn; tmp++) |
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index ec312a92b137..9577638f3ead 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c | |||
@@ -1054,7 +1054,7 @@ void __init mem_init(void) | |||
1054 | register_page_bootmem_info(); | 1054 | register_page_bootmem_info(); |
1055 | 1055 | ||
1056 | /* this will put all memory onto the freelists */ | 1056 | /* this will put all memory onto the freelists */ |
1057 | totalram_pages = free_all_bootmem(); | 1057 | free_all_bootmem(); |
1058 | 1058 | ||
1059 | absent_pages = absent_pages_in_range(0, max_pfn); | 1059 | absent_pages = absent_pages_in_range(0, max_pfn); |
1060 | reservedpages = max_pfn - totalram_pages - absent_pages; | 1060 | reservedpages = max_pfn - totalram_pages - absent_pages; |
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c index 026d29bee30b..663c1619562c 100644 --- a/arch/xtensa/mm/init.c +++ b/arch/xtensa/mm/init.c | |||
@@ -184,7 +184,7 @@ void __init mem_init(void) | |||
184 | #error HIGHGMEM not implemented in init.c | 184 | #error HIGHGMEM not implemented in init.c |
185 | #endif | 185 | #endif |
186 | 186 | ||
187 | totalram_pages += free_all_bootmem(); | 187 | free_all_bootmem(); |
188 | 188 | ||
189 | reservedpages = ram = 0; | 189 | reservedpages = ram = 0; |
190 | for (tmp = 0; tmp < max_mapnr; tmp++) { | 190 | for (tmp = 0; tmp < max_mapnr; tmp++) { |
diff --git a/mm/bootmem.c b/mm/bootmem.c index eb792323187b..58609bbf584e 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -271,9 +271,14 @@ void __init reset_all_zones_managed_pages(void) | |||
271 | */ | 271 | */ |
272 | unsigned long __init free_all_bootmem_node(pg_data_t *pgdat) | 272 | unsigned long __init free_all_bootmem_node(pg_data_t *pgdat) |
273 | { | 273 | { |
274 | unsigned long pages; | ||
275 | |||
274 | register_page_bootmem_info_node(pgdat); | 276 | register_page_bootmem_info_node(pgdat); |
275 | reset_node_managed_pages(pgdat); | 277 | reset_node_managed_pages(pgdat); |
276 | return free_all_bootmem_core(pgdat->bdata); | 278 | pages = free_all_bootmem_core(pgdat->bdata); |
279 | totalram_pages += pages; | ||
280 | |||
281 | return pages; | ||
277 | } | 282 | } |
278 | 283 | ||
279 | /** | 284 | /** |
@@ -291,6 +296,8 @@ unsigned long __init free_all_bootmem(void) | |||
291 | list_for_each_entry(bdata, &bdata_list, list) | 296 | list_for_each_entry(bdata, &bdata_list, list) |
292 | total_pages += free_all_bootmem_core(bdata); | 297 | total_pages += free_all_bootmem_core(bdata); |
293 | 298 | ||
299 | totalram_pages += total_pages; | ||
300 | |||
294 | return total_pages; | 301 | return total_pages; |
295 | } | 302 | } |
296 | 303 | ||
diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 0ae8d91365af..61107cf55bb3 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c | |||
@@ -165,6 +165,8 @@ void __init reset_all_zones_managed_pages(void) | |||
165 | */ | 165 | */ |
166 | unsigned long __init free_all_bootmem(void) | 166 | unsigned long __init free_all_bootmem(void) |
167 | { | 167 | { |
168 | unsigned long pages; | ||
169 | |||
168 | reset_all_zones_managed_pages(); | 170 | reset_all_zones_managed_pages(); |
169 | 171 | ||
170 | /* | 172 | /* |
@@ -172,7 +174,10 @@ unsigned long __init free_all_bootmem(void) | |||
172 | * because in some case like Node0 doesn't have RAM installed | 174 | * because in some case like Node0 doesn't have RAM installed |
173 | * low ram will be on Node1 | 175 | * low ram will be on Node1 |
174 | */ | 176 | */ |
175 | return free_low_memory_core_early(); | 177 | pages = free_low_memory_core_early(); |
178 | totalram_pages += pages; | ||
179 | |||
180 | return pages; | ||
176 | } | 181 | } |
177 | 182 | ||
178 | /** | 183 | /** |