Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1954022rwl; Fri, 24 Mar 2023 19:12:40 -0700 (PDT) X-Google-Smtp-Source: AKy350ZU4fhL8inDMZb8CELaKoEo+TNQMrsg3KhFxf+MKd31+7qL9HRwUbpe96738g9O1f52Rd7W X-Received: by 2002:a17:906:d207:b0:92b:b4d9:3f07 with SMTP id w7-20020a170906d20700b0092bb4d93f07mr4624383ejz.14.1679710359872; Fri, 24 Mar 2023 19:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679710359; cv=none; d=google.com; s=arc-20160816; b=fa209UzqdiLptgDrB+nbUc3Zcrit51IgBjB6RidUT1hFAB1aVq+hHdlQeFc4W4OJYI TopvInS0QOg2Kg7o8DFI7CMreocpU8PZ4390oyZwYxZFa77Nwc49AoroqQirJOpfBvQA S/NUBmKl0Yvz98FJGOUhf4n4X9AQGEcHGG2ng7NXLTD7z9Y5wubDAc29W2BZjkRV9LXD pPU6TTTfDVEhGH47ItwHw6HqE9GMGWQ36G9+WDNI1lbKRo+gh4Gh18zQOwy7RN9RUCdn ob7RSXefpSpetI+8nPqB8IiJeYzoJ2BY61IOu/bAYHOzymjhBleIh/rlpJY3XQ+0N4Ly j6Cw== 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=Lm7fWgen0niTew7VsyqBPJNF079vNT/+PnEagavK/W0=; b=WJBnUfK2QxtcbdzPNQJVJutAAo8csyfoOYsu4CLRkM3bLg7toW0NkrLpU3nAKM8V0W JK/4X6o5V+oLEYdFJwdKgJ9JG1p3lqHpnxhvXuxTKn9cFhKOoDo/UJ9U/KQaaplh75FQ nzqVD6QJLgrBD8vBzXO47aR1cyh2gHPT2zuosMUirZJzKvC91T3EnsHhwkTqzht8LsCb t/ufxQKlMC5YscmOrMe7bR4qQL1eecB2nOnH0+hiIJcelgFcgmdqIoZL3IGkBgNCIaOo +FIx6po5Qa2q1irnrbT0lMLnNXBhr6C9WlwYo3J3htZA7V9fKwc4DWIo+AHS+fdkhK2j Gd0w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a1709066b1000b009334da7a280si16298132ejr.693.2023.03.24.19.12.16; Fri, 24 Mar 2023 19:12:39 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbjCYB4r (ORCPT + 99 others); Fri, 24 Mar 2023 21:56:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjCYB4q (ORCPT ); Fri, 24 Mar 2023 21:56:46 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C19459EFE for ; Fri, 24 Mar 2023 18:56:44 -0700 (PDT) Received: from dggpemm500006.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Pk2FB6ZRYzKtMk; Sat, 25 Mar 2023 09:54:22 +0800 (CST) Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Sat, 25 Mar 2023 09:56:19 +0800 Subject: Re: [PATCH 1/3] arm64: kdump : take off the protection on crashkernel memory region To: Baoquan He , CC: , , , , , , , References: <20230324131838.409996-1-bhe@redhat.com> <20230324131838.409996-2-bhe@redhat.com> From: "Leizhen (ThunderTown)" Message-ID: <550d6152-492c-7f00-4680-9164db04b8fc@huawei.com> Date: Sat, 25 Mar 2023 09:56:19 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20230324131838.409996-2-bhe@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.3 required=5.0 tests=NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 2023/3/24 21:18, Baoquan He wrote: > Problem: > ======= > On arm64, block and section mapping is supported to build page tables. > However, currently it enforces to take base page mapping for the whole > linear mapping if CONFIG_ZONE_DMA or CONFIG_ZONE_DMA32 is enabled and > crashkernel kernel parameter is set. This will cause longer time of the > linear mapping process during bootup and severe performance degradation > during running time. > > Root cause: > ========== > On arm64, crashkernel reservation relies on knowing the upper limit of > low memory zone because it needs to reserve memory in the zone so that > devices' DMA addressing in kdump kernel can be satisfied. However, the > upper limit of low memory on arm64 is variant. And the upper limit can > only be decided late till bootmem_init() is called [1]. > > And we need to map the crashkernel region with base page granularity when > doing linear mapping, because kdump needs to protect the crashkernel region > via set_memory_valid(,0) after kdump kernel loading. However, arm64 doesn't > support well on splitting the built block or section mapping due to some > cpu reststriction [2]. And unfortunately, the linear mapping is done before > bootmem_init(). > > To resolve the above conflict on arm64, the compromise is enforcing to > take base page mapping for the entire linear mapping if crashkernel is > set, and CONFIG_ZONE_DMA or CONFIG_ZONE_DMA32 is enabed. Hence > performance is sacrificed. > > Solution: > ========= > Comparing with the base page mapping for the whole linear region, it's > better to take off the protection on crashkernel memory region for the > time being because the anticipated stamping on crashkernel memory region > could only happen in a chance in one million, while the base page mapping > for the whole linear region is mitigating arm64 systems with crashkernel > set always. > > [1] > https://lore.kernel.org/all/YrIIJkhKWSuAqkCx@arm.com/T/#u > > [2] > https://lore.kernel.org/linux-arm-kernel/20190911182546.17094-1-nsaenzjulienne@suse.de/T/ > > Signed-off-by: Baoquan He > --- > arch/arm64/include/asm/kexec.h | 6 ------ > arch/arm64/kernel/machine_kexec.c | 20 -------------------- > 2 files changed, 26 deletions(-) > > diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h > index 559bfae26715..9ac9572a3bbe 100644 > --- a/arch/arm64/include/asm/kexec.h > +++ b/arch/arm64/include/asm/kexec.h > @@ -102,12 +102,6 @@ void cpu_soft_restart(unsigned long el2_switch, unsigned long entry, > > int machine_kexec_post_load(struct kimage *image); > #define machine_kexec_post_load machine_kexec_post_load > - > -void arch_kexec_protect_crashkres(void); > -#define arch_kexec_protect_crashkres arch_kexec_protect_crashkres > - > -void arch_kexec_unprotect_crashkres(void); > -#define arch_kexec_unprotect_crashkres arch_kexec_unprotect_crashkres > #endif > > #define ARCH_HAS_KIMAGE_ARCH > diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c > index ce3d40120f72..22da7fc1ff50 100644 > --- a/arch/arm64/kernel/machine_kexec.c > +++ b/arch/arm64/kernel/machine_kexec.c > @@ -268,26 +268,6 @@ void machine_crash_shutdown(struct pt_regs *regs) > pr_info("Starting crashdump kernel...\n"); > } > > -void arch_kexec_protect_crashkres(void) > -{ > - int i; > - > - for (i = 0; i < kexec_crash_image->nr_segments; i++) > - set_memory_valid( > - __phys_to_virt(kexec_crash_image->segment[i].mem), > - kexec_crash_image->segment[i].memsz >> PAGE_SHIFT, 0); > -} > - > -void arch_kexec_unprotect_crashkres(void) > -{ > - int i; > - > - for (i = 0; i < kexec_crash_image->nr_segments; i++) > - set_memory_valid( > - __phys_to_virt(kexec_crash_image->segment[i].mem), > - kexec_crash_image->segment[i].memsz >> PAGE_SHIFT, 1); > -} > - > #ifdef CONFIG_HIBERNATION > /* > * To preserve the crash dump kernel image, the relevant memory segments > Reviewed-by: Zhen Lei -- Regards, Zhen Lei