From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sam Ravnborg Date: Thu, 06 Dec 2018 18:08:26 +0000 Subject: Re: [PATCH v2 5/6] arch: simplify several early memory allocations Message-Id: <20181206180826.GB19166@ravnborg.org> List-Id: 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> In-Reply-To: <20181203164920.GB26700@rapoport-lnx> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Mike Rapoport Cc: Michal Hocko , linux-sh@vger.kernel.org, Benjamin Herrenschmidt , linux-mm@kvack.org, Rich Felker , Paul Mackerras , sparclinux@vger.kernel.org, Vincent Chen , Jonas Bonn , linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Michael Ellerman , Russell King , Mark Salter , Arnd Bergmann , Stefan Kristiansson , openrisc@lists.librecores.org, Greentime Hu , Stafford Horne , Guan Xuetao , linux-arm-kernel@lists.infradead.org, Michal Simek , linux-kernel@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" 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 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 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=unavailable 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 C488BC64EB1 for ; Thu, 6 Dec 2018 18:10:58 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4EB9120868 for ; Thu, 6 Dec 2018 18:10:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EB9120868 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 439kDc04gNzDrBh for ; Fri, 7 Dec 2018 05:10:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=ravnborg.org (client-ip=109.247.116.14; helo=asavdk3.altibox.net; envelope-from=sam@ravnborg.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Received: from asavdk3.altibox.net (asavdk3.altibox.net [109.247.116.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 439kB86qpyzDqB4 for ; Fri, 7 Dec 2018 05:08:48 +1100 (AEDT) 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 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 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Hocko , linux-sh@vger.kernel.org, linux-mm@kvack.org, Rich Felker , Paul Mackerras , sparclinux@vger.kernel.org, Vincent Chen , Jonas Bonn , linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Russell King , Mark Salter , Arnd Bergmann , Stefan Kristiansson , openrisc@lists.librecores.org, Greentime Hu , Stafford Horne , Guan Xuetao , linux-arm-kernel@lists.infradead.org, Michal Simek , linux-kernel@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 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=-4.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 82F1CC65BAF for ; Thu, 6 Dec 2018 18:11:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 56D0520868 for ; Thu, 6 Dec 2018 18:11:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SHzBYG54" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56D0520868 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-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TcnrQu5qOwvvi46qAyF594eAdZ+JT1I2uWDWP3Mn78M=; b=SHzBYG54Sa/8kD je1xmNKXVPSlAj5G2SIFY9M4oUFKw2mck6lNUBcyf+XPb40boHHTlH5VRpV1IkJhpPZdkm/oFXSpU SyqKAf0lHoYz4IoMoa6/UtWmh7b3B76XLDTnH4V0nijMlkBOo5bavqSvUkqU7YP3pH005/cMBzkl2 WzAwpTOxxk3ndQQI4B3dAWxsDmSrZbghhgOFQ+KW/8j03Zk0js73JTgrNfshn7OnJTr4aDxL3Ho01 bINyUV+4D7htqoMbtc1h5kXqNf68xYrZBf4G/TS/RHlM38gNo/b6EV0ern8Voej9arFDQOy9OmWpr OrttLHYVYTyaCrk921SA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUy77-0007k5-6Z; Thu, 06 Dec 2018 18:11:05 +0000 Received: from asavdk3.altibox.net ([109.247.116.14]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUy73-000664-O7 for linux-arm-kernel@lists.infradead.org; Thu, 06 Dec 2018 18:11:03 +0000 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 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-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181206_101101_963946_275519F6 X-CRM114-Status: GOOD ( 15.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Hocko , linux-sh@vger.kernel.org, Benjamin Herrenschmidt , linux-mm@kvack.org, Rich Felker , Paul Mackerras , sparclinux@vger.kernel.org, Vincent Chen , Jonas Bonn , linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Michael Ellerman , Russell King , Mark Salter , Arnd Bergmann , Stefan Kristiansson , openrisc@lists.librecores.org, Greentime Hu , Stafford Horne , Guan Xuetao , linux-arm-kernel@lists.infradead.org, Michal Simek , linux-kernel@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sam Ravnborg Date: Thu, 6 Dec 2018 19:08:26 +0100 Subject: [OpenRISC] [PATCH v2 5/6] arch: simplify several early memory allocations In-Reply-To: <20181203164920.GB26700@rapoport-lnx> 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> Message-ID: <20181206180826.GB19166@ravnborg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: openrisc@lists.librecores.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