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=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 13AA0C433E0 for ; Wed, 5 Aug 2020 06:02:12 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC6B222B42 for ; Wed, 5 Aug 2020 06:02:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lWRqeqMx"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gPXNOa9u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC6B222B42 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XLM3cmwHaFMRbTSp2Ua2BQ4fr+g50ikTcvsJc83o9jM=; b=lWRqeqMx1PmpeGEtKWKtTvCL1 VkWNfmTN8RxbFTHAZNUF0+eYO5goivSrtjoWy45bOuYH0QeeiZFDtRqtAGQ62azq2bLHCOT46iEmL fDIIKV/KdsHYYCLenaAK+vHx1iwP146FlD2mi/aOulJa2qktURdOvKn/usNIMuaVweVVrdtWWLQoc NotUA54gGI24nTKP8J9sBLPT05TPeZqbWKKz7rqtLWTO5voZ+/pcNsJuuQsXWtMPmHXxKhYIIJmBs 9tdmatK7kIqJ6sGtYfCdF7lAoz0cppDEMzI4lTMVZnZn05o9aKnEtjDrFutot3bCK2zVPvNtgF1zj 5k483xIYA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3CTg-0004JW-FD; Wed, 05 Aug 2020 06:00:40 +0000 Received: from us-smtp-2.mimecast.com ([205.139.110.61] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3CTd-0004HQ-1w for linux-arm-kernel@lists.infradead.org; Wed, 05 Aug 2020 06:00:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596607235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GMI2VHEJj5qxJst+Mnz2rfpYmYwR7lvZPX1P81/rYkI=; b=gPXNOa9u2JqHhn+jkOXu1vG6VlIUfPsaVVbBT74QqtXBCTZMjyQDiVXrYpMv1tk+JedILc ZwfpU0UjQ3rLAVInETP1LD1E8uOE6LHiBfzLm2G530mcRqlT8CCeyxMg37s9JHxCX48O3/ IPmpgn/Bx9Bgq5OBFYXi3GmW/DawKYk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-72-i88hwEKrNImuiQFvk1P0-w-1; Wed, 05 Aug 2020 02:00:30 -0400 X-MC-Unique: i88hwEKrNImuiQFvk1P0-w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D7338064AC; Wed, 5 Aug 2020 06:00:13 +0000 (UTC) Received: from localhost (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5810726A3; Wed, 5 Aug 2020 06:00:08 +0000 (UTC) Date: Wed, 5 Aug 2020 14:00:06 +0800 From: Baoquan He To: Mike Rapoport Subject: Re: [PATCH v2 14/17] x86/setup: simplify reserve_crashkernel() Message-ID: <20200805060006.GU10792@MiWiFi-R3L-srv> References: <20200802163601.8189-1-rppt@kernel.org> <20200802163601.8189-15-rppt@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200802163601.8189-15-rppt@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_020037_146963_4F12DF40 X-CRM114-Status: GOOD ( 26.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emil Renner Berthing , linux-sh@vger.kernel.org, Peter Zijlstra , Benjamin Herrenschmidt , Dave Hansen , linux-mips@vger.kernel.org, Max Filippov , Paul Mackerras , sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, Will Deacon , Stafford Horne , Marek Szyprowski , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Michael Ellerman , x86@kernel.org, Russell King , Mike Rapoport , clang-built-linux@googlegroups.com, Ingo Molnar , linux-arm-kernel@lists.infradead.org, Catalin Marinas , uclinux-h8-devel@lists.sourceforge.jp, linux-xtensa@linux-xtensa.org, openrisc@lists.librecores.org, Borislav Petkov , Andy Lutomirski , Paul Walmsley , Thomas Gleixner , Hari Bathini , Michal Simek , linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Palmer Dabbelt , Andrew Morton , Christoph Hellwig Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 08/02/20 at 07:35pm, Mike Rapoport wrote: > From: Mike Rapoport > > * Replace magic numbers with defines > * Replace memblock_find_in_range() + memblock_reserve() with > memblock_phys_alloc_range() > * Stop checking for low memory size in reserve_crashkernel_low(). The > allocation from limited range will anyway fail if there is no enough > memory, so there is no need for extra traversal of memblock.memory > > Signed-off-by: Mike Rapoport > --- > arch/x86/kernel/setup.c | 40 ++++++++++++++-------------------------- > 1 file changed, 14 insertions(+), 26 deletions(-) Applied this patch on top of 5.8, crashkernel reservation works well. And the code change looks good. Reviewed-by: Baoquan He > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index d8de4053c5e8..d7ced6982524 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -419,13 +419,13 @@ static int __init reserve_crashkernel_low(void) > { > #ifdef CONFIG_X86_64 > unsigned long long base, low_base = 0, low_size = 0; > - unsigned long total_low_mem; > + unsigned long low_mem_limit; > int ret; > > - total_low_mem = memblock_mem_size(1UL << (32 - PAGE_SHIFT)); > + low_mem_limit = min(memblock_phys_mem_size(), CRASH_ADDR_LOW_MAX); > > /* crashkernel=Y,low */ > - ret = parse_crashkernel_low(boot_command_line, total_low_mem, &low_size, &base); > + ret = parse_crashkernel_low(boot_command_line, low_mem_limit, &low_size, &base); > if (ret) { > /* > * two parts from kernel/dma/swiotlb.c: > @@ -443,23 +443,17 @@ static int __init reserve_crashkernel_low(void) > return 0; > } > > - low_base = memblock_find_in_range(0, 1ULL << 32, low_size, CRASH_ALIGN); > + low_base = memblock_phys_alloc_range(low_size, CRASH_ALIGN, 0, CRASH_ADDR_LOW_MAX); > if (!low_base) { > pr_err("Cannot reserve %ldMB crashkernel low memory, please try smaller size.\n", > (unsigned long)(low_size >> 20)); > return -ENOMEM; > } > > - ret = memblock_reserve(low_base, low_size); > - if (ret) { > - pr_err("%s: Error reserving crashkernel low memblock.\n", __func__); > - return ret; > - } > - > - pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (System low RAM: %ldMB)\n", > + pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (low RAM limit: %ldMB)\n", > (unsigned long)(low_size >> 20), > (unsigned long)(low_base >> 20), > - (unsigned long)(total_low_mem >> 20)); > + (unsigned long)(low_mem_limit >> 20)); > > crashk_low_res.start = low_base; > crashk_low_res.end = low_base + low_size - 1; > @@ -503,13 +497,13 @@ static void __init reserve_crashkernel(void) > * unless "crashkernel=size[KMG],high" is specified. > */ > if (!high) > - crash_base = memblock_find_in_range(CRASH_ALIGN, > - CRASH_ADDR_LOW_MAX, > - crash_size, CRASH_ALIGN); > + crash_base = memblock_phys_alloc_range(crash_size, > + CRASH_ALIGN, CRASH_ALIGN, > + CRASH_ADDR_LOW_MAX); > if (!crash_base) > - crash_base = memblock_find_in_range(CRASH_ALIGN, > - CRASH_ADDR_HIGH_MAX, > - crash_size, CRASH_ALIGN); > + crash_base = memblock_phys_alloc_range(crash_size, > + CRASH_ALIGN, CRASH_ALIGN, > + CRASH_ADDR_HIGH_MAX); > if (!crash_base) { > pr_info("crashkernel reservation failed - No suitable area found.\n"); > return; > @@ -517,19 +511,13 @@ static void __init reserve_crashkernel(void) > } else { > unsigned long long start; > > - start = memblock_find_in_range(crash_base, > - crash_base + crash_size, > - crash_size, 1 << 20); > + start = memblock_phys_alloc_range(crash_size, SZ_1M, crash_base, > + crash_base + crash_size); > if (start != crash_base) { > pr_info("crashkernel reservation failed - memory is in use.\n"); > return; > } > } > - ret = memblock_reserve(crash_base, crash_size); > - if (ret) { > - pr_err("%s: Error reserving crashkernel memblock.\n", __func__); > - return; > - } > > if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) { > memblock_free(crash_base, crash_size); > -- > 2.26.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel