Commit 3afa3949 authored by Yinghai Lu's avatar Yinghai Lu Committed by Ingo Molnar

x86: keep the /proc/meminfo page count correct

Impact: get correct page count in /proc/meminfo

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: default avatarYinghai Lu <yinghai@kernel.org>
Acked-by: default avatarSuresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent ef020ab0
...@@ -350,8 +350,10 @@ phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end, ...@@ -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 * pagetable pages as RO. So assume someone who pre-setup
* these mappings are more intelligent. * these mappings are more intelligent.
*/ */
if (pte_val(*pte)) if (pte_val(*pte)) {
pages++;
continue; continue;
}
if (0) if (0)
printk(" pte=%p addr=%lx pte=%016lx\n", 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, ...@@ -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 * not differ with respect to page frame and
* attributes. * attributes.
*/ */
if (page_size_mask & (1 << PG_LEVEL_2M)) if (page_size_mask & (1 << PG_LEVEL_2M)) {
pages++;
continue; continue;
}
new_prot = pte_pgprot(pte_clrhuge(*(pte_t *)pmd)); 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, ...@@ -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 * not differ with respect to page frame and
* attributes. * attributes.
*/ */
if (page_size_mask & (1 << PG_LEVEL_1G)) if (page_size_mask & (1 << PG_LEVEL_1G)) {
pages++;
continue; continue;
}
prot = pte_pgprot(pte_clrhuge(*(pte_t *)pud)); prot = pte_pgprot(pte_clrhuge(*(pte_t *)pud));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment