Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2205020imu; Thu, 24 Jan 2019 08:52:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN54NPvuOKCIG+svx+IPMjARH8B3FLQp37HpcSWb+oK4Z/rX4goBLBoDhlDzkU/oAJ2UjMCw X-Received: by 2002:a63:2643:: with SMTP id m64mr6482057pgm.35.1548348764404; Thu, 24 Jan 2019 08:52:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548348764; cv=none; d=google.com; s=arc-20160816; b=nvJyU5dLyDh1DRD832hOM4atEtkgOWpX/OZf/zmBoDFD1/MUviBniqWX+rY7wpCze5 CvVBEc9/Nuvz4SrgqlVn9tUXgJLUGAjgd87LChlKaBwtyVv9+dDvM+feNKowknGZL40M KcjPwM0mphcFz9ueWJiQE4+lJhreBSDj96iGqySxjXLvzJTT2TTfBRiwWZRFw6Derdj/ ZdNzqezJFaWfcCyaqNiFchEHU5b3FC2JE8/0Nzgg1dW5Ofxs5RJfoMiH+JgiR0QmqPnK fWBSjCkQm9CmMShFj5xRSt7yUaihkdsqNn8DkkSUeplY6P1Ts9IFt11fdIHpq/LgkkEz 4kfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1wCjIfNw7F7vGTk66LAAxbAmlLzUhMr2xswG4bulc44=; b=no6QwR6pUMX9o1dbALOiXz9J5ESEF4y67Xwt4PyuhA6k7dcqBQcque+d19EpOnzPkw NQbryNHnXZ5PdrQm9oXeZBg2JwnanzklWoyiCs11JdhVxupeEm2WEC8aFZqkU8Pc3yGP sDsqqh5It7d0l3XS94fp2o1qWg5nqR2aLA1z0UoPAn7wxyqJ4EOxrQDHgw/sNMhEPXu1 uWyN9Fs9x/0LcQ2kN1b6CvFm+e4ZKPnJSrsRmEpPmV5rXaDdZGpXaSkSmPgwc/TqXvsE Eyu0UkN/Zm+ncCHAWDJphg6cosuQQWplC1NnX4dHtoI4xikQlSIZ5tb51eWfSfo2q9sS ABOw== ARC-Authentication-Results: i=1; mx.google.com; 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 q140si25394004pfc.20.2019.01.24.08.52.28; Thu, 24 Jan 2019 08:52:44 -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; 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 S1727861AbfAXQv6 (ORCPT + 99 others); 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.