Message ID | 20240118061853.2652295-1-yajun.deng@linux.dev |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-29732-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp154980dyb; Wed, 17 Jan 2024 22:19:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYCN0cKZumOdFRR+css2DmmdmOCR13eesuW94x+Dm9sWIKA1iYrnbHZ3IAHsWt8qAKVpqt X-Received: by 2002:a7b:c311:0:b0:40e:4252:e26 with SMTP id k17-20020a7bc311000000b0040e42520e26mr181784wmj.69.1705558770327; Wed, 17 Jan 2024 22:19:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705558770; cv=pass; d=google.com; s=arc-20160816; b=Tfgc1uJ0tN1/7gX4bOXicLfXveK6HxYLdhrkwLfLRy/eJ2DBHwPBQ04DYnjnO6jI9a 56Oe71Tcen0/bjVK7dpvU3zCgK8ldkKGJ6T/MzjqbuUwuzOdlly9+UucJ1bVfT3WtR/i NW2iMXjqZ9rfLtgNhOqfNZFZeKF9MYfr4zs9/6ew8W+dFPzWfWOjnTOHqeIXo5z2OTSQ 2ERtLyi9EVFgLt+mHOAIQ5eNBE4IqC0xRkeIO4zX4ddfPZvIZhJcIekuQ+kWJRhqH5NW ET28CbQCXwNhvtvgubx385C7Ewa3wyiytYVa535KhC8tUlGLftobGPhhgL42SMweIPq1 ZxwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=sH3eJ1PeLEzp5iMX2ShmJd90S2HOzxuMkVgsHD8St1Y=; fh=QZU3guN9hBCNbG3XWCsoVTJE3Km/GRJW/frPYUuNAVA=; b=xw2e8qcob3it7BofhxKAVo78vCUEvbaJ1+Spzc611VXnRVMA9UsqQtMEvK8cFzTkB2 Bw9SSmdQrYEyEiDW9QN3KU9dMY/WgLV1TCs26FbB/WzZMC4nmrAKf3adIUd4uxe+OVL2 OCFjDSOkgpZb1S0gnnQyB+TzS4tVlmBglEwhay49QABcY9gDmqIG5ZSzXaQmfFHkzSbh fm/5+wOWN69ixOZJb68BId8qiPlHhpM/9xx/NwHeUXuytifPrEqsD7bKhn9Br1fj2GQp zo6rWRifbEI9BvHljyCcLSWNJRqzpBBT2Z4HtWcT2KI7C0SdT6Yh4mRwjENmwqXDh1Bm 9j6Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=q2SumlNy; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-29732-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29732-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o26-20020a17090611da00b00a2dd1ae21bbsi3454250eja.631.2024.01.17.22.19.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 22:19:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29732-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=q2SumlNy; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-29732-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29732-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id EEAC91F230A6 for <ouuuleilei@gmail.com>; Thu, 18 Jan 2024 06:19:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72BCC947B; Thu, 18 Jan 2024 06:19:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="q2SumlNy" Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) (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 CD6BB79E4 for <linux-kernel@vger.kernel.org>; Thu, 18 Jan 2024 06:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705558754; cv=none; b=BtLVVp1UEZaj4sYXxhkp+gmL1cgmM7C+PwO/aj5/JPp6YqJ/lKqyqw7koi19lPqrgXYuvGOh79bTRkHwJSaP3+IjVZ0Z+HJziJEHAbB5PPzuFQgjsC7d95wdE7L0BccC3VsAL3j1gQeH2BakyUfTVrMe86bSfjGwnh0uQI8xKlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705558754; c=relaxed/simple; bh=OzKnacBlOGRsazVvabreopds5Qg+gZxPBfXopYaD548=; h=X-Report-Abuse:DKIM-Signature:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Transfer-Encoding:X-Migadu-Flow; b=DOVCt1pGVpmkNzDeki2cBgr5hI5BkT/pIrIh9aRn6+zrTwNQK+UIE26Xho3PwDDoE6K+5vpeQmO95Hh6ZbadKiU2MtFOefiUQGWYJYD7ul1Iy8B+zpOEFS2umENONd+rpBlu7XQKVnrx3eIKl9Re4ykaRCOiJJpPRGFwoUoArjA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=q2SumlNy; arc=none smtp.client-ip=95.215.58.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705558750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=sH3eJ1PeLEzp5iMX2ShmJd90S2HOzxuMkVgsHD8St1Y=; b=q2SumlNy5FfAKZtKClDn1OZKQxeQKmH5Ko8ONI9YBImUJweeTR0HEQzbzogjPn7TpyvV+/ 8ZS/gh2bUD/06yC8yrpxg0VMAs5WzeXGxNeSj0pCv/MQE6LWrhKsYgZJV2Dywlsff9GjUN lZXP7e+Ow4a2bjv8x9ynsVWigz+rWj8= From: Yajun Deng <yajun.deng@linux.dev> To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yajun Deng <yajun.deng@linux.dev> Subject: [PATCH] memblock: fix crash when reserved memory is not added to memory Date: Thu, 18 Jan 2024 14:18:53 +0800 Message-Id: <20240118061853.2652295-1-yajun.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788407993016315076 X-GMAIL-MSGID: 1788407993016315076 |
Series |
memblock: fix crash when reserved memory is not added to memory
|
|
Commit Message
Yajun Deng
Jan. 18, 2024, 6:18 a.m. UTC
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 <yajun.deng@linux.dev>
---
mm/memblock.c | 3 +++
1 file changed, 3 insertions(+)
Comments
(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 <yajun.deng@linux.dev> > --- > 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 >
On Thu, Jan 18, 2024 at 08:42:08AM +0200, Mike Rapoport wrote: > (adding Huang Pei to verify this fixes the crash on loongarch) > It fixed 61167ad5fecd on MIPS/loongson64, tested on 3b1500 with only this one; My loongarch64 machine is not available now, I can not test it, sorry. It is already applied a arch-specific workaround in v6.5+ > 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 <yajun.deng@linux.dev> > > --- > > 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.
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); } }