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=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,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 54BECC282C3 for ; Thu, 24 Jan 2019 16:52:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 270E1218AF for ; Thu, 24 Jan 2019 16:52:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728401AbfAXQv6 (ORCPT ); Thu, 24 Jan 2019 11:51:58 -0500 Received: from foss.arm.com ([217.140.101.70]:60740 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbfAXQv6 (ORCPT ); Thu, 24 Jan 2019 11:51:58 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 98533A78; Thu, 24 Jan 2019 08:51:57 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A94E3F237; Thu, 24 Jan 2019 08:51:55 -0800 (PST) Date: Thu, 24 Jan 2019 16:51:53 +0000 From: Mark Rutland To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin , Mike Rapoport , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v14 02/12] powerpc/irq: use memblock functions returning virtual address Message-ID: <20190124165153.GB5531@lakrids.cambridge.arm.com> References: <1c8e658c094022a15e4b9f5ef5c191caab3c0dff.1548346225.git.christophe.leroy@c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c8e658c094022a15e4b9f5ef5c191caab3c0dff.1548346225.git.christophe.leroy@c-s.fr> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 04:19:33PM +0000, Christophe Leroy wrote: > Since only the virtual address of allocated blocks is used, > lets use functions returning directly virtual address. > > Those functions have the advantage of also zeroing the block. > > Suggested-by: Mike Rapoport > Acked-by: Mike Rapoport > Signed-off-by: Christophe Leroy [...] > +static void *__init alloc_stack(void) > +{ > + void *ptr = memblock_alloc(THREAD_SIZE, THREAD_SIZE); > + > + if (!ptr) > + panic("cannot allocate stacks"); > + > + return ptr; > +} I believe memblock_alloc() will panic() if it cannot allocate memory, since that goes: memblock_alloc() -> memblock_alloc_try_nid() -> panic() So you can get rid of the panic() here, or if you want a custom panic message, you can use memblock_alloc_nopanic(). [...] > static void *__init alloc_stack(unsigned long limit, int cpu) > { > - unsigned long pa; > + void *ptr; > > BUILD_BUG_ON(STACK_INT_FRAME_SIZE % 16); > > - pa = memblock_alloc_base_nid(THREAD_SIZE, THREAD_SIZE, limit, > - early_cpu_to_node(cpu), MEMBLOCK_NONE); > - if (!pa) { > - pa = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit); > - if (!pa) > - panic("cannot allocate stacks"); > - } > + ptr = memblock_alloc_try_nid(THREAD_SIZE, THREAD_SIZE, > + MEMBLOCK_LOW_LIMIT, limit, > + early_cpu_to_node(cpu)); > + if (!ptr) > + panic("cannot allocate stacks"); The same applies here -- memblock_alloc_try_nid() will panic itself rather than returning NULL. Otherwise, this looks like a nice cleanup. With the panics removed (or using the _nopanic() allocators), feel free to add: Acked-by: Mark Rutland Thanks, Mark.