linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: keep the page count correct
@ 2008-10-26  5:58 Yinghai Lu
  2008-10-27 16:50 ` Suresh Siddha
  0 siblings, 1 reply; 12+ messages in thread
From: Yinghai Lu @ 2008-10-26  5:58 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Suresh Siddha,
	Jeremy Fitzhardinge, Andrew Morton
  Cc: linux-kernel


impact: get correct page count for 2M and 1G...

found page count in /proc/meminfo is nor correct on 1G system in VirtualBox 2.0.4

# cat /proc/meminfo
MemTotal:        1017508 kB
MemFree:          822700 kB
Buffers:            1456 kB
Cached:            26632 kB
SwapCached:            0 kB
...
Hugepagesize:       2048 kB
DirectMap4k:      4032 kB
DirectMap2M:  18446744073709549568 kB

with this patch get:
...
DirectMap4k:      4032 kB
DirectMap2M:   1044480 kB

which is consistent to kernel_page_tables
---[ Low Kernel Mapping ]---
0xffff880000000000-0xffff880000001000           4K     RW     PCD     GLB x  pte
0xffff880000001000-0xffff88000009f000         632K     RW             GLB x  pte
0xffff88000009f000-0xffff8800000a0000           4K     RW     PCD     GLB x  pte
0xffff8800000a0000-0xffff880000200000        1408K     RW             GLB x  pte
0xffff880000200000-0xffff88003fe00000        1020M     RW         PSE GLB x  pmd
0xffff88003fe00000-0xffff88003fff0000        1984K     RW             GLB NX pte
0xffff88003fff0000-0xffff880040000000          64K                           pte
0xffff880040000000-0xffff888000000000         511G                           pud
0xffff888000000000-0xffffc20000000000       58880G                           pgd

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 7df1209..701675a 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -350,8 +350,10 @@ phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end,
 		 * pagetable pages as RO. So assume someone who pre-setup
 		 * these mappings are more intelligent.
 		 */
-		if (pte_val(*pte))
+		if (pte_val(*pte)) {
+			pages++;
 			continue;
+		}
 
 		if (0)
 			printk("   pte=%p addr=%lx pte=%016lx\n",
@@ -418,8 +420,10 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
 			 * not differ with respect to page frame and
 			 * attributes.
 			 */
-			if (page_size_mask & (1 << PG_LEVEL_2M))
+			if (page_size_mask & (1 << PG_LEVEL_2M)) {
+				pages++;
 				continue;
+			}
 			new_prot = pte_pgprot(pte_clrhuge(*(pte_t *)pmd));
 		}
 
@@ -499,8 +503,10 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
 			 * not differ with respect to page frame and
 			 * attributes.
 			 */
-			if (page_size_mask & (1 << PG_LEVEL_1G))
+			if (page_size_mask & (1 << PG_LEVEL_1G)) {
+				pages++;
 				continue;
+			}
 			prot = pte_pgprot(pte_clrhuge(*(pte_t *)pud));
 		}
 

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-10-28 19:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-26  5:58 [PATCH] x86: keep the page count correct Yinghai Lu
2008-10-27 16:50 ` Suresh Siddha
2008-10-27 17:55   ` Ingo Molnar
2008-10-28  1:52     ` [PATCH] x86: fix init_memory_mapping for [dc000000 - e0000000) Yinghai Lu
2008-10-28  9:27       ` Ingo Molnar
2008-10-28 17:48         ` Cyrill Gorcunov
2008-10-28 18:10           ` Ingo Molnar
2008-10-28 18:14             ` Cyrill Gorcunov
2008-10-28 18:18               ` Ingo Molnar
2008-10-28 18:22                 ` Cyrill Gorcunov
     [not found]         ` <20081028093930.GA9699@elte.hu>
     [not found]           ` <20081028094758.GA11958@elte.hu>
     [not found]             ` <4906E048.6060006@kernel.org>
     [not found]               ` <20081028095244.GY15734@elte.hu>
2008-10-28 19:39                 ` [PATCH] x86: fix init_memory_mapping for [dc000000 - e0000000) - v2 Yinghai Lu
2008-10-28 19:55                   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).