Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp779441pxb; Wed, 13 Apr 2022 12:09:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKIaqZvA14GEJKprt/F5F3c5W0jGbU9vcdYTJ299FgpW9W9tHEpS1kqTWecNrd+pm953l1 X-Received: by 2002:a05:6402:27d1:b0:419:1b02:4a04 with SMTP id c17-20020a05640227d100b004191b024a04mr44984604ede.218.1649876980991; Wed, 13 Apr 2022 12:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649876980; cv=none; d=google.com; s=arc-20160816; b=VWfi8dhXv6jMmdZsDaiZDpfCQxfdlncdeUct1qrXiTsdeNztl41e+oB0JF5Ikr+rig NS7VsP1P8GQWpqDl8qjipnL9N7nSmkugqjPkbjlLcQQpfE1xlEuG3ND548OGP3JqmY/o nzXVX3QZTeue5/3BIYJGLkoaG4ifyPXRNchkh3W7TgFF4T7rzUXw6kw+dSEK6ahVabD8 0NtFOzkhMDrDDvik+8oa6vd5FRdUsD62jAjuc6n7BYUQeWYcWsswLOVAoNm7jLEMviZc 9r3AOajjIEgyPYXOGjfA7rYzpefjBucms9hrOaq2NDqJ5jUDrF1Kb+L+E5eMzw+F4CMR JnXg== 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; bh=PhSA0skDLDRkp83q+rZHG30m7gNMS8TYFRoAU8kWcTc=; b=dAcjUUDuiY0ofSPEqXpPHFhxNMT35az19+h2Y9L0MxGpU4wqL88/w9ExOvT4eb+ngW ps7EpO0+hNENH/tVNYM5+yncP3ktzFN+PgBtXjXX0SzaXcRP5zG3+1wTB5eCdn4/vmVq DFnrZ3Eyaept7j3R05yjZh2QgEQ0F+BdmwVGYhdH7BODEzAIhHW7ioDaJOyElCV8MA2e uemw6SLLzAfMknLFB9Pcw9Rp8MGlJbvv34pB5y5KOYP0lQdDbm5g73MTgZzIno7Yst3E qJODuecLO/7JcqzCnX4n5UuBxhouYs/GcWMsF32GBMpPLFzAGCPlpFaqDPZTxiCUD6YQ B+dw== 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=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a1709061e8900b006e8969b8e90si474584ejj.598.2022.04.13.12.09.15; Wed, 13 Apr 2022 12:09:40 -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=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235515AbiDMQ4G (ORCPT + 99 others); Wed, 13 Apr 2022 12:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbiDMQ4F (ORCPT ); Wed, 13 Apr 2022 12:56:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C5D68301 for ; Wed, 13 Apr 2022 09:53:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4D70D61E71 for ; Wed, 13 Apr 2022 16:53:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B77CBC385A3; Wed, 13 Apr 2022 16:53:41 +0000 (UTC) Date: Wed, 13 Apr 2022 17:53:38 +0100 From: Catalin Marinas To: Guanghui Feng Cc: will@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, baolin.wang@linux.alibaba.com Subject: Re: [PATCH RFC v1] arm64: mm: change mem_map to use block/section mapping with crashkernel Message-ID: References: <1649754476-8713-1-git-send-email-guanghuifeng@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1649754476-8713-1-git-send-email-guanghuifeng@linux.alibaba.com> X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, Apr 12, 2022 at 05:07:56PM +0800, Guanghui Feng wrote: > There are many changes and discussions: > commit 031495635b46 > commit 1a8e1cef7603 > commit 8424ecdde7df > commit 0a30c53573b0 > commit 2687275a5843 > > When using DMA/DMA32 zone and crashkernel, disable rodata full and kfence, > mem_map will use non block/section mapping(for crashkernel requires to shrink > the region in page granularity). But it will degrade performance when doing > larging continuous mem access in kernel(memcpy/memmove, etc). > > This patch firstly do block/section mapping at mem_map, reserve crashkernel > memory. And then walking pagetable to split block/section mapping > to non block/section mapping [only] for crashkernel mem. We will accelerate > mem access about 10-20% performance improvement, and reduce the cpu dTLB miss > conspicuously on some platform with this optimization. Do you actually have some real world use-cases where this improvement matters? I don't deny that large memcpy over the kernel linear map may be slightly faster but where does this really matter? > +static void init_crashkernel_pmd(pud_t *pudp, unsigned long addr, > + unsigned long end, phys_addr_t phys, > + pgprot_t prot, > + phys_addr_t (*pgtable_alloc)(int), int flags) > +{ > + phys_addr_t map_offset; > + unsigned long next; > + pmd_t *pmdp; > + pmdval_t pmdval; > + > + pmdp = pmd_offset(pudp, addr); > + do { > + next = pmd_addr_end(addr, end); > + if (!pmd_none(*pmdp) && pmd_sect(*pmdp)) { > + phys_addr_t pte_phys = pgtable_alloc(PAGE_SHIFT); > + pmd_clear(pmdp); > + pmdval = PMD_TYPE_TABLE | PMD_TABLE_UXN; > + if (flags & NO_EXEC_MAPPINGS) > + pmdval |= PMD_TABLE_PXN; > + __pmd_populate(pmdp, pte_phys, pmdval); > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); The architecture requires us to do a break-before-make here, so pmd_clear(), TLBI, __pmd_populate() - in this order. And that's where it gets tricky, if the kernel happens to access this pmd range while it is unmapped, you'd get a translation fault. -- Catalin