Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5657541img; Wed, 27 Mar 2019 12:35:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyGXsQvMlT8pLg0Yg4IQrHfDIymanrV+fcsW8V+7JsbvXj1Nhihx/TocGC+G57rWtBFd7R X-Received: by 2002:a65:6548:: with SMTP id a8mr7654997pgw.442.1553715332094; Wed, 27 Mar 2019 12:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553715332; cv=none; d=google.com; s=arc-20160816; b=iJBVQYaXFIEVUR7BAlJ9vlk/g+rcobbxpETTjRgiEtWzxIg8w/6syM47aYeWMkI/Te wdurklgvA9LAZiPHYHCpLlsOY9yvSuujXV3D6DrJh1ceabdaQW/7rOs4XJPxKoP3W7c1 1A/qlt62/mCQV9PEaMpwbnvTMLty9S9SpHaPDGkC/+e5nZAXWzonj8GAFEjmMr8aPwLl 43PWG/h45qMVWV/U3ts1xGn4ORfO79B8Z0BJDU4vieb0KfJt2tfe2vskRuvEsXHn5LfP ty2s/ibP3tS7OPoGiQTxC1Om/530MrK+/ZKVFAMB8epv11AJTG4G+K8co3xPpM8kWiMl EX7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dWYvGUbTzzKvOdF7nmXjedlOhm9Y8mmuknLbtd8dgVw=; b=HPws6Hp+h6q9BYmP+5eC8tiuQzBNFuZd0dIzwJa5QhjyCQPzAUS1QQrvWApJHKJ82l AEcbo8ca9+I0HT1cg28uTG2KP/iwLpEvrTcaAwtNvpp1AZOyUSQZTDFPuNELDQGQJuOk 6jZcYqE6080jJ5V2buVCfwfM77jCtWW3KvfCaZf5pNy9uepzrlzeItlNkwuNmSeqClG6 iDkbLTO1GvT/BWYa9IUJ892o+Bk6aM8X8hJ0eoBiDGTxCL3Qrj9+zS9BkFlc5kHEtd2y RJnnCAu7efiydvwfW202GUosoRZbQHNc6kaRB54s8ItYHjyckHravwhRdizp6keO7/bC fp7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bn9CB8uQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23si19196107pgc.220.2019.03.27.12.35.17; Wed, 27 Mar 2019 12:35:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bn9CB8uQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730636AbfC0SC2 (ORCPT + 99 others); Wed, 27 Mar 2019 14:02:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:42240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730464AbfC0SC0 (ORCPT ); Wed, 27 Mar 2019 14:02:26 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB1A52146F; Wed, 27 Mar 2019 18:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709745; bh=hOyhfl2oQp9beaVEdiXpd/rNdZl7HVN7AZx/JZPGlhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bn9CB8uQTyuorEN8f+aOAe1Szm8Ck4wwzvHTCusv1mSK24/7AXgrPpNDaoswKU+8G ygZ4WKaNUbXK/ZwNXY90G2GBJvSSIJ45DI1/iiOBgqyv7rUzwHb5bvBNrfGaHQ3+Cl T7m7TJpkoxAOW4KsvrK0r19PzW28WD7bqkqossIM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mike Rapoport , Catalin Marinas , Christophe Leroy , Christoph Hellwig , "David S. Miller" , Dennis Zhou , Geert Uytterhoeven , Greentime Hu , Greg Kroah-Hartman , Guan Xuetao , Guo Ren , Guo Ren , Heiko Carstens , Juergen Gross , Mark Salter , Matt Turner , Max Filippov , Michal Simek , Paul Burton , Petr Mladek , Richard Weinberger , Rich Felker , Rob Herring , Rob Herring , Russell King , Stafford Horne , Tony Luck , Vineet Gupta , Yoshinori Sato , Andrew Morton , Linus Torvalds , Sasha Levin , linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Subject: [PATCH AUTOSEL 5.0 015/262] memblock: memblock_phys_alloc_try_nid(): don't panic Date: Wed, 27 Mar 2019 13:57:50 -0400 Message-Id: <20190327180158.10245-15-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Rapoport [ Upstream commit 337555744e6e39dd1d87698c6084dd88a606d60a ] The memblock_phys_alloc_try_nid() function tries to allocate memory from the requested node and then falls back to allocation from any node in the system. The memblock_alloc_base() fallback used by this function panics if the allocation fails. Replace the memblock_alloc_base() fallback with the direct call to memblock_alloc_range_nid() and update the memblock_phys_alloc_try_nid() callers to check the returned value and panic in case of error. Link: http://lkml.kernel.org/r/1548057848-15136-7-git-send-email-rppt@linux.ibm.com Signed-off-by: Mike Rapoport Acked-by: Michael Ellerman [powerpc] Cc: Catalin Marinas Cc: Christophe Leroy Cc: Christoph Hellwig Cc: "David S. Miller" Cc: Dennis Zhou Cc: Geert Uytterhoeven Cc: Greentime Hu Cc: Greg Kroah-Hartman Cc: Guan Xuetao Cc: Guo Ren Cc: Guo Ren [c-sky] Cc: Heiko Carstens Cc: Juergen Gross [Xen] Cc: Mark Salter Cc: Matt Turner Cc: Max Filippov Cc: Michal Simek Cc: Paul Burton Cc: Petr Mladek Cc: Richard Weinberger Cc: Rich Felker Cc: Rob Herring Cc: Rob Herring Cc: Russell King Cc: Stafford Horne Cc: Tony Luck Cc: Vineet Gupta Cc: Yoshinori Sato Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- arch/arm64/mm/numa.c | 4 ++++ arch/powerpc/mm/numa.c | 4 ++++ mm/memblock.c | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c index ae34e3a1cef1..2c61ea4e290b 100644 --- a/arch/arm64/mm/numa.c +++ b/arch/arm64/mm/numa.c @@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) pr_info("Initmem setup node %d []\n", nid); nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); + if (!nd_pa) + panic("Cannot allocate %zu bytes for node %d data\n", + nd_size, nid); + nd = __va(nd_pa); /* report and initialize */ diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 87f0dd004295..8ec2ed30d44c 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -788,6 +788,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) int tnid; nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); + if (!nd_pa) + panic("Cannot allocate %zu bytes for node %d data\n", + nd_size, nid); + nd = __va(nd_pa); /* report and initialize */ diff --git a/mm/memblock.c b/mm/memblock.c index ea31045ba704..d5923df56acc 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1342,7 +1342,9 @@ phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t ali if (res) return res; - return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); + return memblock_alloc_range_nid(size, align, 0, + MEMBLOCK_ALLOC_ACCESSIBLE, + NUMA_NO_NODE, MEMBLOCK_NONE); } /** -- 2.19.1