Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp163681rdb; Wed, 17 Jan 2024 22:42:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IECSc0wG+l69+PI4gobG0SUhdARzKarRZvfd/ScSGsYwNFbY+E4B2kKz0XalCrKSBd10sFf X-Received: by 2002:a17:90a:62c8:b0:28e:7b73:806a with SMTP id k8-20020a17090a62c800b0028e7b73806amr347953pjs.64.1705560150367; Wed, 17 Jan 2024 22:42:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705560150; cv=pass; d=google.com; s=arc-20160816; b=Q18awupKJQ2xv3hngMndj0erJiI1r/Ly9+Cd0kMeUS4KN5xthWpPGmq1M5KUaKMUpT s62/azVmqY/FlLfJCBnEWO/EETguyCf+862bny5UwlLrru2WeIfcRY7Xipnd+yjFuQ8A folWdmJGMVMc3UhjToEaD3X4HtmbT8WbHBk1vQfuuCNi5XfN0hRKGK388/HwRHcMUzZR qsafzdB2WLfCMObVS4GnstoR5moMJAlQBYPRnauujtFW/9SbBrzSluOMPqIQx1ZV6dTG gL512ALrkqRpr5126GKj8c8LGrAep1oxtVknNqYFGs9rY9oMB7MiDxEQ47HIEgqb111E QgSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=57/OCQn/jtJ0d2EaAgtp8HVZB8wQOkm9HshFkxuQTAw=; fh=5BzQq0r11N7jCKvIHp+s+khwVIp//Jpr2/fEyU/rlz8=; b=jlKaZAfDUmQMNJCsWNfGeDAbONV++Mb61gcgeYTd25E9l0SpWmp5hFOJ8h7ZcVdbSS bO4Hfxuzi1xwVgDqqBedU/g3VaCpdZ3BACqhoMwqlmMBeWaWXVhC7Fe2UxcsRcAFzYYp biJ+T1Z5ajoskvbpX1UKJmI9ilhSuooNdU8c7Aatihf1NO22x66dZpONIgqqW2olQp5P jZPuhYlx/k9UhzblwsxjBe0VLoH3unM2N/y8SjEo3Wwn9F8Uweel034PLAK0rVIYl9Jy BLtFglDLUiGe+wa3vDD75TWaulXarlZWDRYhXcf5mPn5QYZi/L3hCe5bu63QZDqsKEVG 0f1w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OFiQrywG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m14-20020a170902db0e00b001d703a08c54si852618plx.467.2024.01.17.22.42.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 22:42:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OFiQrywG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EFE71282C7D for ; Thu, 18 Jan 2024 06:42:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 84AD011CB0; Thu, 18 Jan 2024 06:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OFiQrywG" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6FE911C80 for ; Thu, 18 Jan 2024 06:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705560143; cv=none; b=OkrGAoWT4GTURkvjrfXioIofHLhjby01gI/I6VGfBg2OUVox61VyDFtkZG3+7juQRBihVHqtXi2FkdUIvgJKcS+pCw6ba6gCociNoqDOj6OTGux8oxO+gXh2TJI9lfILuxkam69O2tLyipUe8h3knjf27kofrL2w7zsD8GcnKwo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705560143; c=relaxed/simple; bh=7irHwcUOlLLvJ2czZrHOJqq3RhjBpa00ankX30HggNE=; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=fnAJPHwIQdYfcIrfnHeHnmu2b/efSGTe3vIQ6rXfpQOSwBWIeAm9+8gmMM7sVSS0UiDO6mfdVy1IwPWpS2ClYVekgHCsTcwhakScYA9kyDHl6TA8O6MWYYtLFXtANnhKV2mFz2W44yhab3CUCclOViHol2UOhi9NqNQgwIkzO1Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OFiQrywG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98146C43390; Thu, 18 Jan 2024 06:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705560143; bh=7irHwcUOlLLvJ2czZrHOJqq3RhjBpa00ankX30HggNE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OFiQrywGk1L0FEqB3zgPffyixtDSEM16hHyBN8bHBAmzU71ff7sCJqTwVgsvAKDlt eZs379UnaSF2wDZaqEyGTl2qmoIrPmW0f+Rby1pW6+FpJ2kqCKuHMnwGQbhPzggAo5 xQ3Znn82qCXhFiC0/Gg8vV4OsxLpDb+dI6XPbrXFTjuaKJlgnNl+egrHUGurPIAJIe yXY2ssLC4m6AVNrTjzb0ZbI1nfHXgv7O4d2aPD4nqJzhQTKwP7haUVNemqyY2NNmQE 8+LVv4bDTf9geyLSUyUqnIDYZjYmOF2TB8jnicLhF7Mw7zpuVWeKCSpiPIQdbjWxx7 C3GRh9wInDWtA== Date: Thu, 18 Jan 2024 08:42:08 +0200 From: Mike Rapoport To: Yajun Deng , Huang Pei Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] memblock: fix crash when reserved memory is not added to memory Message-ID: References: <20240118061853.2652295-1-yajun.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240118061853.2652295-1-yajun.deng@linux.dev> (adding Huang Pei to verify this fixes the crash on loongarch) On Thu, Jan 18, 2024 at 02:18:53PM +0800, Yajun Deng wrote: > After commit 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()"), > we set nid on all reserved pages based on memory region, but some reserved > memory may not be added to memory on certain architectures. The nid is > invalid. > > Add the nid check, make sure the nid is valid by early_pfn_to_nid(). > > Fixes: 61167ad5fecd ("mm: pass nid to reserve_bootmem_region()") > Signed-off-by: Yajun Deng > --- > mm/memblock.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/memblock.c b/mm/memblock.c > index abd92869874d..4dcb2ee35eca 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2176,6 +2176,9 @@ static void __init memmap_init_reserved_pages(void) > start = region->base; > end = start + region->size; > > + if (nid == NUMA_NO_NODE || nid >= MAX_NUMNODES) > + nid = early_pfn_to_nid(PFN_DOWN(start)); > + > reserve_bootmem_region(start, end, nid); > } > } > -- > 2.25.1 > -- Sincerely yours, Mike.