Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp329446pxu; Thu, 3 Dec 2020 01:01:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWOD31P/4yrWZNGcJ1OMbqvxwzRBd+maFlURCsanBMi7Y55LyYpcnX7rBPuXLmc7jTtflW X-Received: by 2002:a17:906:7016:: with SMTP id n22mr1511580ejj.402.1606986095509; Thu, 03 Dec 2020 01:01:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606986095; cv=none; d=google.com; s=arc-20160816; b=KO8wMRc2NvQ6PGLRExX3CnrmYhXyDU15iBzmVjQXU5i1mYETJMT756QyZaKJamIh/Y 864ymEwd8v9bzqJyfwZmgyMZJ96prK+qkmlDEDeL17XpPGQVWs58x1YV0lOEf48FBSWM xOSbDBxs2xb5V35LzrQ2my4R+88/GKxJp1QET7JP/Q5EYl0qkrSScRxyXiiJRIKL8Vk0 R1HdHxT1imC5mQLtOIaNTgHCwSM1Qh7E/CgOH2YX7+7znmzAE8ek8wCSRL6mgI8jjg3S TUhxL/NJbsS7ObzSLpqvhEgpnYUmUIf2weRd0+0B5hLu4+dFGL3uotRg1gA56W19EFRT bVzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=X2Yyc6NHupA9RSfKo8JlmozvN3V2TWR/2mSWT7UcWGI=; b=h52FxRi7IFaJLg/cMA9nFDA3BbJMOvJuXfRW9MqHlgb4/piQd2mdnnQffrgq260239 R6jSieS2mTxXzHLkTMNb1QrS9NAgWra3wdoCfhlucUfHGxnxTdaqgMNkNuxY06Edgi0n AEEAGUf9w44oXjKKTKkkKBzTDXti7CQhttWNKI7364+c/CD7iAXSXRMrtW47ON/Z0oPl BjT7q3X92FJT+T2eTvnbzfAnhgk1YAWow6XVJIwQfc/E/NXhCqSbZAwNCYEd6m/25OwE YoBAfHo2uKQ2bVW4gXsGQT//4AFsCgR2PoqljuFNmebYKGLXHnfJykuETXGfAGjYb/Vd TuSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si754495ejk.231.2020.12.03.01.01.11; Thu, 03 Dec 2020 01:01:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730041AbgLCI6g (ORCPT + 99 others); Thu, 3 Dec 2020 03:58:36 -0500 Received: from mail.loongson.cn ([114.242.206.163]:33520 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728037AbgLCI6e (ORCPT ); Thu, 3 Dec 2020 03:58:34 -0500 Received: from bogon.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx73+LqMhf01sZAA--.41290S4; Thu, 03 Dec 2020 16:57:49 +0800 (CST) From: Jinyang He To: Thomas Bogendoerfer , Huacai Chen , Jiaxun Yang 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 Message-Id: <1606985867-9791-3-git-send-email-hejinyang@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1606985867-9791-1-git-send-email-hejinyang@loongson.cn> References: <1606985867-9791-1-git-send-email-hejinyang@loongson.cn> X-CM-TRANSID: AQAAf9Dx73+LqMhf01sZAA--.41290S4 X-Coremail-Antispam: 1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UUUU== X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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