* [Patch] x86, mm: fix the size calculation of mapping tables
@ 2012-01-15 11:56 xiyou.wangcong
2012-01-16 7:58 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: xiyou.wangcong @ 2012-01-15 11:56 UTC (permalink / raw)
To: linux-kernel
Cc: Andrew Morton, Yinghai Lu, Tejun Heo, ianfang.cn, WANG Cong,
Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
Konrad Rzeszutek Wilk, Stefano Stabellini
For machine enables PSE, the first 2/4M memory region still uses
4K pages, so needs more PTEs in this case, but find_early_table_space()
doesn't count this. This patch fixes it.
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: ianfang.cn@gmail.com
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
---
arch/x86/mm/init.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 6cabf65..2e92fdc 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -30,8 +30,14 @@ int direct_gbpages
#endif
;
-static void __init find_early_table_space(unsigned long end, int use_pse,
- int use_gbpages)
+struct map_range {
+ unsigned long start;
+ unsigned long end;
+ unsigned page_size_mask;
+};
+
+static void __init find_early_table_space(struct map_range *mr, unsigned long end,
+ int use_pse, int use_gbpages)
{
unsigned long puds, pmds, ptes, tables, start = 0, good_end = end;
phys_addr_t base;
@@ -56,6 +62,9 @@ static void __init find_early_table_space(unsigned long end, int use_pse,
#ifdef CONFIG_X86_32
extra += PMD_SIZE;
#endif
+ /* The first 2/4M doesn't use large pages. */
+ extra += mr->end - mr->start;
+
ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
} else
ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -85,12 +94,6 @@ void __init native_pagetable_reserve(u64 start, u64 end)
memblock_reserve(start, end - start);
}
-struct map_range {
- unsigned long start;
- unsigned long end;
- unsigned page_size_mask;
-};
-
#ifdef CONFIG_X86_32
#define NR_RANGE_MR 3
#else /* CONFIG_X86_64 */
@@ -262,7 +265,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
* nodes are discovered.
*/
if (!after_bootmem)
- find_early_table_space(end, use_pse, use_gbpages);
+ find_early_table_space(&mr[0], end, use_pse, use_gbpages);
for (i = 0; i < nr_range; i++)
ret = kernel_physical_mapping_init(mr[i].start, mr[i].end,
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch] x86, mm: fix the size calculation of mapping tables
2012-01-15 11:56 [Patch] x86, mm: fix the size calculation of mapping tables xiyou.wangcong
@ 2012-01-16 7:58 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2012-01-16 7:58 UTC (permalink / raw)
To: xiyou.wangcong
Cc: linux-kernel, Andrew Morton, Yinghai Lu, Tejun Heo, ianfang.cn,
Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
Konrad Rzeszutek Wilk, Stefano Stabellini
* xiyou.wangcong@gmail.com <xiyou.wangcong@gmail.com> wrote:
> For machine enables PSE, the first 2/4M memory region still uses
> 4K pages, so needs more PTEs in this case, but find_early_table_space()
> doesn't count this. This patch fixes it.
>
> Cc: Yinghai Lu <yinghai@kernel.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: ianfang.cn@gmail.com
> Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
What were the symptoms of this bug - or have you found it via
review only?
Thanks,
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-16 7:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-15 11:56 [Patch] x86, mm: fix the size calculation of mapping tables xiyou.wangcong
2012-01-16 7:58 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome