Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2708438rdb; Tue, 12 Sep 2023 09:41:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtBu1S0M/0hiUhLvuf4kGxVra1i12xkMRs87pvAcTOtAA5e9AQJYFGL98e0QmpLW+3qkwg X-Received: by 2002:a05:6870:b6a4:b0:1d0:f5bd:6c8 with SMTP id cy36-20020a056870b6a400b001d0f5bd06c8mr23272oab.5.1694536860831; Tue, 12 Sep 2023 09:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694536860; cv=none; d=google.com; s=arc-20160816; b=n3/Aj6XxqUJCKKMSXZpikLfYfI7Y0++0N29UnzSHmLEulWjB1UXGHD70DR8bL7NuV3 VoUX4ksDP4KxM6q31WPNyDt4b8wcclZtUJMJZ+dOA+pXQdOmg+t8VOyE/2GTXWZ24knM XlCvdTYG1jR9ScPBHmKEEvZOXLOkLg1bfjKNEG6K+sUh65E3PpvkXDgAbEhF29qF/TMP TZYWbfWbedWn+DpODBAMIMIl0Wwqy4FONul651cPT9uItYUrsppHhInVelsVplqp96UI IanmhI3C+e7NZnyobtUh+7YDHIXw67ixwHfxcsTqRvUAX55GMnStdZqGavRE5nApmZPV x0NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=DSzj/ZCZ1uP+BaACVoRVOoxq/efOYtDMUkASJC1N3eY=; fh=EDdX9X5U+eenK3dADCLl/gKs8jVUE5bg4zPrhtM/g/E=; b=xGsXxtp4Zt5cNCl/8qqD6dLASdq12MRkcLhAsq7a8qc30b0YZlzvKIuKZl/i7+61jw hFScy/03+zlvti/47AyzE/Wlm8ZtppHqZFaRXVIlYUOaHHWrpJsPsTxp94fuL9RyvSCc x2VJdgIMu9u9JIjdfp42E1neoy7HeYC9okEcRb1PdAKQ85DaW9S/0PFqC3hjZMRw2rCQ tpIUlKKqE4CeV56xzM1kvZmpfvgOtnOoYvUatY6vS+LSP6WASuY0peatjwN34x3Fz77O 05Rcb3k8q3yESHNzGLrqKyGkIakN1uYqztsCo2gdSEtmSq5HSgukG8mQNdN/ROCAkrOE gedA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=I1ZyuG9e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id m1-20020a656a01000000b00573fffaed37si8716278pgu.476.2023.09.12.09.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 09:41:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=I1ZyuG9e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3158D80FCE2E; Tue, 12 Sep 2023 09:08:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234544AbjILQIG (ORCPT + 99 others); Tue, 12 Sep 2023 12:08:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbjILQIF (ORCPT ); Tue, 12 Sep 2023 12:08:05 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97C2C10DE for ; Tue, 12 Sep 2023 09:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1694534872; bh=TFmefhI42+iEoIzW3KV4n3E64ZgbD2Bt6Pu49+Cq3KI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=I1ZyuG9eQf11TP1UkUssDs+Gyc52kAf/WXj0GYJioqhOhOi10GTZG0fKgipKtifC6 NGwF8Vro2VKtCrinWCsfUqeeF6Jm5XJM4eB5kH37O6oY5rREm58V6oHdvF8hIoJmHE YyW12f6HeBdda1bDQm+YMRl5P1uU1oBvyH2EQgWY= Received: from [192.168.9.172] (unknown [101.88.25.36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id E9C9160112; Wed, 13 Sep 2023 00:07:51 +0800 (CST) Message-ID: Date: Wed, 13 Sep 2023 00:07:51 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH] LoongArch: Set all reserved memblocks on Node#0 at initialization To: Huacai Chen , Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, WANG Xuerui References: <20230911092810.3108092-1-chenhuacai@loongson.cn> Content-Language: en-US From: WANG Xuerui In-Reply-To: <20230911092810.3108092-1-chenhuacai@loongson.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Sep 2023 09:08:13 -0700 (PDT) X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email On 9/11/23 17:28, Huacai Chen wrote: > After commit 61167ad5fecdea ("mm: pass nid to reserve_bootmem_region()") > we get a panic if DEFERRED_STRUCT_PAGE_INIT is enabled: > > [snip] > > The reason is early memblock_reserve() in memblock_init() set node id Why is it that only "early" but not "late" memblock_reserve() matters? I failed to see the reason because the arch-specific memblock_init() isn't even in the backtrace, which means that *neither* is the culprit. > to MAX_NUMNODES, which causes NODE_DATA(nid) be a NULL dereference in "making NODE_DATA(nid) a NULL ..." > reserve_bootmem_region() -> init_reserved_page(). So set all reserved > memblocks on Node#0 at initialization to avoid this panic. > > Reported-by: WANG Xuerui > Signed-off-by: Huacai Chen > --- > arch/loongarch/kernel/mem.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/loongarch/kernel/mem.c b/arch/loongarch/kernel/mem.c > index 4a4107a6a965..aed901c57fb4 100644 > --- a/arch/loongarch/kernel/mem.c > +++ b/arch/loongarch/kernel/mem.c > @@ -50,7 +50,6 @@ void __init memblock_init(void) > } > > memblock_set_current_limit(PFN_PHYS(max_low_pfn)); > - memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); > > /* Reserve the first 2MB */ > memblock_reserve(PHYS_OFFSET, 0x200000); > @@ -58,4 +57,7 @@ void __init memblock_init(void) > /* Reserve the kernel text/data/bss */ > memblock_reserve(__pa_symbol(&_text), > __pa_symbol(&_end) - __pa_symbol(&_text)); > + > + memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); > + memblock_set_node(0, PHYS_ADDR_MAX, &memblock.reserved, 0); So the reordering is for being able to override the newly added memblocks' nids to 0, and additionally doing the same for memblock.reserved is the actual fix. Looks okay. > } And I've tested the patch on the 2-way 3C5000L server, and it now correctly boots with deferred struct page init enabled. Thanks for providing such a quick fix! Tested-by: WANG Xuerui Reviewed-by: WANG Xuerui   # with nits addressed -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/