Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6772256imu; Wed, 30 Jan 2019 22:44:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN6dD7UxbMczM2bn8M302JB3DupMxNA3HsnUhsGREiH0fgR679Kolsn8wFdHYoQu9U7+7nrY X-Received: by 2002:a63:70c:: with SMTP id 12mr29512666pgh.352.1548917081117; Wed, 30 Jan 2019 22:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548917081; cv=none; d=google.com; s=arc-20160816; b=L4X7VTLcs5gW8Vn/vvGHxD6UvdL6CuR1FIOlkOdjkj8lzD4E1JSvrTvXhDQ4hVqiFN sIC6Vol63GOYkzRAidmvSRTXbpBQGzHbNvgq3NjbEWcsHbuv/oEz/5bd3piDjFsWPOT3 rOmpIgSuIBhzamwU88wyfMy/ta6lBXjBewZrqiXDFN4H8Kl99rykoyb0eDaohyHHKYG8 a0oHOqOFXs2FMs4oBvjKq8qn00jDmRFxG70tW/Z4Dk6ZGyO7z0bq0o/Ofx0YklCmNF6W RT94RuCbB8eCapRhdBiBJQmNWYHTM+eyjo44Z7BQpNNe4UxArLZmCrqY1alrhvnctLWY RJPw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=cOJiyexC4RhzV3nLmw1xVDcK744oiB5d7rgry5+gXoM=; b=Ddh+BZJdoTW5FfDMqWPgXyrpdjijgqdJJOanyGlFIsy8zb4bN6ntcDj6xtiQ7/LKdA +in3baiDdZ5rsI+owhWm4kSKoSHtFN1VmaIttBpzFRKmPeGSU6WQGgweQdJUpfFEi9Su 5+tuiZZXUsedc2uvmhXJ5EIsPNATuE6e0ioziWN+RI8qV+8s0GAFBVwbVkyq5pfyeu0R iD3VVBKOmD2AmAD8eXeTEsZS+7TcFoU/DebddRRtp8zspxkJoYXGiQ0BC/knlcxEFQHJ DWYwAABNv9yaqZjIyR4Iv0aQrUZPsnIJ8yjppovNW/UXtFw8/P0qfKbTTXZFVJQhYIGs mf0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=JMZ+vLjQ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l185si2827696pgd.253.2019.01.30.22.44.25; Wed, 30 Jan 2019 22:44:41 -0800 (PST) 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=@c-s.fr header.s=mail header.b=JMZ+vLjQ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729895AbfAaGoV (ORCPT + 99 others); Thu, 31 Jan 2019 01:44:21 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:54595 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727623AbfAaGoU (ORCPT ); Thu, 31 Jan 2019 01:44:20 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43qrLS1Crsz9v0QW; Thu, 31 Jan 2019 07:44:16 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=JMZ+vLjQ; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id GE1BryDiLvL6; Thu, 31 Jan 2019 07:44:16 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 43qrLR6vTNz9v0QV; Thu, 31 Jan 2019 07:44:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1548917056; bh=cOJiyexC4RhzV3nLmw1xVDcK744oiB5d7rgry5+gXoM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=JMZ+vLjQ76kryo0d4/3v/CDV0aIlsMdhbsiuclC0eKE0XnqOavCGYfranMcArXvgZ dV45OC8eZ/80eWqgb+hc9/o9z1Khd3UH2cqOEZvxMsXqASyrcPNuh48OKAIU0LEGhU t5oaxwZcm23sWI0poHri1Vgox0AoX9rAx2aliPUM= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BA4FF8B78E; Thu, 31 Jan 2019 07:44:16 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ETfFXp9TLqKY; Thu, 31 Jan 2019 07:44:16 +0100 (CET) Received: from PO15451 (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8915D8B74C; Thu, 31 Jan 2019 07:44:14 +0100 (CET) Subject: Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*() To: Mike Rapoport Cc: linux-mm@kvack.org, Rich Felker , linux-ia64@vger.kernel.org, devicetree@vger.kernel.org, Catalin Marinas , Heiko Carstens , x86@kernel.org, linux-mips@vger.kernel.org, Max Filippov , Guo Ren , sparclinux@vger.kernel.org, Christoph Hellwig , linux-s390@vger.kernel.org, linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Richard Weinberger , linux-sh@vger.kernel.org, Russell King , kasan-dev@googlegroups.com, Geert Uytterhoeven , Mark Salter , Dennis Zhou , Matt Turner , linux-snps-arc@lists.infradead.org, uclinux-h8-devel@lists.sourceforge.jp, Petr Mladek , linux-xtensa@linux-xtensa.org, linux-alpha@vger.kernel.org, linux-um@lists.infradead.org, linux-m68k@lists.linux-m68k.org, Rob Herring , Greentime Hu , xen-devel@lists.xenproject.org, Stafford Horne , Guan Xuetao , linux-arm-kernel@lists.infradead.org, Michal Simek , Tony Luck , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Burton , Vineet Gupta , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" , openrisc@lists.librecores.org, Stephen Rothwell References: <1548057848-15136-1-git-send-email-rppt@linux.ibm.com> <1548057848-15136-20-git-send-email-rppt@linux.ibm.com> <20190131064139.GB28876@rapoport-lnx> From: Christophe Leroy Message-ID: <8838f7ab-998b-6d78-02a8-a53f8a3619d9@c-s.fr> Date: Thu, 31 Jan 2019 07:44:14 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190131064139.GB28876@rapoport-lnx> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 31/01/2019 à 07:41, Mike Rapoport a écrit : > On Thu, Jan 31, 2019 at 07:07:46AM +0100, Christophe Leroy wrote: >> >> >> Le 21/01/2019 à 09:04, Mike Rapoport a écrit : >>> Add check for the return value of memblock_alloc*() functions and call >>> panic() in case of error. >>> The panic message repeats the one used by panicing memblock allocators with >>> adjustment of parameters to include only relevant ones. >>> >>> The replacement was mostly automated with semantic patches like the one >>> below with manual massaging of format strings. >>> >>> @@ >>> expression ptr, size, align; >>> @@ >>> ptr = memblock_alloc(size, align); >>> + if (!ptr) >>> + panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__, >>> size, align); >>> >>> Signed-off-by: Mike Rapoport >>> Reviewed-by: Guo Ren # c-sky >>> Acked-by: Paul Burton # MIPS >>> Acked-by: Heiko Carstens # s390 >>> Reviewed-by: Juergen Gross # Xen >>> --- >> >> [...] >> >>> diff --git a/mm/sparse.c b/mm/sparse.c >>> index 7ea5dc6..ad94242 100644 >>> --- a/mm/sparse.c >>> +++ b/mm/sparse.c >> >> [...] >> >>> @@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid) >>> memblock_alloc_try_nid_raw(size, PAGE_SIZE, >>> __pa(MAX_DMA_ADDRESS), >>> MEMBLOCK_ALLOC_ACCESSIBLE, nid); >>> + if (!sparsemap_buf) >>> + panic("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n", >>> + __func__, size, PAGE_SIZE, nid, __pa(MAX_DMA_ADDRESS)); >>> + >> >> memblock_alloc_try_nid_raw() does not panic (help explicitly says: Does not >> zero allocated memory, does not panic if request cannot be satisfied.). > > "Does not panic" does not mean it always succeeds. I agree, but at least here you are changing the behaviour by making it panic explicitly. Are we sure there are not cases where the system could just continue functionning ? Maybe a WARN_ON() would be enough there ? Christophe > >> Stephen Rothwell reports a boot failure due to this change. > > Please see my reply on that thread. > >> Christophe >> >>> sparsemap_buf_end = sparsemap_buf + size; >>> } >>> >> >