* Re: [PATCH v4 21/22] x86, mm: Make init_mem_mapping be able to be called several times
@ 2013-04-12 1:05 Konrad Wilk
2013-04-12 2:04 ` Yinghai Lu
0 siblings, 1 reply; 4+ messages in thread
From: Konrad Wilk @ 2013-04-12 1:05 UTC (permalink / raw)
To: yinghai
Cc: trenn, tangchen, tglx, penberg, akpm, mingo, jacob.shin, tj,
linux-kernel, hpa
----- yinghai@kernel.org wrote:
> Prepare to put page table on local nodes.
>
> Move calling of init_mem_mapping to early_initmem_init.
>
> Rework alloc_low_pages to alloc page table in following order:
> BRK, local node, low range
>
> Still only load_cr3 one time, otherwise we would break xen 64bit
> again.
I have asked you in the previous iteration of the patch to fix that comment.
Please remove it - as it is misleading. The issue with load_cr3 more than
once has been fixed under the Xen platform.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4 21/22] x86, mm: Make init_mem_mapping be able to be called several times
2013-04-12 1:05 [PATCH v4 21/22] x86, mm: Make init_mem_mapping be able to be called several times Konrad Wilk
@ 2013-04-12 2:04 ` Yinghai Lu
2013-04-12 2:20 ` H. Peter Anvin
0 siblings, 1 reply; 4+ messages in thread
From: Yinghai Lu @ 2013-04-12 2:04 UTC (permalink / raw)
To: Konrad Wilk
Cc: Thomas Renninger, Tang Chen, Thomas Gleixner, Pekka Enberg,
Andrew Morton, Ingo Molnar, Jacob Shin, Tejun Heo,
Linux Kernel Mailing List, H. Peter Anvin
On Thu, Apr 11, 2013 at 6:05 PM, Konrad Wilk <konrad.wilk@oracle.com> wrote:
>
> ----- yinghai@kernel.org wrote:
>
>> Prepare to put page table on local nodes.
>>
>> Move calling of init_mem_mapping to early_initmem_init.
>>
>> Rework alloc_low_pages to alloc page table in following order:
>> BRK, local node, low range
>>
>> Still only load_cr3 one time, otherwise we would break xen 64bit
>> again.
>
> I have asked you in the previous iteration of the patch to fix that comment.
Maybe it is not clear enough.
>
> Please remove it - as it is misleading. The issue with load_cr3 more than
> once has been fixed under the Xen platform.
Peter, can you remove those two lines?
or need to resend -v5?
Thanks
Yinghai
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4 21/22] x86, mm: Make init_mem_mapping be able to be called several times
2013-04-12 2:04 ` Yinghai Lu
@ 2013-04-12 2:20 ` H. Peter Anvin
0 siblings, 0 replies; 4+ messages in thread
From: H. Peter Anvin @ 2013-04-12 2:20 UTC (permalink / raw)
To: Yinghai Lu, Konrad Wilk
Cc: Thomas Renninger, Tang Chen, Thomas Gleixner, Pekka Enberg,
Andrew Morton, Ingo Molnar, Jacob Shin, Tejun Heo,
Linux Kernel Mailing List
Please send a replacement patch.
Yinghai Lu <yinghai@kernel.org> wrote:
>On Thu, Apr 11, 2013 at 6:05 PM, Konrad Wilk <konrad.wilk@oracle.com>
>wrote:
>>
>> ----- yinghai@kernel.org wrote:
>>
>>> Prepare to put page table on local nodes.
>>>
>>> Move calling of init_mem_mapping to early_initmem_init.
>>>
>>> Rework alloc_low_pages to alloc page table in following order:
>>> BRK, local node, low range
>>>
>>> Still only load_cr3 one time, otherwise we would break xen 64bit
>>> again.
>>
>> I have asked you in the previous iteration of the patch to fix that
>comment.
>
>Maybe it is not clear enough.
>
>>
>> Please remove it - as it is misleading. The issue with load_cr3 more
>than
>> once has been fixed under the Xen platform.
>
>Peter, can you remove those two lines?
>or need to resend -v5?
>
>Thanks
>
>Yinghai
--
Sent from my mobile phone. Please excuse brevity and lack of formatting.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4 00/22] x86, ACPI, numa: Parse numa info early
@ 2013-04-12 0:55 Yinghai Lu
2013-04-12 0:56 ` [PATCH v4 21/22] x86, mm: Make init_mem_mapping be able to be called several times Yinghai Lu
0 siblings, 1 reply; 4+ messages in thread
From: Yinghai Lu @ 2013-04-12 0:55 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton,
Tejun Heo, Thomas Renninger, Tang Chen
Cc: linux-kernel, Yinghai Lu
One commit that tried to parse SRAT early get reverted before v3.9-rc1.
| commit e8d1955258091e4c92d5a975ebd7fd8a98f5d30f
| Author: Tang Chen <tangchen@cn.fujitsu.com>
| Date: Fri Feb 22 16:33:44 2013 -0800
|
| acpi, memory-hotplug: parse SRAT before memblock is ready
It broke several things, like acpi override and fall back path etc.
This patchset is clean implementation that will parse numa info early.
1. keep the acpi table initrd override working by split finding with copying.
finding is done at head_32.S and head64.c stage,
in head_32.S, initrd is accessed in 32bit flat mode with phys addr.
in head64.c, initrd is accessed via kernel low mapping address
with help of #PF set page table.
copying is done with early_ioremap just after memblock is setup.
2. keep fallback path working. numaq and ACPI and amd_nmua and dummy.
seperate initmem_init to two stages.
early_initmem_init will only extract numa info early into numa_meminfo.
initmem_init will keep slit and emulation handling.
3. keep other old code flow untouched like relocate_initrd and initmem_init.
early_initmem_init will take old init_mem_mapping position.
it call early_x86_numa_init and init_mem_mapping for every nodes.
For 64bit, we avoid having size limit on initrd, as relocate_initrd
is still after init_mem_mapping for all memory.
4. last patch will try to put page table on local node, so that memory
hotplug will be happy.
In short, early_initmem_init will parse numa info early and call
init_mem_mapping to set page table for every nodes's mem.
could be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-x86-mm
and it is based on today's Linus tree.
-v2: Address tj's review and split patches to small ones.
-v3: Add some Acked-by from tj, also stop abusing cpio_data for acpi_files info
-v4: fix one typo found by Tang Chen.
Also added tested-by from Thomas Renninger and Tony.
Thanks
Yinghai
Yinghai Lu (22):
x86: Change get_ramdisk_image() to global
x86, microcode: Use common get_ramdisk_image()
x86, ACPI, mm: Kill max_low_pfn_mapped
x86, ACPI: Search buffer above 4G in second try for acpi override
tables
x86, ACPI: Increase override tables number limit
x86, ACPI: Split acpi_initrd_override to find/copy two functions
x86, ACPI: Store override acpi tables phys addr in cpio files info
array
x86, ACPI: Make acpi_initrd_override_find work with 32bit flat mode
x86, ACPI: Find acpi tables in initrd early from head_32.S/head64.c
x86, mm, numa: Move two functions calling on successful path later
x86, mm, numa: Call numa_meminfo_cover_memory() checking early
x86, mm, numa: Move node_map_pfn alignment() to x86
x86, mm, numa: Use numa_meminfo to check node_map_pfn alignment
x86, mm, numa: Set memblock nid later
x86, mm, numa: Move node_possible_map setting later
x86, mm, numa: Move emulation handling down.
x86, ACPI, numa, ia64: split SLIT handling out
x86, mm, numa: Add early_initmem_init() stub
x86, mm: Parse numa info early
x86, mm: Add comments for step_size shift
x86, mm: Make init_mem_mapping be able to be called several times
x86, mm, numa: Put pagetable on local node ram for 64bit
arch/ia64/kernel/setup.c | 4 +-
arch/x86/include/asm/acpi.h | 3 +-
arch/x86/include/asm/page_types.h | 2 +-
arch/x86/include/asm/pgtable.h | 2 +-
arch/x86/include/asm/setup.h | 9 ++
arch/x86/kernel/head64.c | 2 +
arch/x86/kernel/head_32.S | 4 +
arch/x86/kernel/microcode_intel_early.c | 8 +-
arch/x86/kernel/setup.c | 86 +++++++-----
arch/x86/mm/init.c | 109 ++++++++++-----
arch/x86/mm/numa.c | 240 +++++++++++++++++++++++++-------
arch/x86/mm/numa_emulation.c | 2 +-
arch/x86/mm/numa_internal.h | 2 +
arch/x86/mm/srat.c | 11 +-
drivers/acpi/numa.c | 13 +-
drivers/acpi/osl.c | 138 ++++++++++++------
include/linux/acpi.h | 20 +--
include/linux/mm.h | 3 -
mm/page_alloc.c | 52 +------
19 files changed, 467 insertions(+), 243 deletions(-)
--
1.8.1.4
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v4 21/22] x86, mm: Make init_mem_mapping be able to be called several times
2013-04-12 0:55 [PATCH v4 00/22] x86, ACPI, numa: Parse numa info early Yinghai Lu
@ 2013-04-12 0:56 ` Yinghai Lu
0 siblings, 0 replies; 4+ messages in thread
From: Yinghai Lu @ 2013-04-12 0:56 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton,
Tejun Heo, Thomas Renninger, Tang Chen
Cc: linux-kernel, Yinghai Lu, Pekka Enberg, Jacob Shin,
Konrad Rzeszutek Wilk
Prepare to put page table on local nodes.
Move calling of init_mem_mapping to early_initmem_init.
Rework alloc_low_pages to alloc page table in following order:
BRK, local node, low range
Still only load_cr3 one time, otherwise we would break xen 64bit again.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Jacob Shin <jacob.shin@amd.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/include/asm/pgtable.h | 2 +-
arch/x86/kernel/setup.c | 1 -
arch/x86/mm/init.c | 88 ++++++++++++++++++++++++++----------------
arch/x86/mm/numa.c | 24 ++++++++++++
4 files changed, 79 insertions(+), 36 deletions(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 1e67223..868687c 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -621,7 +621,7 @@ static inline int pgd_none(pgd_t pgd)
#ifndef __ASSEMBLY__
extern int direct_gbpages;
-void init_mem_mapping(void);
+void init_mem_mapping(unsigned long begin, unsigned long end);
void early_alloc_pgt_buf(void);
/* local pte updates need not use xchg for locking */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 6ef3fa2..67ef4bc 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1105,7 +1105,6 @@ void __init setup_arch(char **cmdline_p)
acpi_boot_table_init();
early_acpi_boot_init();
early_initmem_init();
- init_mem_mapping();
memblock.current_limit = get_max_mapped();
early_trap_pf_init();
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 2754e45..8a03283 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -24,7 +24,10 @@ static unsigned long __initdata pgt_buf_start;
static unsigned long __initdata pgt_buf_end;
static unsigned long __initdata pgt_buf_top;
-static unsigned long min_pfn_mapped;
+static unsigned long low_min_pfn_mapped;
+static unsigned long low_max_pfn_mapped;
+static unsigned long local_min_pfn_mapped;
+static unsigned long local_max_pfn_mapped;
static bool __initdata can_use_brk_pgt = true;
@@ -52,10 +55,17 @@ __ref void *alloc_low_pages(unsigned int num)
if ((pgt_buf_end + num) > pgt_buf_top || !can_use_brk_pgt) {
unsigned long ret;
- if (min_pfn_mapped >= max_pfn_mapped)
- panic("alloc_low_page: ran out of memory");
- ret = memblock_find_in_range(min_pfn_mapped << PAGE_SHIFT,
- max_pfn_mapped << PAGE_SHIFT,
+ if (local_min_pfn_mapped >= local_max_pfn_mapped) {
+ if (low_min_pfn_mapped >= low_max_pfn_mapped)
+ panic("alloc_low_page: ran out of memory");
+ ret = memblock_find_in_range(
+ low_min_pfn_mapped << PAGE_SHIFT,
+ low_max_pfn_mapped << PAGE_SHIFT,
+ PAGE_SIZE * num , PAGE_SIZE);
+ } else
+ ret = memblock_find_in_range(
+ local_min_pfn_mapped << PAGE_SHIFT,
+ local_max_pfn_mapped << PAGE_SHIFT,
PAGE_SIZE * num , PAGE_SIZE);
if (!ret)
panic("alloc_low_page: can not alloc memory");
@@ -402,60 +412,75 @@ static unsigned long __init get_new_step_size(unsigned long step_size)
return step_size;
}
-void __init init_mem_mapping(void)
+void __init init_mem_mapping(unsigned long begin, unsigned long end)
{
- unsigned long end, real_end, start, last_start;
+ unsigned long real_end, start, last_start;
unsigned long step_size;
unsigned long addr;
unsigned long mapped_ram_size = 0;
unsigned long new_mapped_ram_size;
+ bool is_low = false;
+
+ if (!begin) {
+ probe_page_size_mask();
+ /* the ISA range is always mapped regardless of memory holes */
+ init_memory_mapping(0, ISA_END_ADDRESS);
+ begin = ISA_END_ADDRESS;
+ is_low = true;
+ }
- probe_page_size_mask();
-
-#ifdef CONFIG_X86_64
- end = max_pfn << PAGE_SHIFT;
-#else
- end = max_low_pfn << PAGE_SHIFT;
-#endif
-
- /* the ISA range is always mapped regardless of memory holes */
- init_memory_mapping(0, ISA_END_ADDRESS);
+ if (begin >= end)
+ return;
/* xen has big range in reserved near end of ram, skip it at first.*/
- addr = memblock_find_in_range(ISA_END_ADDRESS, end, PMD_SIZE, PMD_SIZE);
+ addr = memblock_find_in_range(begin, end, PMD_SIZE, PMD_SIZE);
real_end = addr + PMD_SIZE;
/* step_size need to be small so pgt_buf from BRK could cover it */
step_size = PMD_SIZE;
- max_pfn_mapped = 0; /* will get exact value next */
- min_pfn_mapped = real_end >> PAGE_SHIFT;
+ local_max_pfn_mapped = begin >> PAGE_SHIFT;
+ local_min_pfn_mapped = real_end >> PAGE_SHIFT;
last_start = start = real_end;
- while (last_start > ISA_END_ADDRESS) {
+ while (last_start > begin) {
if (last_start > step_size) {
start = round_down(last_start - 1, step_size);
- if (start < ISA_END_ADDRESS)
- start = ISA_END_ADDRESS;
+ if (start < begin)
+ start = begin;
} else
- start = ISA_END_ADDRESS;
+ start = begin;
new_mapped_ram_size = init_range_memory_mapping(start,
last_start);
+ if ((last_start >> PAGE_SHIFT) > local_max_pfn_mapped)
+ local_max_pfn_mapped = last_start >> PAGE_SHIFT;
+ local_min_pfn_mapped = start >> PAGE_SHIFT;
last_start = start;
- min_pfn_mapped = last_start >> PAGE_SHIFT;
/* only increase step_size after big range get mapped */
if (new_mapped_ram_size > mapped_ram_size)
step_size = get_new_step_size(step_size);
mapped_ram_size += new_mapped_ram_size;
}
- if (real_end < end)
+ if (real_end < end) {
init_range_memory_mapping(real_end, end);
+ if ((end >> PAGE_SHIFT) > local_max_pfn_mapped)
+ local_max_pfn_mapped = end >> PAGE_SHIFT;
+ }
+ if (is_low) {
+ low_min_pfn_mapped = local_min_pfn_mapped;
+ low_max_pfn_mapped = local_max_pfn_mapped;
+ }
+}
+
+#ifndef CONFIG_NUMA
+void __init early_initmem_init(void)
+{
#ifdef CONFIG_X86_64
- if (max_pfn > max_low_pfn) {
- /* can we preseve max_low_pfn ?*/
+ init_mem_mapping(0, max_pfn << PAGE_SHIFT);
+ if (max_pfn > max_low_pfn)
max_low_pfn = max_pfn;
- }
#else
+ init_mem_mapping(0, max_low_pfn << PAGE_SHIFT);
early_ioremap_page_table_range_init();
#endif
@@ -464,11 +489,6 @@ void __init init_mem_mapping(void)
early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
}
-
-#ifndef CONFIG_NUMA
-void __init early_initmem_init(void)
-{
-}
#endif
/*
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index c2d4653..d3eb0c9 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -17,8 +17,10 @@
#include <asm/dma.h>
#include <asm/acpi.h>
#include <asm/amd_nb.h>
+#include <asm/tlbflush.h>
#include "numa_internal.h"
+#include "mm_internal.h"
int __initdata numa_off;
nodemask_t numa_nodes_parsed __initdata;
@@ -668,9 +670,31 @@ static void __init early_x86_numa_init(void)
numa_init(dummy_numa_init);
}
+#ifdef CONFIG_X86_64
+static void __init early_x86_numa_init_mapping(void)
+{
+ init_mem_mapping(0, max_pfn << PAGE_SHIFT);
+ if (max_pfn > max_low_pfn)
+ max_low_pfn = max_pfn;
+}
+#else
+static void __init early_x86_numa_init_mapping(void)
+{
+ init_mem_mapping(0, max_low_pfn << PAGE_SHIFT);
+ early_ioremap_page_table_range_init();
+}
+#endif
+
void __init early_initmem_init(void)
{
early_x86_numa_init();
+
+ early_x86_numa_init_mapping();
+
+ load_cr3(swapper_pg_dir);
+ __flush_tlb_all();
+
+ early_memtest(0, max_pfn_mapped<<PAGE_SHIFT);
}
void __init x86_numa_init(void)
--
1.8.1.4
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-12 2:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-12 1:05 [PATCH v4 21/22] x86, mm: Make init_mem_mapping be able to be called several times Konrad Wilk
2013-04-12 2:04 ` Yinghai Lu
2013-04-12 2:20 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2013-04-12 0:55 [PATCH v4 00/22] x86, ACPI, numa: Parse numa info early Yinghai Lu
2013-04-12 0:56 ` [PATCH v4 21/22] x86, mm: Make init_mem_mapping be able to be called several times Yinghai Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®