From: Jinyang He <hejinyang@loongson.cn>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Huacai Chen <chenhc@lemote.com>,
Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter
Date: Thu, 3 Dec 2020 16:57:47 +0800 [thread overview]
Message-ID: <1606985867-9791-3-git-send-email-hejinyang@loongson.cn> (raw)
In-Reply-To: <1606985867-9791-1-git-send-email-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.
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
next prev parent reply other threads:[~2020-12-03 8:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2020-12-03 9:27 ` [PATCH 2/2] MIPS: Add fix_range_node after parse "mem=" parameter Jiaxun Yang
2020-12-03 9:55 ` Jinyang He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1606985867-9791-3-git-send-email-hejinyang@loongson.cn \
--to=hejinyang@loongson.cn \
--cc=chenhc@lemote.com \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).