From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68418C64EB1 for ; Thu, 6 Dec 2018 18:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B51220850 for ; Thu, 6 Dec 2018 18:08:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B51220850 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726078AbeLFSIr (ORCPT ); Thu, 6 Dec 2018 13:08:47 -0500 Received: from asavdk3.altibox.net ([109.247.116.14]:36033 "EHLO asavdk3.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbeLFSIr (ORCPT ); Thu, 6 Dec 2018 13:08:47 -0500 Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by asavdk3.altibox.net (Postfix) with ESMTPS id 3A8DD2007D; Thu, 6 Dec 2018 19:08:28 +0100 (CET) Date: Thu, 6 Dec 2018 19:08:26 +0100 From: Sam Ravnborg To: Mike Rapoport Cc: Andrew Morton , Arnd Bergmann , Benjamin Herrenschmidt , "David S. Miller" , Guan Xuetao , Greentime Hu , Jonas Bonn , Michael Ellerman , Michal Hocko , Michal Simek , Mark Salter , Paul Mackerras , Rich Felker , Russell King , Stefan Kristiansson , Stafford Horne , Vincent Chen , Yoshinori Sato , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, openrisc@lists.librecores.org, sparclinux@vger.kernel.org Subject: Re: [PATCH v2 5/6] arch: simplify several early memory allocations Message-ID: <20181206180826.GB19166@ravnborg.org> References: <1543852035-26634-1-git-send-email-rppt@linux.ibm.com> <1543852035-26634-6-git-send-email-rppt@linux.ibm.com> <20181203162908.GB4244@ravnborg.org> <20181203164920.GB26700@rapoport-lnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181203164920.GB26700@rapoport-lnx> User-Agent: Mutt/1.5.21 (2010-09-15) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=dqr19Wo4 c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=kj9zAlcOel0A:10 a=5FtgESxhPiTmXxFRN-kA:9 a=CjuIK1q_8ugA:10 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 03, 2018 at 06:49:21PM +0200, Mike Rapoport wrote: > On Mon, Dec 03, 2018 at 05:29:08PM +0100, Sam Ravnborg wrote: > > Hi Mike. > > > > > index c37955d..2a17665 100644 > > > --- a/arch/sparc/kernel/prom_64.c > > > +++ b/arch/sparc/kernel/prom_64.c > > > @@ -34,16 +34,13 @@ > > > > > > void * __init prom_early_alloc(unsigned long size) > > > { > > > - unsigned long paddr = memblock_phys_alloc(size, SMP_CACHE_BYTES); > > > - void *ret; > > > + void *ret = memblock_alloc(size, SMP_CACHE_BYTES); > > > > > > - if (!paddr) { > > > + if (!ret) { > > > prom_printf("prom_early_alloc(%lu) failed\n", size); > > > prom_halt(); > > > } > > > > > > - ret = __va(paddr); > > > - memset(ret, 0, size); > > > prom_early_allocated += size; > > > > > > return ret; > > > > memblock_alloc() calls memblock_alloc_try_nid(). > > And if allocation fails then memblock_alloc_try_nid() calls panic(). > > So will we ever hit the prom_halt() code? > > memblock_phys_alloc_try_nid() also calls panic if an allocation fails. So > in either case we never reach prom_halt() code. So we have code here we never reach - not nice. If the idea is to avoid relying on the panic inside memblock_alloc() then maybe replace it with a variant that do not call panic? To make it clear what happens. Sam