From patchwork Mon Jan 21 08:03:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 10772905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AF071390 for ; Mon, 21 Jan 2019 08:05:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C10728524 for ; Mon, 21 Jan 2019 08:05:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F0CD29B02; Mon, 21 Jan 2019 08:05:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5D0E28524 for ; Mon, 21 Jan 2019 08:05:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAA9B8E001B; Mon, 21 Jan 2019 03:05:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D5A3A8E0018; Mon, 21 Jan 2019 03:05:09 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C229D8E001B; Mon, 21 Jan 2019 03:05:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 7E06B8E0018 for ; Mon, 21 Jan 2019 03:05:09 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id y2so12659015plr.8 for ; Mon, 21 Jan 2019 00:05:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=hGKBLmpR6kMaew84GxylKTWV5fJZlqKJ86XMoCPo28w=; b=FyQbmecuMsWWOtH2TquwF+KafR05nSnFxEgPizsTXHLQDjzIzvWUrmpktqsGkWASN9 DK0MggtZRIA48uig5I3j972xO53vKdVZLo1OSjjdrYX0hrxz51n6+PZldLeSvI2LYTJL ARZmiUdPSoJVPzwCNh59LkBqVdFR6jmTLKfL8xuuKf+CllqqArk5Zz7aj/re25m9MY1h edDcOB86SVXWPDFko7EHkCr4+GtD5YsABCCV+lb+WYQ3aQaa7oWt5kT+6zhIibzn7Oiz OQ5rARJFYwtoN51xYt8JH2iEiM7DTSC+63MdqNfHw3EEceRzrVjOEBJe5D+Ywc4dCnoG F9pg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AJcUukcFnlOLhC/FeTerK1RgwdNvhJyMiyfzGkQXKhnL4Vv9ax/nnsby c4iSSNlCkXOazLB1NLLBvOE3XvgzgAy6lao2Wwt5oC8/WVuMSBapqVGOr46aJdz5i6IDmMTNwk+ IorFv7BVB/K0Kkip17DKYga0EJxQvDK0k1swW4XOiZe56XwWYCO4oQEtq9T6ICQ3YLQ== X-Received: by 2002:a62:444b:: with SMTP id r72mr29309095pfa.184.1548057909182; Mon, 21 Jan 2019 00:05:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN7q/gkZDabJAaRgwfov6M6StMYhCe0DjKuqjt9N5t9tl32ETwpKKZFSMpBVmL6qtvcbCS8w X-Received: by 2002:a62:444b:: with SMTP id r72mr29309061pfa.184.1548057908522; Mon, 21 Jan 2019 00:05:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057908; cv=none; d=google.com; s=arc-20160816; b=KGlfTRVJCcQWY4uYSID3o9vtUCO77o5xSBxn4g/XJz0Mt0//fiAycszURWBHl+TerF tEN+7lKpvQmrfJbb54z2iALKUu6bYxi3S3oghHkgcEhouZp4jzWVXsE6YEMWPe0JT+Lx RXmhINxoreac2hjXhBMzWs9VHd0WIkl0+3eAiITKwyUZ/1vxDXrbAzioZJ3jVEA3iBJ1 JFrtFoAOmnbqUOGi0KhKMSh5TyTLKRWalkynttGJOgTCZfg8MVYTRYmof1O5ZGiZgJsk GkhKCnlY2zcXpz3XLXgo8dJyF+MlJJsSx2pzDv2SYZmk+X9maKuK+lUe7BDQEbnajUPM WuOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from; bh=hGKBLmpR6kMaew84GxylKTWV5fJZlqKJ86XMoCPo28w=; b=YlMcDsZYusjXu/VuWI0rvE9/26P/tYOGRtsQOmVsHr3acUCv87EL9yurRcTdAPk1oS 1MooVLcGSLwk5lNLnNjtlPGeop1V00ucHeygwV0L11qyFfhuqW0iXhdlI80KzJFl3ZID 9iyVpLwE1M72M+Wx3fd32DbjPfC7qraRzGE6PjiaZqJhOT7YcjutZPt7YdeQTime9vEd ASGMGUq3FqZCdE5XWikvVpZCZeJtAns7skGzbopH1h3oOqLukiaAnULJ8mVzOxWJ/8Tm +j3konLLtdvTvQH7VUxuvVIRqM/V15L0M84Bh0390UauO6lNKqvElv693uvoGVw8sjb0 IDHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id r14si10976223pfh.229.2019.01.21.00.05.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:05:08 -0800 (PST) Received-SPF: pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0L84Emo125718 for ; Mon, 21 Jan 2019 03:05:08 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2q58rjumek-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 21 Jan 2019 03:05:07 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Jan 2019 08:05:04 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 21 Jan 2019 08:04:52 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0L84pFF61079554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 21 Jan 2019 08:04:51 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4655B5205A; Mon, 21 Jan 2019 08:04:51 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.207.125]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 6DB6952051; Mon, 21 Jan 2019 08:04:46 +0000 (GMT) Received: by rapoport-lnx (sSMTP sendmail emulation); Mon, 21 Jan 2019 10:04:44 +0200 From: Mike Rapoport To: linux-mm@kvack.org Cc: Andrew Morton , Catalin Marinas , Christoph Hellwig , "David S. Miller" , Dennis Zhou , Geert Uytterhoeven , Greentime Hu , Greg Kroah-Hartman , Guan Xuetao , Guo Ren , Heiko Carstens , Mark Salter , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Paul Burton , Petr Mladek , Rich Felker , Richard Weinberger , Rob Herring , Russell King , Stafford Horne , Tony Luck , Vineet Gupta , Yoshinori Sato , devicetree@vger.kernel.org, kasan-dev@googlegroups.com, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-um@lists.infradead.org, linux-usb@vger.kernel.org, linux-xtensa@linux-xtensa.org, linuxppc-dev@lists.ozlabs.org, openrisc@lists.librecores.org, sparclinux@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, x86@kernel.org, xen-devel@lists.xenproject.org, Mike Rapoport Subject: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic Date: Mon, 21 Jan 2019 10:03:53 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548057848-15136-1-git-send-email-rppt@linux.ibm.com> References: <1548057848-15136-1-git-send-email-rppt@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19012108-0028-0000-0000-0000033BE171 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19012108-0029-0000-0000-000023F91583 Message-Id: <1548057848-15136-7-git-send-email-rppt@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-21_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=927 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901210066 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Mike Rapoport Acked-by: Michael Ellerman (powerpc) --- 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 ae34e3a..2c61ea4 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 270cefb..8f2bbe1 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 f019aee..8aabb1b 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1393,7 +1393,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); } /**