Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3648553iog; Tue, 21 Jun 2022 03:07:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u3LA3gKMtMZ+5EvqhWdjhCd8PlUmQq27tRMEkFCryab9rLCInpml82NWkhqjuHDty0FQ3V X-Received: by 2002:a17:907:3e1d:b0:711:dc92:e308 with SMTP id hp29-20020a1709073e1d00b00711dc92e308mr24703889ejc.235.1655806055616; Tue, 21 Jun 2022 03:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655806055; cv=none; d=google.com; s=arc-20160816; b=bUDc1u10QEtvKJejFGBfqL7x34Q6hQ2IZ3Qvv3E0p+y1aUbmM34po8516DAp39A5cF ULrqBU/kCmEzpsf0nTq5AC3WzczcnjgsmDR5m0iSkRxiQraWgYhvoY+XTzSfCeQgOPKp xXjduw9KRDRTajnNLvykGlx4Ri3vC3biC88EJlGr+vTUo3Qbp/SW4muk6Us90TuLqfGV 153RrQzQZ2mQQCI+pHalv8TrN7v2ykn7eVXxVFKIbeGFknaa/EUNb+xqSO0Df6h9/3xt +6nlTLEUs6GjWbVbCe8CN/EiA8SRGw+N295Qooq7QwyBX0APY5QSiqCWJK0g51m/GtlZ KUsA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1/6eJspt/AVzBoz5mItJSgxql1F5f7nb/z62lzZC//s=; b=RY52VPcAICCq69BDk6KqWPKVLLBhhAfhkf0EazOFR1WD7bZyJY8APoz6aTmsuc4/5G BDYOradNidXEl0JbXifKnjyyCErI9egdadllKtkK5jJNHKabUcNwV0rwZwfWpzwhNs8p FAHoCDnR7lljEpRN1IjIIPekmMe2cPLH2ECv2+TUMUBGkA4WI+kq7dvYuMg0Pcn0ERht aOcJQ//vXjON8qYy/7WYgqH43h0TbcsfqS2MDhGTdofQx52j9xVxrF6akOZAZNN1VsLn renTEj4SRFXxQ8I0fgRWwOHx8CMjcrWSq3XR0Fwrou+wmhXIVXdZBGSf52eoI3HI6KNf KQ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h92MBdQ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk8-20020a1709077f8800b0071de916293csi12233132ejc.617.2022.06.21.03.07.09; Tue, 21 Jun 2022 03:07:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h92MBdQ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348775AbiFUJ3R (ORCPT + 99 others); Tue, 21 Jun 2022 05:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347043AbiFUJ2O (ORCPT ); Tue, 21 Jun 2022 05:28:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6E3B7300 for ; Tue, 21 Jun 2022 02:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655803670; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1/6eJspt/AVzBoz5mItJSgxql1F5f7nb/z62lzZC//s=; b=h92MBdQ60YyfZtTbeTYIsHZWShRLkjKqTjvj2+fhkEzm8r35rgkMIsdzQo3u8IA9caCYqf 5pxhNmMkM6OnewRaPK1fLodCkqUaE5yz1EyXfayLo9+RONtmB/JSoZisruRS5D5+BQzVE2 ixudyhNSW9jUk8rYMuFumpZtVxYWyig= 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-2-MQve9TMLMYyX3G1gVtvhfA-1; Tue, 21 Jun 2022 05:27:47 -0400 X-MC-Unique: MQve9TMLMYyX3G1gVtvhfA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 539A280B70F; Tue, 21 Jun 2022 09:27:46 +0000 (UTC) Received: from localhost (ovpn-12-183.pek2.redhat.com [10.72.12.183]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A52A540CFD0A; Tue, 21 Jun 2022 09:27:44 +0000 (UTC) Date: Tue, 21 Jun 2022 17:27:40 +0800 From: Baoquan He To: Kefeng Wang Cc: Zhen Lei , Catalin Marinas , Ard Biesheuvel , Mark Rutland , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Eric Biederman , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Dave Young , Vivek Goyal , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Will Deacon , linux-arm-kernel@lists.infradead.org, Jonathan Corbet , linux-doc@vger.kernel.org, Randy Dunlap , Feng Zhou , Chen Zhou , John Donnelly , Dave Kleikamp , liushixin Subject: Re: [PATCH 5/5] arm64: kdump: Don't defer the reservation of crash high memory Message-ID: References: <20220613080932.663-1-thunder.leizhen@huawei.com> <20220613080932.663-6-thunder.leizhen@huawei.com> <3f66323d-f371-b931-65fb-edfae0f01c88@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3f66323d-f371-b931-65fb-edfae0f01c88@huawei.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_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 06/21/22 at 02:24pm, Kefeng Wang wrote: > > On 2022/6/21 13:33, Baoquan He wrote: > > Hi, > > > > On 06/13/22 at 04:09pm, Zhen Lei wrote: > > > If the crashkernel has both high memory above DMA zones and low memory > > > in DMA zones, kexec always loads the content such as Image and dtb to the > > > high memory instead of the low memory. This means that only high memory > > > requires write protection based on page-level mapping. The allocation of > > > high memory does not depend on the DMA boundary. So we can reserve the > > > high memory first even if the crashkernel reservation is deferred. > > > > > > This means that the block mapping can still be performed on other kernel > > > linear address spaces, the TLB miss rate can be reduced and the system > > > performance will be improved. > > Ugh, this looks a little ugly, honestly. > > > > If that's for sure arm64 can't split large page mapping of linear > > region, this patch is one way to optimize linear mapping. Given kdump > > setting is necessary on arm64 server, the booting speed is truly > > impacted heavily. > > Is there some conclusion or discussion that arm64 can't split large page > mapping? Yes, please see below commit log. commit d27cfa1fc823 ("arm64: mm: set the contiguous bit for kernel mappings where appropriate") > > Could the crashkernel reservation (and Kfence pool) be splited dynamically? For crashkernel region, we have arch_kexec_protect_crashkres() to secure the region, and crash_shrink_memory() could be called to shrink it. While crahshkernel region could be crossig part of a block mapping or section mapping and the mapping need be splitted, that will cause TLB conflicts. > > I found Mark replay "arm64: remove page granularity limitation from > KFENCE"[1], > > ? "We also avoid live changes from block<->table mappings, since the > ? archtitecture gives us very weak guarantees there and generally requires > ? a Break-Before-Make sequence (though IIRC this was tightened up > ? somewhat, so maybe going one way is supposed to work). Unless it's > ? really necessary, I'd rather not split these block mappings while > ? they're live." > > Hi Mark and Catalin,? could you give some comment,? many thanks. > > [1] https://lore.kernel.org/lkml/20210920101938.GA13863@C02TD0UTHF1T.local/T/#m1a7f974593f5545cbcfc0d21560df4e7926b1381 > > > > > > However, I would suggest letting it as is with below reasons: > > > > 1) The code will complicate the crashkernel reservatoin code which > > is already difficult to understand. > > 2) It can only optimize the two cases, first is CONFIG_ZONE_DMA|DMA32 > > disabled, the other is crashkernel=,high is specified. While both > > two cases are corner case, most of systems have CONFIG_ZONE_DMA|DMA32 > > enabled, and most of systems have crashkernel=xM which is enough. > > Having them optimized won't bring benefit to most of systems. > > 3) Besides, the crashkernel=,high can be handled earlier because > > arm64 alwasys have memblock.bottom_up == false currently, thus we > > don't need worry arbout the lower limit of crashkernel,high > > reservation for now. If memblock.bottom_up is set true in the future, > > this patch doesn't work any more. > > > > > > ... > > crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, > > crash_base, crash_max); > > > > So, in my opinion, we can leave the current NON_BLOCK|SECT mapping as > > is caused by crashkernel reserving, since no regression is brought. > > And meantime, turning to check if there's any way to make the contiguous > > linear mapping and later splitting work. The patch 4, 5 in this patchset > > doesn't make much sense to me, frankly speaking. > > > > Thanks > > Baoquan >