Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4642666iob; Sun, 8 May 2022 20:20:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj+DokAbieynovlnjc0MwfnVdAncUMU1w3XX+eZEl+sfAaSZH+pd+4gfsIOtu4ojTT5x0T X-Received: by 2002:a63:69c7:0:b0:3c2:2b51:a4b6 with SMTP id e190-20020a6369c7000000b003c22b51a4b6mr11659025pgc.153.1652066418871; Sun, 08 May 2022 20:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652066418; cv=none; d=google.com; s=arc-20160816; b=fwE1taeChnDjEjt1oJIHcVOPg49/RQRM/Aa+Jo9sITzNzMiiubMv+MspZ254pyivjv ByP33JjMpasdSZNyNoninaTX//GZTzVII98dQ8cDA9Fc+KFqhbwWweVBkGzn3DrHCz3T qX5wVxW4dFt283S8XnHAdBCIYOmDHUuJ6qv5tA5rOae2vaA0cCGJn6dAhhhUtf1rfTyj fcU6I/+aKt+MUPPzRZkbnHoyVOT9uL55FpKLuyNnjes0p1cQztCkbdHPQEl4nKO7pZPg StdhpnzxYYEYA/bZqg0IHdRmX8XetiYubdZtTUpc5Wl7/WzRNHqn1hqcWQZhpVSayt/T Ojmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8e+k/+y9OcE1mgVQl5G3myG0wCTkmuqBJJIz2n+p6KI=; b=QTnOQbZIwmplHP5I7YlleKKpfDfZ3L37B24prTgoci3f39Qr8T+k0ZAnRc425LGnAy g65/2fuaYGN3Re61x1Evio7eCinvVJks5ReQfrMZN1pSVOMlNS7lt01ILmeWIXoipw+s 0TLDMqz/3yslMbI786QqxtcmUOyVRn6FtjmBSx1orIqkYOVTZlcaHb1O0GTXrv9JT94I 8QCASQmvcusvNa1l2ogK6mBHMo3/CpCJ3P0QL9GtF2vr5v4eSfhUjPbMoZF6yD8HcYy6 oHNkiF8Qb9XsTfddo1mPYEml6A95AA12L7UmZ0WI2fhcuKD6nf7WJgdTCvqMWlsXisQ1 glnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EvmJFEvN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t22-20020a62ea16000000b00505fd3b3dcbsi11970411pfh.164.2022.05.08.20.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:20:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EvmJFEvN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A37B698F76; Sun, 8 May 2022 20:20:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384182AbiEGN0k (ORCPT + 99 others); Sat, 7 May 2022 09:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235180AbiEGN0i (ORCPT ); Sat, 7 May 2022 09:26:38 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7D612366A9 for ; Sat, 7 May 2022 06:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651929770; 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=8e+k/+y9OcE1mgVQl5G3myG0wCTkmuqBJJIz2n+p6KI=; b=EvmJFEvN1wDCz6TxbWUk1auHKVqsLVBoZu7qv2g/VCnHuOVR9QfOcHG4u4UVc3P4BHDM1z 5PhXt5SyD8Ye9O5b/K0B14Us1qltveCLj26x8ZRoC6IPf1l42ZIzIQ+DObY51tNtxKGnn+ bP7MgY/SmnBpSKWC7f1yOY3StIZIn3s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-351-y-8dsoQnOnWyX_xDm9-YPg-1; Sat, 07 May 2022 09:22:46 -0400 X-MC-Unique: y-8dsoQnOnWyX_xDm9-YPg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9705F101AA44; Sat, 7 May 2022 13:22:45 +0000 (UTC) Received: from localhost (ovpn-12-41.pek2.redhat.com [10.72.12.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E74840D2830; Sat, 7 May 2022 13:22:41 +0000 (UTC) Date: Sat, 7 May 2022 21:22:21 +0800 From: Baoquan He To: "Leizhen (ThunderTown)" Cc: Catalin Marinas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org, Dave Young , Vivek Goyal , Eric Biederman , kexec@lists.infradead.org, Will Deacon , linux-arm-kernel@lists.infradead.org, Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Randy Dunlap , Feng Zhou , Kefeng Wang , Chen Zhou , John Donnelly , Dave Kleikamp Subject: Re: [PATCH v24 3/6] arm64: kdump: Reimplement crashkernel=X Message-ID: References: <20220506114402.365-1-thunder.leizhen@huawei.com> <20220506114402.365-4-thunder.leizhen@huawei.com> <20220506231032.GA122876@MiWiFi-R3L-srv> <9f6fdbb8-b6c5-3ca0-31b6-617175739e81@huawei.com> <6e892914-74ae-2b8f-954e-342aaf4be870@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6e892914-74ae-2b8f-954e-342aaf4be870@huawei.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/07/22 at 05:35pm, Leizhen (ThunderTown) wrote: > > > On 2022/5/7 11:37, Leizhen (ThunderTown) wrote: > > > > > > On 2022/5/7 10:07, Baoquan He wrote: > >> On 05/07/22 at 09:34am, Leizhen (ThunderTown) wrote: > >>> > >>> > >>> On 2022/5/7 7:10, Baoquan He wrote: > >>>> On 05/06/22 at 07:43pm, Zhen Lei wrote: > >>>> ...... > >>>>> @@ -118,8 +162,7 @@ static void __init reserve_crashkernel(void) > >>>>> if (crash_base) > >>>>> crash_max = crash_base + crash_size; > >>>>> > >>>>> - /* Current arm64 boot protocol requires 2MB alignment */ > >>>>> - crash_base = memblock_phys_alloc_range(crash_size, SZ_2M, > >>>>> + crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, > >>>>> crash_base, crash_max); > >>>>> if (!crash_base) { > >>>>> pr_warn("cannot allocate crashkernel (size:0x%llx)\n", > >>>>> @@ -127,6 +170,11 @@ static void __init reserve_crashkernel(void) > >>>>> return; > >>>>> } > >>>>> > >>>> > >>>> There's corner case missed, e.g > >>>> 1) ,high and ,low are specified, CONFIG_ZONE_DMA|DMA32 is not enabled; > >>>> 2) ,high and ,low are specified, the whole system memory is under 4G. > >>>> > >>>> Below judgement can filter them away: > >>>> > >>>> if (crash_base > arm64_dma_phys_limit && crash_low_size && > >>>> reserve_crashkernel_low(crash_low_size)) { > >>>> > >>>> What's your opinion? Leave it and add document to notice user, or fix it > >>>> with code change? > > I decided to modify the code and document. But the code changes aren't what > you suggested. For the following reasons: Hi Lei, I would say let's merge this version firstly, then add the left step by step. Crashkernel= is not a simple parameter, expecting to make it in one step is not realistic. Otherwise, we will be in a mess of all cases of discussion and handling. Let's slow down and get the basic support added. > 1. The memory allocated for 'high' may be partially under 4G. So the low > memory may not be enough. Of course, it's rare. No, let's forget under 4G or above 4G thing on arm64, but use arm64_dma_phys_limit instead. It's basically equivalent to 4G on x86, while will cause confusion. And I may not get what you are saying the 'high' partially under 4G thing, could you be more specific or give an example? > 2. The second kernel can work properly only when the high and low memory > are successfully applied for. For example, high=128M, low=128M, but the > second kernel need 256M. I may not get this either. We usually won't split our memory requirement into ,high and ,low region. ,high is the main place to accommadate kernel image, initrd, and user space program's memory allocation. ,low is for DMA during kernel bootup. We probably should not encourage or guide user to use like this if I got you correctly. That will complicate the crashkernel= usage more. > > So for the cases you listed: > 1) ,high and ,low are specified, CONFIG_ZONE_DMA|DMA32 is not enabled; > --> Follow you suggestion, ignore crashkernel=Y,low, don't allocate low memory. > > @@ -100,6 +100,14 @@ static int __init reserve_crashkernel_low(unsigned long long low_size) > { > unsigned long long low_base; > > + /* > + * The kernel does not have any DMA zone, so the range of each DMA > + * zone is unknown. Please make sure both CONFIG_ZONE_DMA and > + * CONFIG_ZONE_DMA32 are also not set in the second kernel. > + */ > + if (!IS_ENABLED(CONFIG_ZONE_DMA) && !IS_ENABLED(CONFIG_ZONE_DMA32)) > + return 0; > + > > 2) ,high and ,low are specified, the whole system memory is under 4G. > --> two memory ranges will be allocated, the size is what 'high' and 'low' specified. > --> Yes, the memory of 'low' may be above 'high', but the 'high' just hint allocation > --> from top, try high memory first. Of course, this may cause kexec to fail to load. > --> Because the memory of 'low' with small size will be used to store Image, etc.. > --> But the memory of 'low' above 'high' is almost impossible, we use memblock API to > --> allocate memory from top to bottem, 'low' above 'high' need a sizeable memory block > --> (128M, 256M?) to be freed at init phase. Not really. Please think about the case that crashkernel=1G,hign crashkernel=128M,low. memblock top down allocation find a lower position for 1G, but a higher position for 128M because of meomry fragmentation. It's easy but reasonable thing. > --> Maybe I should add: crash_max = min(crash_base, CRASH_ADDR_LOW_MAX); > --> to make sure the memory of 'low' is always under 'high' I would say let's not scatter these details into different places. Like what I changed, it's much easier and code is more understandable. Let's discuss this after this series accepted. A new series can be posted to handle these. > > >>> > >>> I think maybe we can leave it unchanged. If the user configures two memory ranges, > >>> we'd better apply for two. Otherwise, he'll be confused when he inquires. Currently, > >>> crash_low_size is non-zero only when 'crashkernel=Y,low' is explicitly configured. > >> > >> Then user need know the system information, e.g how much is the high > >> memory, low memory, if CONFIG_ZONE_DMA|DMA32 is enabled. And we need > >> describe these cases in document. Any corner case or exception need > >> be noted if we don't handle it in code. > >> > >> Caring about this very much because we have CI with existed test cases > >> to run on the system, and QA will check these manually too. Support > >> engineer need detailed document if anything special but happened. > >> Anything unclear or uncovered will be reported as bug to our kernel dev. > >> Guess your company do the similar thing like this. > >> > >> This crashkerne,high and crashkernel,low reservation is special if we > >> allow ,high, ,low existing in the same zone. Imagine on system with > >> CONFIG_ZONE_DMA|DMA32 disabled, people copy the crashkernel=512M,high > >> and crashkernel=128M,low from other system, and he could get > >> crash_res at [5G, 5G+512M], while crash_low_res at [6G, 6G+128M]. Guess > >> how they will judge us. > > > > OK, I got it. > > > >> > >>> > >>>> > >>>> I would suggest merging this series, Lei can add this corner case > >>>> handling on top. Since this is a newly added support, we don't have > >>>> to make it one step. Doing step by step can make reviewing easier. > >>>> > >>>>> + if (crash_low_size && reserve_crashkernel_low(crash_low_size)) { > >>>>> + memblock_phys_free(crash_base, crash_size); > >>>>> + return; > >>>>> + } > >>>>> + > >>>>> pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", > >>>>> crash_base, crash_base + crash_size, crash_size >> 20); > >>>>> > >>>>> @@ -135,6 +183,9 @@ static void __init reserve_crashkernel(void) > >>>>> * map. Inform kmemleak so that it won't try to access it. > >>>>> */ > >>>>> kmemleak_ignore_phys(crash_base); > >>>>> + if (crashk_low_res.end) > >>>>> + kmemleak_ignore_phys(crashk_low_res.start); > >>>>> + > >>>>> crashk_res.start = crash_base; > >>>>> crashk_res.end = crash_base + crash_size - 1; > >>>>> insert_resource(&iomem_resource, &crashk_res); > >>>>> -- > >>>>> 2.25.1 > >>>>> > >>>> > >>>> . > >>>> > >>> > >>> -- > >>> Regards, > >>> Zhen Lei > >>> > >> > >> . > >> > > > > -- > Regards, > Zhen Lei >