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.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS 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 05967C04EB9 for ; Wed, 5 Dec 2018 12:37:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C2FA020850 for ; Wed, 5 Dec 2018 12:37:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2FA020850 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au 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 S1727787AbeLEMh5 (ORCPT ); Wed, 5 Dec 2018 07:37:57 -0500 Received: from ozlabs.org ([203.11.71.1]:47883 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbeLEMh4 (ORCPT ); Wed, 5 Dec 2018 07:37:56 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 438ytd6ssyz9s3C; Wed, 5 Dec 2018 23:37:45 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Mike Rapoport Cc: Andrew Morton , Arnd Bergmann , Benjamin Herrenschmidt , "David S. Miller" , Guan Xuetao , Greentime Hu , Jonas Bonn , 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 1/6] powerpc: prefer memblock APIs returning virtual address In-Reply-To: <20181204171327.GL26700@rapoport-lnx> References: <1543852035-26634-1-git-send-email-rppt@linux.ibm.com> <1543852035-26634-2-git-send-email-rppt@linux.ibm.com> <87woophasy.fsf@concordia.ellerman.id.au> <20181204171327.GL26700@rapoport-lnx> Date: Wed, 05 Dec 2018 23:37:44 +1100 Message-ID: <87mupkkv3b.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mike Rapoport writes: > On Tue, Dec 04, 2018 at 08:59:41PM +1100, Michael Ellerman wrote: >> Hi Mike, >> >> Thanks for trying to clean these up. >> >> I think a few could be improved though ... >> >> Mike Rapoport writes: >> > diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c >> > index 913bfca..fa884ad 100644 >> > --- a/arch/powerpc/kernel/paca.c >> > +++ b/arch/powerpc/kernel/paca.c >> > @@ -42,17 +42,15 @@ static void *__init alloc_paca_data(unsigned long size, unsigned long align, >> > nid = early_cpu_to_node(cpu); >> > } >> > >> > - pa = memblock_alloc_base_nid(size, align, limit, nid, MEMBLOCK_NONE); >> > - if (!pa) { >> > - pa = memblock_alloc_base(size, align, limit); >> > - if (!pa) >> > - panic("cannot allocate paca data"); >> > - } >> > + ptr = memblock_alloc_try_nid_raw(size, align, MEMBLOCK_LOW_LIMIT, >> > + limit, nid); >> > + if (!ptr) >> > + panic("cannot allocate paca data"); >> >> The old code doesn't zero, but two of the three callers of >> alloc_paca_data() *do* zero the whole allocation, so I'd be happy if we >> did it in here instead. > > I looked at the callers and couldn't tell if zeroing memory in > init_lppaca() would be ok. > I'll remove the _raw here. Thanks. >> That would mean we could use memblock_alloc_try_nid() avoiding the need >> to panic() manually. > > Actual, my plan was to remove panic() from all memblock_alloc* and make all > callers to check the returned value. > I believe it's cleaner and also allows more meaningful panic messages. Not > mentioning the reduction of memblock code. Hmm, not sure. I see ~200 calls to the panicking functions, that seems like a lot of work to change all those. And I think I disagree on the "more meaningful panic message". This is a perfect example, compare: panic("cannot allocate paca data"); to: panic("%s: Failed to allocate %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa\n", __func__, (u64)size, (u64)align, nid, &min_addr, &max_addr); The former is basically useless, whereas the second might at least give you a hint as to *why* the allocation failed. I know it's kind of odd for a function to panic() rather than return an error, but memblock is kind of special because it's so early in boot. Most of these allocations have to succeed to get the system up and running. cheers