From: Sam Ravnborg <sam@ravnborg•org>
To: Mike Rapoport <rppt@linux•ibm.com>
Cc: Michal Hocko <mhocko@suse•com>,
linux-sh@vger•kernel.org, linux-mm@kvack•org,
Rich Felker <dalias@libc•org>, Paul Mackerras <paulus@samba•org>,
sparclinux@vger•kernel.org, Vincent Chen <deanbo422@gmail•com>,
Jonas Bonn <jonas@southpole•se>,
linux-c6x-dev@linux-c6x•org,
Yoshinori Sato <ysato@users•sourceforge.jp>,
Russell King <linux@armlinux•org.uk>,
Mark Salter <msalter@redhat•com>, Arnd Bergmann <arnd@arndb•de>,
Stefan Kristiansson <stefan.kristiansson@saunalahti•fi>,
openrisc@lists•librecores.org, Greentime Hu <green.hu@gmail•com>,
Stafford Horne <shorne@gmail•com>, Guan Xuetao <gxt@pku•edu.cn>,
linux-arm-kernel@lists•infradead.org,
Michal Simek <monstr@monstr•eu>,
linux-kernel@vger•kernel.org,
Andrew Morton <akpm@linux-foundation•org>,
linuxppc-dev@lists•ozlabs.org,
"David S. Miller" <davem@davemloft•net>
Subject: Re: [PATCH v2 5/6] arch: simplify several early memory allocations
Date: Thu, 6 Dec 2018 19:08:26 +0100 [thread overview]
Message-ID: <20181206180826.GB19166@ravnborg.org> (raw)
In-Reply-To: <20181203164920.GB26700@rapoport-lnx>
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
next prev parent reply other threads:[~2018-12-06 18:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-03 15:47 [PATCH v2 0/6] memblock: simplify several early memory allocation Mike Rapoport
2018-12-03 15:47 ` [PATCH v2 1/6] powerpc: prefer memblock APIs returning virtual address Mike Rapoport
2018-12-04 9:59 ` Michael Ellerman
2018-12-04 17:13 ` Mike Rapoport
2018-12-05 12:37 ` Michael Ellerman
2018-12-05 21:22 ` Mike Rapoport
2018-12-03 15:47 ` [PATCH v2 2/6] microblaze: prefer memblock API " Mike Rapoport
2018-12-05 15:29 ` Michal Simek
2018-12-06 7:31 ` Mike Rapoport
2018-12-03 15:47 ` [PATCH v2 3/6] sh: prefer memblock APIs " Mike Rapoport
2018-12-03 16:10 ` Sam Ravnborg
2018-12-03 16:28 ` Mike Rapoport
2018-12-03 15:47 ` [PATCH v2 4/6] openrisc: simplify pte_alloc_one_kernel() Mike Rapoport
2018-12-03 15:47 ` [PATCH v2 5/6] arch: simplify several early memory allocations Mike Rapoport
2018-12-03 16:29 ` Sam Ravnborg
2018-12-03 16:49 ` Mike Rapoport
2018-12-06 18:08 ` Sam Ravnborg [this message]
2018-12-06 21:30 ` Mike Rapoport
2018-12-03 15:47 ` [PATCH v2 6/6] arm, unicore32: remove early_alloc*() wrappers Mike Rapoport
2018-12-03 16:27 ` Rob Herring
2018-12-03 16:55 ` Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181206180826.GB19166@ravnborg.org \
--to=sam@ravnborg$(echo .)org \
--cc=akpm@linux-foundation$(echo .)org \
--cc=arnd@arndb$(echo .)de \
--cc=dalias@libc$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=deanbo422@gmail$(echo .)com \
--cc=green.hu@gmail$(echo .)com \
--cc=gxt@pku$(echo .)edu.cn \
--cc=jonas@southpole$(echo .)se \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-c6x-dev@linux-c6x$(echo .)org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-mm@kvack$(echo .)org \
--cc=linux-sh@vger$(echo .)kernel.org \
--cc=linux@armlinux$(echo .)org.uk \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=mhocko@suse$(echo .)com \
--cc=monstr@monstr$(echo .)eu \
--cc=msalter@redhat$(echo .)com \
--cc=openrisc@lists$(echo .)librecores.org \
--cc=paulus@samba$(echo .)org \
--cc=rppt@linux$(echo .)ibm.com \
--cc=shorne@gmail$(echo .)com \
--cc=sparclinux@vger$(echo .)kernel.org \
--cc=stefan.kristiansson@saunalahti$(echo .)fi \
--cc=ysato@users$(echo .)sourceforge.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox