Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp601343pxb; Thu, 5 Nov 2020 08:13:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwE3wg16eRTUXGOW2Wya1nJMV5c9F85B3uaZQxpEQRkXULxrul2fN0iAh80VyrwiyyKjhyg X-Received: by 2002:a50:96d2:: with SMTP id z18mr3458515eda.367.1604592791510; Thu, 05 Nov 2020 08:13:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604592791; cv=none; d=google.com; s=arc-20160816; b=S93kmmKjMFqrGNCAP2hcVxqFOTo7KrQeVSbHThLFWDgbmL4tbsmomaLYyyEJZ3cJ4d N05tB+hC0IXKKBijQ74JjyhiSJLyV3qLjmABTDOdGamw3n/CARVCkU2GSYbxJCwU5qTX brXFhp70ugZO7FZ3vo9HWyunvwtos8WngQ7IANHlXoO3iN3NwI/wVsYqU+juVRAIte/V 2FSQ6+WSgA6ez6N9+F1wXI+vnPDPXR/egnmiGNeub57CjEmr6dkiqsj3oIahlxVR0nhr x1D22NyGRit/NSpRMrGWMpVuPFaBgbk1vnBSMSFlPBn7CegZoeyG6t0JC4ZlvmgIBrg9 CFwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ILTjpwYmD2Ke7zSdS4hg1XI6FrlynNHEad7UH8eIs9Y=; b=MiS7Rb2RYjQzhSdiYCgVEENFIkbRBVnl3ACpN7wbDKZYu012y+j5vC/MDaBXbR3p8G ldYVFQ0ODRgy9mZI1cmV4fToemKYYCwfM6dQOM0xjKedp12dAmZXmqRGRBYt5i3Va9/k BbB1z1eUrG3rQVXuJJfgpKZhUXvyIN6Pldm3NV4hj/pRyj58vOUlYki1Sme986wtshWo rg46rYZTckoV3KT5+Omz9TCiIOgnrYOdZ/3GNVgs05NVBuDdsAgrzpdyznTZyWBprRAD pQCHGMJpn/I6YSO7B6KZX3a/pnVQlexZ94EPrk2DlHhDCX03reOvhsLlhlp6scPea9AC AIIg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y10si1405401ejf.165.2020.11.05.08.12.48; Thu, 05 Nov 2020 08:13:11 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729718AbgKEQL0 (ORCPT + 99 others); Thu, 5 Nov 2020 11:11:26 -0500 Received: from foss.arm.com ([217.140.110.172]:36456 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbgKEQL0 (ORCPT ); Thu, 5 Nov 2020 11:11:26 -0500 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 6F66514BF; Thu, 5 Nov 2020 08:11:25 -0800 (PST) Received: from [172.16.1.113] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0A0BB3F718; Thu, 5 Nov 2020 08:11:17 -0800 (PST) Subject: Re: [PATCH v6 1/7] arm64: mm: Move reserve_crashkernel() into mem_init() To: Nicolas Saenz Julienne Cc: robh+dt@kernel.org, catalin.marinas@arm.com, hch@lst.de, ardb@kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, lorenzo.pieralisi@arm.com, will@kernel.org, jeremy.linton@arm.com, iommu@lists.linux-foundation.org, linux-rpi-kernel@lists.infradead.org, guohanjun@huawei.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org References: <20201103173159.27570-1-nsaenzjulienne@suse.de> <20201103173159.27570-2-nsaenzjulienne@suse.de> From: James Morse Message-ID: Date: Thu, 5 Nov 2020 16:11:08 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201103173159.27570-2-nsaenzjulienne@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! On 03/11/2020 17:31, Nicolas Saenz Julienne wrote: > crashkernel might reserve memory located in ZONE_DMA. We plan to delay > ZONE_DMA's initialization after unflattening the devicetree and ACPI's > boot table initialization, so move it later in the boot process. > Specifically into mem_init(), this is the last place crashkernel will be > able to reserve the memory before the page allocator kicks in. > There > isn't any apparent reason for doing this earlier. It's so that map_mem() can carve it out of the linear/direct map. This is so that stray writes from a crashing kernel can't accidentally corrupt the kdump kernel. We depend on this if we continue with kdump, but failed to offline all the other CPUs. We also depend on this when skipping the checksum code in purgatory, which can be exceedingly slow. Grepping around, the current order is: start_kernel() -> setup_arch() -> arm64_memblock_init() /* reserve */ -> paging_init() -> map_mem() /* carve out reservation */ [...] -> mm_init() -> mem_init() I agree we should add comments to make this apparent! Thanks, James > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 095540667f0f..fc4ab0d6d5d2 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -386,8 +386,6 @@ void __init arm64_memblock_init(void) > else > arm64_dma32_phys_limit = PHYS_MASK + 1; > > - reserve_crashkernel(); > - > reserve_elfcorehdr(); > > high_memory = __va(memblock_end_of_DRAM() - 1) + 1; > @@ -508,6 +506,8 @@ void __init mem_init(void) > else > swiotlb_force = SWIOTLB_NO_FORCE; > > + reserve_crashkernel(); > + > set_max_mapnr(max_pfn - PHYS_PFN_OFFSET); > > #ifndef CONFIG_SPARSEMEM_VMEMMAP >