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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 C4DBAC43216 for ; Wed, 4 Aug 2021 10:02:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5542C610A0 for ; Wed, 4 Aug 2021 10:02:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5542C610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id EF01F8D0058; Wed, 4 Aug 2021 06:02:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9FEC8D002D; Wed, 4 Aug 2021 06:02:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8F358D0058; Wed, 4 Aug 2021 06:02:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id BBC648D002D for ; Wed, 4 Aug 2021 06:02:41 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 72BE3182067BB for ; Wed, 4 Aug 2021 10:02:41 +0000 (UTC) X-FDA: 78436958922.25.34B62E4 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf04.hostedemail.com (Postfix) with ESMTP id F1B885007E05 for ; Wed, 4 Aug 2021 10:02:40 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id E224061004; Wed, 4 Aug 2021 10:02:34 +0000 (UTC) Date: Wed, 4 Aug 2021 11:02:32 +0100 From: Catalin Marinas To: Mike Rapoport Cc: Andrew Morton , Albert Ou , Andy Lutomirski , Borislav Petkov , Christian Borntraeger , Dave Hansen , Frank Rowand , Greg Kroah-Hartman , "H. Peter Anvin" , Heiko Carstens , Ingo Molnar , "Kirill A. Shutemov" , Len Brown , Marc Zyngier , Mike Rapoport , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , "Rafael J. Wysocki" , Rob Herring , Russell King , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , devicetree@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v3] memblock: make memblock_find_in_range method private Message-ID: <20210804100231.GA4857@arm.com> References: <20210803064218.6611-1-rppt@kernel.org> <20210803180526.GD5786@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: F1B885007E05 Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of cmarinas@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) X-Stat-Signature: r3c11hjkmjnh3kb8abqxgamo18z8b487 X-HE-Tag: 1628071360-112703 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Aug 03, 2021 at 10:07:37PM +0300, Mike Rapoport wrote: > On Tue, Aug 03, 2021 at 07:05:26PM +0100, Catalin Marinas wrote: > > On Tue, Aug 03, 2021 at 09:42:18AM +0300, Mike Rapoport wrote: > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > > index 8490ed2917ff..0bffd2d1854f 100644 > > > --- a/arch/arm64/mm/init.c > > > +++ b/arch/arm64/mm/init.c > > > @@ -74,6 +74,7 @@ phys_addr_t arm64_dma_phys_limit __ro_after_init; > > > static void __init reserve_crashkernel(void) > > > { > > > unsigned long long crash_base, crash_size; > > > + unsigned long long crash_max = arm64_dma_phys_limit; > > > int ret; > > > > > > ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), > > > @@ -84,33 +85,18 @@ static void __init reserve_crashkernel(void) > > > > > > crash_size = PAGE_ALIGN(crash_size); > > > > > > - if (crash_base == 0) { > > > - /* Current arm64 boot protocol requires 2MB alignment */ > > > - crash_base = memblock_find_in_range(0, arm64_dma_phys_limit, > > > - crash_size, SZ_2M); > > > - if (crash_base == 0) { > > > - pr_warn("cannot allocate crashkernel (size:0x%llx)\n", > > > - crash_size); > > > - return; > > > - } > > > - } else { > > > - /* User specifies base address explicitly. */ > > > - if (!memblock_is_region_memory(crash_base, crash_size)) { > > > - pr_warn("cannot reserve crashkernel: region is not memory\n"); > > > - return; > > > - } > > > + /* User specifies base address explicitly. */ > > > + if (crash_base) > > > + crash_max = crash_base + crash_size; > > > > > > - if (memblock_is_region_reserved(crash_base, crash_size)) { > > > - pr_warn("cannot reserve crashkernel: region overlaps reserved memory\n"); > > > - return; > > > - } > > > - > > > - if (!IS_ALIGNED(crash_base, SZ_2M)) { > > > - pr_warn("cannot reserve crashkernel: base address is not 2MB aligned\n"); > > > - return; > > > - } > > > + /* Current arm64 boot protocol requires 2MB alignment */ > > > + crash_base = memblock_phys_alloc_range(crash_size, SZ_2M, > > > + crash_base, crash_max); > > > + if (!crash_base) { > > > + pr_warn("cannot allocate crashkernel (size:0x%llx)\n", > > > + crash_size); > > > + return; > > > } > > > - memblock_reserve(crash_base, crash_size); > > > > We'll miss a bit on debug information provided to the user in case of a > > wrong crash_base/size option on the command line. Not sure we care much, > > though the alignment would probably be useful (maybe we document it > > somewhere). > > It is already documented: > > Documentation/admin-guide/kdump/kdump.rst: > On arm64, use "crashkernel=Y[@X]". Note that the start address of > the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000). Thanks for the pointer. > > What I haven't checked is whether memblock_phys_alloc_range() aims to > > get a 2MB aligned end (size) as well. If crash_size is not 2MB aligned, > > crash_max wouldn't be either and the above could fail. We only care > > about the crash_base to be aligned but the memblock_phys_alloc_range() > > doc says that both the start and size would be aligned to this. > > The doc lies :) > > memblock_phys_alloc_range() boils down to > > for_each_free_mem_range_reverse(i, nid, flags, &this_start, &this_end, > NULL) { > > /* clamp this_{start,end} to the user defined limits */ > > cand = round_down(this_end - size, align); > if (cand >= this_start) > return cand; > } Alright, it should work then. For arm64: Reviewed-by: Catalin Marinas