linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2]  memory node
@ 2020-12-03  8:57 Jinyang He
  2020-12-03  8:57 ` [PATCH 1/2] MIPS: Remove unused memblock_set_node Jinyang He
  2020-12-03  8:57 ` [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter Jinyang He
  0 siblings, 2 replies; 5+ messages in thread
From: Jinyang He @ 2020-12-03  8:57 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Huacai Chen, Jiaxun Yang; +Cc: linux-mips, linux-kernel

*** BLURB HERE ***

Jinyang He (2):
  MIPS: Remove unused memblock_set_node
  MIPS: Add fix_range_node after parse "mem=" parameter

 arch/mips/include/asm/bootinfo.h |  1 +
 arch/mips/kernel/setup.c         |  9 +++++----
 arch/mips/loongson64/numa.c      | 11 +++++++++++
 3 files changed, 17 insertions(+), 4 deletions(-)

-- 
2.1.0


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

* [PATCH 1/2] MIPS: Remove unused memblock_set_node
  2020-12-03  8:57 [PATCH 0/2] memory node Jinyang He
@ 2020-12-03  8:57 ` Jinyang He
  2020-12-03  8:57 ` [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter Jinyang He
  1 sibling, 0 replies; 5+ messages in thread
From: Jinyang He @ 2020-12-03  8:57 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Huacai Chen, Jiaxun Yang; +Cc: linux-mips, linux-kernel

Seting node for platforms which not need multiple nodes make no sence
after we abandoning DISCONTIGMEM.

Signed-off-by: Jinyang He <hejinyang@loongson.cn>
---
 arch/mips/kernel/setup.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index ca579de..b3a711e 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -639,9 +639,6 @@ static void __init arch_mem_init(char **cmdline_p)
 	early_init_fdt_reserve_self();
 	early_init_fdt_scan_reserved_mem();
 
-#ifndef CONFIG_NUMA
-	memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
-#endif
 	bootmem_init();
 
 	/*
-- 
2.1.0


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

* [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter
  2020-12-03  8:57 [PATCH 0/2] memory node Jinyang He
  2020-12-03  8:57 ` [PATCH 1/2] MIPS: Remove unused memblock_set_node Jinyang He
@ 2020-12-03  8:57 ` Jinyang He
  2020-12-03  9:27   ` Jiaxun Yang
  1 sibling, 1 reply; 5+ messages in thread
From: Jinyang He @ 2020-12-03  8:57 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Huacai Chen, Jiaxun Yang; +Cc: linux-mips, linux-kernel

This problem may only occur on NUMA platforms. When machine start
with the "mem=" parameter on Loongson64, it cannot boot. When parsing the
"mem=" parameter, first all the RAM was removed, and then the memory was
not added by memblock_add_node(), which caused the newly added memory to
be on MAX_NUMNODES. The key to solve this problem is to fix these memory
nodes through memblock_set_node() before bootmem_init() or earlier. So
it would be better to fix it before check_kernel_sections_mem().
The check_kernel_sections_mem() will check whether the current RAM can be
used by the kernel. If this fix is added after that, it will do a redundant
memblock_add operation. Adding the fixup_region_node() function can also
provide a reference for future platforms using NUMA when encountering
such problems.

Signed-off-by: Jinyang He <hejinyang@loongson.cn>
---
 arch/mips/include/asm/bootinfo.h |  1 +
 arch/mips/kernel/setup.c         |  6 +++++-
 arch/mips/loongson64/numa.c      | 11 +++++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
index aa03b12..ddc17b1 100644
--- a/arch/mips/include/asm/bootinfo.h
+++ b/arch/mips/include/asm/bootinfo.h
@@ -91,6 +91,7 @@ const char *get_system_type(void);
 extern unsigned long mips_machtype;
 
 extern void detect_memory_region(phys_addr_t start, phys_addr_t sz_min,  phys_addr_t sz_max);
+extern void fixup_region_node(void);
 
 extern void prom_init(void);
 extern void prom_free_prom_memory(void);
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index b3a711e..fe93882 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -110,6 +110,8 @@ void __init detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_add
 	memblock_add(start, size);
 }
 
+void __weak fixup_region_node(void) {}
+
 /*
  * Manage initrd
  */
@@ -631,8 +633,10 @@ static void __init arch_mem_init(char **cmdline_p)
 
 	parse_early_param();
 
-	if (usermem)
+	if (usermem) {
 		pr_info("User-defined physical RAM map overwrite\n");
+		fixup_region_node();
+	}
 
 	check_kernel_sections_mem();
 
diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
index c6f0c48..d8661cc 100644
--- a/arch/mips/loongson64/numa.c
+++ b/arch/mips/loongson64/numa.c
@@ -220,6 +220,17 @@ void __init mem_init(void)
 	mem_init_print_info(NULL);
 }
 
+void __init fixup_region_node(void)
+{
+	phys_addr_t start, end;
+	u64 i;
+
+	for_each_mem_range(i, &start, &end) {
+		memblock_set_node(start, end - start,
+				  &memblock.memory, pa_to_nid(start));
+	}
+}
+
 /* All PCI device belongs to logical Node-0 */
 int pcibus_to_node(struct pci_bus *bus)
 {
-- 
2.1.0


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

* Re: [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter
  2020-12-03  8:57 ` [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter Jinyang He
@ 2020-12-03  9:27   ` Jiaxun Yang
  2020-12-03  9:55     ` Jinyang He
  0 siblings, 1 reply; 5+ messages in thread
From: Jiaxun Yang @ 2020-12-03  9:27 UTC (permalink / raw)
  To: Jinyang He, Thomas Bogendoerfer, Huacai Chen; +Cc: linux-mips, linux-kernel



于 2020年12月3日 GMT+08:00 下午4:57:47, Jinyang He <hejinyang@loongson.cn> 写到:
>This problem may only occur on NUMA platforms. When machine start
>with the "mem=" parameter on Loongson64, it cannot boot. When parsing the
>"mem=" parameter, first all the RAM was removed, and then the memory was
>not added by memblock_add_node(), which caused the newly added memory to
>be on MAX_NUMNODES. The key to solve this problem is to fix these memory
>nodes through memblock_set_node() before bootmem_init() or earlier. So
>it would be better to fix it before check_kernel_sections_mem().
>The check_kernel_sections_mem() will check whether the current RAM can be
>used by the kernel. If this fix is added after that, it will do a redundant
>memblock_add operation. Adding the fixup_region_node() function can also
>provide a reference for future platforms using NUMA when encountering
>such problems.

Hi Jingyang,

Is it possible to do it when parsing cmdline to avoid this kind of fixup?

Thanks.

- Jiaxun

>
>Signed-off-by: Jinyang He <hejinyang@loongson.cn>
>---
> arch/mips/include/asm/bootinfo.h |  1 +
> arch/mips/kernel/setup.c         |  6 +++++-
> arch/mips/loongson64/numa.c      | 11 +++++++++++
> 3 files changed, 17 insertions(+), 1 deletion(-)
>
>diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
>index aa03b12..ddc17b1 100644
>--- a/arch/mips/include/asm/bootinfo.h
>+++ b/arch/mips/include/asm/bootinfo.h
>@@ -91,6 +91,7 @@ const char *get_system_type(void);
> extern unsigned long mips_machtype;
> 
> extern void detect_memory_region(phys_addr_t start, phys_addr_t sz_min,  phys_addr_t sz_max);
>+extern void fixup_region_node(void);
> 
> extern void prom_init(void);
> extern void prom_free_prom_memory(void);
>diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
>index b3a711e..fe93882 100644
>--- a/arch/mips/kernel/setup.c
>+++ b/arch/mips/kernel/setup.c
>@@ -110,6 +110,8 @@ void __init detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_add
> 	memblock_add(start, size);
> }
> 
>+void __weak fixup_region_node(void) {}
>+
> /*
>  * Manage initrd
>  */
>@@ -631,8 +633,10 @@ static void __init arch_mem_init(char **cmdline_p)
> 
> 	parse_early_param();
> 
>-	if (usermem)
>+	if (usermem) {
> 		pr_info("User-defined physical RAM map overwrite\n");
>+		fixup_region_node();
>+	}
> 
> 	check_kernel_sections_mem();
> 
>diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
>index c6f0c48..d8661cc 100644
>--- a/arch/mips/loongson64/numa.c
>+++ b/arch/mips/loongson64/numa.c
>@@ -220,6 +220,17 @@ void __init mem_init(void)
> 	mem_init_print_info(NULL);
> }
> 
>+void __init fixup_region_node(void)
>+{
>+	phys_addr_t start, end;
>+	u64 i;
>+
>+	for_each_mem_range(i, &start, &end) {
>+		memblock_set_node(start, end - start,
>+				  &memblock.memory, pa_to_nid(start));
>+	}
>+}
>+
> /* All PCI device belongs to logical Node-0 */
> int pcibus_to_node(struct pci_bus *bus)
> {

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

* Re: [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter
  2020-12-03  9:27   ` Jiaxun Yang
@ 2020-12-03  9:55     ` Jinyang He
  0 siblings, 0 replies; 5+ messages in thread
From: Jinyang He @ 2020-12-03  9:55 UTC (permalink / raw)
  To: Jiaxun Yang, Thomas Bogendoerfer, Huacai Chen; +Cc: linux-mips, linux-kernel



On 12/03/2020 05:27 PM, Jiaxun Yang wrote:
>
> 于 2020年12月3日 GMT+08:00 下午4:57:47, Jinyang He <hejinyang@loongson.cn> 写到:
>> This problem may only occur on NUMA platforms. When machine start
>> with the "mem=" parameter on Loongson64, it cannot boot. When parsing the
>> "mem=" parameter, first all the RAM was removed, and then the memory was
>> not added by memblock_add_node(), which caused the newly added memory to
>> be on MAX_NUMNODES. The key to solve this problem is to fix these memory
>> nodes through memblock_set_node() before bootmem_init() or earlier. So
>> it would be better to fix it before check_kernel_sections_mem().
>> The check_kernel_sections_mem() will check whether the current RAM can be
>> used by the kernel. If this fix is added after that, it will do a redundant
>> memblock_add operation. Adding the fixup_region_node() function can also
>> provide a reference for future platforms using NUMA when encountering
>> such problems.
> Hi Jingyang,
>
> Is it possible to do it when parsing cmdline to avoid this kind of fixup?
>
> Thanks.
>
> - Jiaxun

Hi, Jiaxun,

Of course. But "memmap=" could cause same problem , "mem=" could
parse many times. So it better to fix it after these parse opertion 
having done.

Thanks,
Jinyang.

>> Signed-off-by: Jinyang He <hejinyang@loongson.cn>
>> ---
>> arch/mips/include/asm/bootinfo.h |  1 +
>> arch/mips/kernel/setup.c         |  6 +++++-
>> arch/mips/loongson64/numa.c      | 11 +++++++++++
>> 3 files changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
>> index aa03b12..ddc17b1 100644
>> --- a/arch/mips/include/asm/bootinfo.h
>> +++ b/arch/mips/include/asm/bootinfo.h
>> @@ -91,6 +91,7 @@ const char *get_system_type(void);
>> extern unsigned long mips_machtype;
>>
>> extern void detect_memory_region(phys_addr_t start, phys_addr_t sz_min,  phys_addr_t sz_max);
>> +extern void fixup_region_node(void);
>>
>> extern void prom_init(void);
>> extern void prom_free_prom_memory(void);
>> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
>> index b3a711e..fe93882 100644
>> --- a/arch/mips/kernel/setup.c
>> +++ b/arch/mips/kernel/setup.c
>> @@ -110,6 +110,8 @@ void __init detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_add
>> 	memblock_add(start, size);
>> }
>>
>> +void __weak fixup_region_node(void) {}
>> +
>> /*
>>   * Manage initrd
>>   */
>> @@ -631,8 +633,10 @@ static void __init arch_mem_init(char **cmdline_p)
>>
>> 	parse_early_param();
>>
>> -	if (usermem)
>> +	if (usermem) {
>> 		pr_info("User-defined physical RAM map overwrite\n");
>> +		fixup_region_node();
>> +	}
>>
>> 	check_kernel_sections_mem();
>>
>> diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
>> index c6f0c48..d8661cc 100644
>> --- a/arch/mips/loongson64/numa.c
>> +++ b/arch/mips/loongson64/numa.c
>> @@ -220,6 +220,17 @@ void __init mem_init(void)
>> 	mem_init_print_info(NULL);
>> }
>>
>> +void __init fixup_region_node(void)
>> +{
>> +	phys_addr_t start, end;
>> +	u64 i;
>> +
>> +	for_each_mem_range(i, &start, &end) {
>> +		memblock_set_node(start, end - start,
>> +				  &memblock.memory, pa_to_nid(start));
>> +	}
>> +}
>> +
>> /* All PCI device belongs to logical Node-0 */
>> int pcibus_to_node(struct pci_bus *bus)
>> {


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

end of thread, other threads:[~2020-12-03  9:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03  8:57 [PATCH 0/2] memory node Jinyang He
2020-12-03  8:57 ` [PATCH 1/2] MIPS: Remove unused memblock_set_node Jinyang He
2020-12-03  8:57 ` [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter Jinyang He
2020-12-03  9:27   ` Jiaxun Yang
2020-12-03  9:55     ` Jinyang He

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).