Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1685849pxk; Tue, 1 Sep 2020 05:25:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAxJ+Kw7HS4afKdshufq2Tj2AMdmAaQG55sJu1zQdSseBygKtQ37AO3AfWi6us8f2fpAh/ X-Received: by 2002:a50:d78e:: with SMTP id w14mr1518087edi.229.1598963115950; Tue, 01 Sep 2020 05:25:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598963115; cv=none; d=google.com; s=arc-20160816; b=fbS1ydq8PJAkK+0P+1UJs4JFjXQF2jpTvBvKC9Tm69o2ZB9ol4JxiBXMOjMg9WdRQe yQ9pIUkEiPQSTbgWRW9PZ8kboSwdMOkAp8PHMVIYKQ2SzJ5Mehx3iollofwbd89iGd5C 1TAVCkuUqPY/gKVr+p7au1VO4yhhr+PjHeA2y/6Y00sExFNXv6jiKyujI0yfEIEVmPEI vi74vzBEgDbnj/LEn+gJ0JeUVVXO3GMykAkxzVsJm7tcvMei6uFpOUX6jtHiVDqNpVo9 C0neBdhY3iGcAqvkuW1KObFXSjxNvRs3Uw9p5xkvzx1/o/5LvcHSYteE3MiXr9Q0wYkH hVmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=scLzcqqJvYdoW6c7NyMFBPIHd6/MSgK0mxwVHeyxSNA=; b=tBA4bGfvGf0l20ULW7B7CXSutx7rfNOAcKJ+Ys94C1grlWTwSO5ywVCKdKuXxoHbWi dGEmwNgs2gNMs8xTClaaj1Gr+kIzIYzUVfhRW56/Gi63BvddOs0JI/4giFKcOLkWxDSz 92GdAIkP6RTxWTifd/O3ThEre9fSdJNseEVbvtjKvFB2nXdG5N+3JuhP1WzEzeaQ04rZ dcBO2OZQsweuzd2hlTPv0rbVuN02UDrK782j43zf9/ecGMfPRHRsKwsRfyPBufNUzn2f 8prxPGzWJFadGHJmqApH6pDqzYEw/elVNg+GD36i1bz1hTdPqO34JL0W89ln557kVp1v PERg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dEqOWpAz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m18si597622ejc.93.2020.09.01.05.24.53; Tue, 01 Sep 2020 05:25:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dEqOWpAz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727109AbgIAMXI (ORCPT + 99 others); Tue, 1 Sep 2020 08:23:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:59694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728177AbgIAMLg (ORCPT ); Tue, 1 Sep 2020 08:11:36 -0400 Received: from kernel.org (unknown [77.127.89.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5EDE9206EF; Tue, 1 Sep 2020 12:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598962296; bh=p4M/L1yz/ek8/chpzyAF+xMHJfMK5wQCHUgID8EQdmE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dEqOWpAz2kvlKimlO8dARzBFcrklfu8cSe+2aBF7CkJogzpcFaPoSG4sCMG8qyzbm ZMT4ghik9IujpTvBZZvnOyJQ3FEHNmSceRhtvrncuQUYwdh1STPOtZ5hDvRfEgtVCc sCotdF9hRvqJ/eYyBX3v/Yw22a9waEHIR0NqLKK4= Date: Tue, 1 Sep 2020 15:11:30 +0300 From: Mike Rapoport To: Stafford Horne Cc: LKML , Jonas Bonn , Stefan Kristiansson , Greg Kroah-Hartman , Andrew Morton , Arvind Sankar , openrisc@lists.librecores.org Subject: Re: [PATCH] openrisc: Reserve memblock for initrd Message-ID: <20200901121130.GA698558@kernel.org> References: <20200831212102.4014642-1-shorne@gmail.com> <20200901055924.GC432455@kernel.org> <20200901102044.GB3562056@lianli.shorne-pla.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200901102044.GB3562056@lianli.shorne-pla.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 01, 2020 at 07:20:44PM +0900, Stafford Horne wrote: > On Tue, Sep 01, 2020 at 08:59:24AM +0300, Mike Rapoport wrote: > > On Tue, Sep 01, 2020 at 06:21:01AM +0900, Stafford Horne wrote: > > > Recently OpenRISC added support for external initrd images, but I found > > > some instability when using larger buildroot initrd images. It turned > > > out that I forgot to reserve the memblock space for the initrd image. > > > > > > This patch fixes the instability issue by reserving memblock space. > > > > > > Fixes: ff6c923dbec3 ("openrisc: Add support for external initrd images") > > > Signed-off-by: Stafford Horne > > > --- > > > arch/openrisc/kernel/setup.c | 9 +++++++++ > > > 1 file changed, 9 insertions(+) > > > > > > diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c > > > index b18e775f8be3..2c8aa53cc7ba 100644 > > > --- a/arch/openrisc/kernel/setup.c > > > +++ b/arch/openrisc/kernel/setup.c > > > @@ -80,6 +80,15 @@ static void __init setup_memory(void) > > > */ > > > memblock_reserve(__pa(_stext), _end - _stext); > > > > > > +#ifdef CONFIG_BLK_DEV_INITRD > > > + /* Then reserve the initrd, if any */ > > > + if (initrd_start && (initrd_end > initrd_start)) { > > > + memblock_reserve(ALIGN_DOWN(__pa(initrd_start), PAGE_SIZE), > > > + ALIGN(initrd_end, PAGE_SIZE) - > > > + ALIGN_DOWN(initrd_start, PAGE_SIZE)); > > > + } > > > > The core mm takes care of reserving the entrire pages for the memory > > reserved with memblock, so it is not necessary to do it here. > > Thanks for the pointer > > I guess what you mean is it is not required to do the page alignment. Right. > I used other architectures as an example and most do the alignment, I > think for most architectures this can be pulled out to generic code. You are more than welcome :) We already have a generic free_initrd_mem(), maybe it's time to have a generic reserve_initrd_mem(). I'm ok with openrisc doing the alignment, but I think using local variables would make the core more readable, e.g if (initd_start && (initrd_end)) { unsigned long aligned_start = ALIGN_DOWN(initrd_start, PAGE_SIZE); unsigned long aligned_end = ALIGN(end, PAGE_SIZE); memblock_reserve(aligned_start, aligned_end); } What do you say? > -Stafford > > > > +#endif /* CONFIG_BLK_DEV_INITRD */ > > > + > > > early_init_fdt_reserve_self(); > > > early_init_fdt_scan_reserved_mem(); > > > > > > -- > > > 2.26.2 > > > > > > > -- > > Sincerely yours, > > Mike. -- Sincerely yours, Mike.