Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp535886ybn; Wed, 25 Sep 2019 03:55:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwclXh1cjXx9G4NeZ8b8lzITIxCYuRHCR+83bF6b1asYEvYjNT++auHIvWHrQpQ/VJEP0oJ X-Received: by 2002:a2e:81c5:: with SMTP id s5mr5691261ljg.124.1569408957901; Wed, 25 Sep 2019 03:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569408957; cv=none; d=google.com; s=arc-20160816; b=E5alxeikUDGXh4E6RtBlrP2CKrcdc4dFmXnltM2T9nlCE/jyhc7nCYB/FNQntChAiV ajDnrdTir2qihlborWkPeht2dNBgHhH/XzMHzstie3Bsat7qt81VrIBwrgk1GZkv8lg1 0tbzmDD0xLylzWAcsJIXDQgsq2zVGCC3y7Lzrt+w1L1D08/wS3fr1d33N/oocQ8JUrWf XChmntfO0rPaaOxj1pptxy/QxMkuVM+O8DgGIkg85zqN9fIKM/lwWx+QRqtbN4L1u/VF nclzD6+IU75/kTuYIi9MCEeWxfNTn/j0tBSzsUm/Zo1vFtR/WO7kNhSRjpebeB7AKMNR Hcjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=iUsvo0bqSb8Dnn4GFm/fYZHI7DWM+WbKk7S98/FMvg4=; b=hRzvNmyczg87ffgtEoKxbcvCvBqySogfIyGWkVhEtVdyNNxCSscmKPDnHqNOguBkyE 4XYdhzw9UGKX8NRbeJLYYZKVsGWy6m8xMZ/jOB4f6dksH2ugJJXTf9+H4gwtknv+3/ZD PXafbth3u0EaHH3YA81mwemOrHNE+J0P5MffXMkXkn40w3TFTpgjD2FVHwWIXKm2t72L bVUkgQKdNk6oXiD+BvC45nIbdnzw2JJlH1vnRuSqTQpjUut8yWxvi+gbEpX0E6RfK4Ee nhqGaiWVqwaUX8/tlQJGGJYYlhC0K924h0Sbh+iXlj5qWHhRkRlFbnt0Dp6wsCcvs0On kuWw== 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 c8si3258581edb.82.2019.09.25.03.55.20; Wed, 25 Sep 2019 03:55:57 -0700 (PDT) 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 S2406871AbfIWKLc (ORCPT + 99 others); Mon, 23 Sep 2019 06:11:32 -0400 Received: from foss.arm.com ([217.140.110.172]:39990 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405389AbfIWKLc (ORCPT ); Mon, 23 Sep 2019 06:11:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C59CA1000; Mon, 23 Sep 2019 03:11:31 -0700 (PDT) Received: from [10.162.40.137] (p8cg001049571a15.blr.arm.com [10.162.40.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 537933F694; Mon, 23 Sep 2019 03:11:29 -0700 (PDT) Subject: Re: [PATCH] arm64: use generic free_initrd_mem() To: Mike Rapoport , Laura Abbott Cc: Mark Rutland , linux-arch@vger.kernel.org, Catalin Marinas , linux-kernel@vger.kernel.org, Mike Rapoport , Will Deacon , linux-arm-kernel@lists.infradead.org References: <1568618488-19055-1-git-send-email-rppt@kernel.org> <0ba20aa4-d2dd-2263-6b5f-16a5c8a39f67@redhat.com> <20190916135542.GC5196@rapoport-lnx> From: Anshuman Khandual Message-ID: Date: Mon, 23 Sep 2019 15:41:46 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190916135542.GC5196@rapoport-lnx> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/16/2019 07:25 PM, Mike Rapoport wrote: > (added linux-arch) > > On Mon, Sep 16, 2019 at 08:23:29AM -0400, Laura Abbott wrote: >> On 9/16/19 8:21 AM, Mike Rapoport wrote: >>> From: Mike Rapoport >>> >>> arm64 calls memblock_free() for the initrd area in its implementation of >>> free_initrd_mem(), but this call has no actual effect that late in the boot >>> process. By the time initrd is freed, all the reserved memory is managed by >>> the page allocator and the memblock.reserved is unused, so there is no >>> point to update it. >>> >> >> People like to use memblock for keeping track of memory even if it has no >> actual effect. We made this change explicitly (see 05c58752f9dc ("arm64: To remove >> initrd reserved area entry from memblock") That said, moving to the generic >> APIs would be nice. Maybe we can find another place to update the accounting? > > Any other place in arch/arm64 would make it messy because it would have to > duplicate keepinitrd logic. > > We could put the memblock_free() in the generic free_initrd_mem() with > something like: > > diff --git a/init/initramfs.c b/init/initramfs.c > index c47dad0..403c6a0 100644 > --- a/init/initramfs.c > +++ b/init/initramfs.c > @@ -531,6 +531,10 @@ void __weak free_initrd_mem(unsigned long start, > unsigned long end) > { > free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, > "initrd"); > + > +#ifdef CONFIG_ARCH_KEEP_MEMBLOCK > + memblock_free(__virt_to_phys(start), end - start); > +#endif > } This makes sense. > > #ifdef CONFIG_KEXEC_CORE > > > Then powerpc and s390 folks will also be able to track the initrd memory :) Sure. > >>> Without the memblock_free() call the only difference between arm64 and the >>> generic versions of free_initrd_mem() is the memory poisoning. Switching >>> arm64 to the generic version will enable the poisoning. >>> >>> Signed-off-by: Mike Rapoport >>> --- >>> >>> I've boot tested it on qemu and I've checked that kexec works. >>> >>> arch/arm64/mm/init.c | 8 -------- >>> 1 file changed, 8 deletions(-) >>> >>> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c >>> index f3c7952..8ad2934 100644 >>> --- a/arch/arm64/mm/init.c >>> +++ b/arch/arm64/mm/init.c >>> @@ -567,14 +567,6 @@ void free_initmem(void) >>> unmap_kernel_range((u64)__init_begin, (u64)(__init_end - __init_begin)); >>> } >>> -#ifdef CONFIG_BLK_DEV_INITRD >>> -void __init free_initrd_mem(unsigned long start, unsigned long end) >>> -{ >>> - free_reserved_area((void *)start, (void *)end, 0, "initrd"); >>> - memblock_free(__virt_to_phys(start), end - start); >>> -} >>> -#endif >>> - >>> /* >>> * Dump out memory limit information on panic. >>> */ >>> >> >