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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4314C433EF for ; Wed, 30 Mar 2022 06:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242861AbiC3Gq7 (ORCPT ); Wed, 30 Mar 2022 02:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238754AbiC3Gq5 (ORCPT ); Wed, 30 Mar 2022 02:46:57 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A99E7EB3B for ; Tue, 29 Mar 2022 23:45:11 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KSxhJ4N2LzDq8M; Wed, 30 Mar 2022 14:42:56 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 30 Mar 2022 14:45:09 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.21; Wed, 30 Mar 2022 14:45:09 +0800 Message-ID: Date: Wed, 30 Mar 2022 14:45:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 From: Kefeng Wang Subject: Re: [PATCH 1/2] arm64: mm: Do not defer reserve_crashkernel() if only ZONE_DMA32 To: Vijay Balakrishna , Catalin Marinas , Will Deacon , , CC: Pasha Tatashin , References: <20220325055315.25671-1-wangkefeng.wang@huawei.com> <9e8f32c4-1198-dca5-915f-0b31ce1436b4@linux.microsoft.com> Content-Language: en-US In-Reply-To: <9e8f32c4-1198-dca5-915f-0b31ce1436b4@linux.microsoft.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggeme708-chm.china.huawei.com (10.1.199.104) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/3/30 6:29, Vijay Balakrishna wrote: > > > On 3/24/2022 10:53 PM, Kefeng Wang wrote: >> The kernel could be benifit due to BLOCK_MAPPINGS, see commit >> 031495635b46 ("arm64: Do not defer reserve_crashkernel() for >> platforms with no DMA memory zones"), if there is only with >> ZONE_DMA32, we could set arm64_dma_phys_limit to max_zone_phys(32) >> earlier in arm64_memblock_init(), then we will benifit too. > > Thanks for noticing platforms with just ZONE_DMA32 config can also > benefit BLOCK_MAPPINGS.  I assume you have access to one where you > notice the difference with proposed changes and able to test.  I did > test proposed changes on SoC we use with IOMMU (no ZONE_DMA configs > enabled). I backported your patches into 5.10 and tested(unixbench will benifit due to block mapping, only with DMA32 and rodata=false) > > Nits -- > - benifit -> benefit > - consider making commit message clear, "then we will.." seems you are > referring to platforms with just ZONE_DMA32 config enabled > - to reflect new change consider updating comment added in commit > 031495635b46 Thanks for your reviewing,  will update and test with upstream. > >> >> Cc: Vijay Balakrishna >> Cc: Pasha Tatashin >> Cc: Will Deacon >> Signed-off-by: Kefeng Wang > > Reviewed-by: Vijay Balakrishna > >> --- >>   arch/arm64/mm/init.c | 18 ++++++++++-------- >>   arch/arm64/mm/mmu.c  |  6 ++---- >>   2 files changed, 12 insertions(+), 12 deletions(-) >> >> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c >> index 8ac25f19084e..9dded8779d72 100644 >> --- a/arch/arm64/mm/init.c >> +++ b/arch/arm64/mm/init.c >> @@ -157,14 +157,14 @@ static phys_addr_t __init >> max_zone_phys(unsigned int zone_bits) >>       return min(zone_mask, memblock_end_of_DRAM() - 1) + 1; >>   } >>   +phys_addr_t __ro_after_init dma32_phys_limit; Will make it static, suggested by Florian >>   static void __init zone_sizes_init(unsigned long min, unsigned long >> max) >>   { >>       unsigned long max_zone_pfns[MAX_NR_ZONES]  = {0}; >> -    unsigned int __maybe_unused acpi_zone_dma_bits; >> -    unsigned int __maybe_unused dt_zone_dma_bits; >> -    phys_addr_t __maybe_unused dma32_phys_limit = max_zone_phys(32); >> - >>   #ifdef CONFIG_ZONE_DMA >> +    unsigned int acpi_zone_dma_bits; >> +    unsigned int dt_zone_dma_bits; >> + >>       acpi_zone_dma_bits = fls64(acpi_iort_dma_get_max_cpu_address()); >>       dt_zone_dma_bits = fls64(of_dma_get_max_cpu_address(NULL)); >>       zone_dma_bits = min3(32U, dt_zone_dma_bits, acpi_zone_dma_bits); >> @@ -173,8 +173,6 @@ static void __init zone_sizes_init(unsigned long >> min, unsigned long max) >>   #endif >>   #ifdef CONFIG_ZONE_DMA32 >>       max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit); >> -    if (!arm64_dma_phys_limit) >> -        arm64_dma_phys_limit = dma32_phys_limit; >>   #endif >>       max_zone_pfns[ZONE_NORMAL] = max; >>   @@ -336,8 +334,12 @@ void __init arm64_memblock_init(void) >>         early_init_fdt_scan_reserved_mem(); >>   -    if (!IS_ENABLED(CONFIG_ZONE_DMA) && >> !IS_ENABLED(CONFIG_ZONE_DMA32)) >> +    dma32_phys_limit = max_zone_phys(32); >> +    if (!IS_ENABLED(CONFIG_ZONE_DMA)) { >> +        if (IS_ENABLED(CONFIG_ZONE_DMA32)) >> +            arm64_dma_phys_limit = dma32_phys_limit; >>           reserve_crashkernel(); >> +    } >>         high_memory = __va(memblock_end_of_DRAM() - 1) + 1; >>   } >> @@ -385,7 +387,7 @@ void __init bootmem_init(void) >>        * request_standard_resources() depends on crashkernel's memory >> being >>        * reserved, so do it here. >>        */ >> -    if (IS_ENABLED(CONFIG_ZONE_DMA) || IS_ENABLED(CONFIG_ZONE_DMA32)) >> +    if (IS_ENABLED(CONFIG_ZONE_DMA)) >>           reserve_crashkernel(); >>         memblock_dump_all(); >> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c >> index 626ec32873c6..23734481318a 100644 >> --- a/arch/arm64/mm/mmu.c >> +++ b/arch/arm64/mm/mmu.c >> @@ -529,8 +529,7 @@ static void __init map_mem(pgd_t *pgdp) >>     #ifdef CONFIG_KEXEC_CORE >>       if (crash_mem_map) { >> -        if (IS_ENABLED(CONFIG_ZONE_DMA) || >> -            IS_ENABLED(CONFIG_ZONE_DMA32)) >> +        if (IS_ENABLED(CONFIG_ZONE_DMA)) >>               flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; >>           else if (crashk_res.end) >>               memblock_mark_nomap(crashk_res.start, >> @@ -571,8 +570,7 @@ static void __init map_mem(pgd_t *pgdp) >>        * through /sys/kernel/kexec_crash_size interface. >>        */ >>   #ifdef CONFIG_KEXEC_CORE >> -    if (crash_mem_map && >> -        !IS_ENABLED(CONFIG_ZONE_DMA) && >> !IS_ENABLED(CONFIG_ZONE_DMA32)) { >> +    if (crash_mem_map && !IS_ENABLED(CONFIG_ZONE_DMA)) { >>           if (crashk_res.end) { >>               __map_memblock(pgdp, crashk_res.start, >>                          crashk_res.end + 1, > .