Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2935581rdb; Tue, 12 Sep 2023 17:50:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4MQW1HF9/epDEt77fCH2Bst1Qz5J5uZ2IBI7vQsIue+qEPUlM4kGj5Dr88SWe0MKxpo/l X-Received: by 2002:a05:6808:130c:b0:3a5:cc7d:3d66 with SMTP id y12-20020a056808130c00b003a5cc7d3d66mr1737915oiv.49.1694566222631; Tue, 12 Sep 2023 17:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694566222; cv=none; d=google.com; s=arc-20160816; b=DH9w4Lc9N7fZUPWHLUmVzXpbxslHqVArdcs4WPbPNiMxK6zgVIHHDSiy4jvYykTG0M JYfbb8NNkU0zRMGQKBYvZmOdIv2/RjqkLeTZ8c9BlmTg6oKxhk9HTVnoz4eOXhpfBVl0 00ZxOQWRQumYnXefRwZFVJtvGOsfnJIGSFyTsDMehnArRc0EWJH7kJ9R53wsBXUZvIrl sngx67Z3vYW/fFSCRkkP3S06Rg6Sx95L4BC5UI91Cyx5yTjq4fFi3/G86fmON/rROmKD 3psFYozanLdhRCWBNx4m1AvsETotkAGMgtmkyIikl/Aawi2aV6Ykev5m1bmfSDtmnEQH kKlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PZf+PsP7mWbGPWdtMadEGimg17b0Ilg/fZVSf0FfPtg=; fh=zWjNW843QIL0dwFweqoVDTfy4wHJu+nIxpS4FABgC08=; b=GfXG3Kd8rRUDIjt+ajmScROUVIpa2hZldTPgzQ05Tq8voDLghXSKI7+cKpw7OrdtFp fwcbwqCkHolS86wXVT6w/3hRNHjAaZXUCMOQalMIu+suGk/HVe8argATVxcob7C9ADzD wbCwa1NAyP8m3bHqUQghbKIH1rOgL7bM9vrLKe7ZoP9YFU5/ebtMcRgacLqmzt8qRPnt 41gLmI1dUGhqWxyU6mjZUwdaXVewuI77LaEhp0azrzXwxkiUkbFRE/kaF94mY+jS1f5W Dd8YluepJQjWvdjUghD4IxKs5w5drHCe0D8h4Px4/VIAncA/pER11XgRJvcD9ajGPqQx 9uGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cOhcaKTb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id g191-20020a636bc8000000b005636ef310adsi2154985pgc.597.2023.09.12.17.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 17:50:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cOhcaKTb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 37DE1804B2A8; Tue, 12 Sep 2023 17:50:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237971AbjIMAuE (ORCPT + 99 others); Tue, 12 Sep 2023 20:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbjIMAuD (ORCPT ); Tue, 12 Sep 2023 20:50:03 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA53C125 for ; Tue, 12 Sep 2023 17:49:59 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44AD9C433C9 for ; Wed, 13 Sep 2023 00:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694566199; bh=JW8eFTbL5Zu4+gvs9EK1EjcoupsFINoxnXaQNhFvMsI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cOhcaKTbX6hq4EYkMnux9p7Z1U7/j+nx+uvA0cfWJdqRCgPcSwxV72N97zM826Xnn jQP9b4Cm1+h8WNOHb3LmPnVDtSYskpUI+t5l0JQepAqWQOhIKdjbA74A3GbHk3HdBJ xSQJNspwYeIlLkiREkbf+b5+KKqTDopChwv+GNFWS1cZB8kSgDOSDBf6DSVhvOEOWS Ce6yUGQlaJTwx+5OWiPDIh4oy326mWfPQY/BJkidQX5lf37C4Xk9Yn8PefH1w/9DLt 2KIoZVSMDM6fZugzx+VVyKiT6pXiuy7t5Hyt+dFc2p8Luc7s1cq0CMuG7Z9i6uStJO lJW2tQNDCliTQ== Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2bb9a063f26so106713201fa.2 for ; Tue, 12 Sep 2023 17:49:59 -0700 (PDT) X-Gm-Message-State: AOJu0Yxb/5AFUjHg10KFMSBTvQnQV+gL4XQnDiJ9RX7aE/BUHfEz9aZs XEXZYCNdRhNSuYHHzbbjq6bgvEu2fTlmUNEjv10= X-Received: by 2002:a2e:8802:0:b0:2b5:80c9:1266 with SMTP id x2-20020a2e8802000000b002b580c91266mr1041477ljh.43.1694566197491; Tue, 12 Sep 2023 17:49:57 -0700 (PDT) MIME-Version: 1.0 References: <20230911092810.3108092-1-chenhuacai@loongson.cn> In-Reply-To: From: Huacai Chen Date: Wed, 13 Sep 2023 08:49:45 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] LoongArch: Set all reserved memblocks on Node#0 at initialization To: WANG Xuerui Cc: Huacai Chen , loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, WANG Xuerui Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 (groat.vger.email [0.0.0.0]); Tue, 12 Sep 2023 17:50:10 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 groat.vger.email On Wed, Sep 13, 2023 at 12:08=E2=80=AFAM WANG Xuerui wr= ote: > > 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. Late memblock_reserve() operates on subregions of memblock.memory regions. These reserved regions will be set to the correct node at the first iteration of memmap_init_reserved_pages(). Huacai > > 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/ > >