Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp686984imn; Sat, 2 Jul 2022 04:09:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u0Os2DlvpMc5Xbp/vE8yHW6icR+1o+2APsk4iIbYBjnOKx/TdznzozpRWflDpBSHC9AaoZ X-Received: by 2002:a17:902:ec83:b0:16a:3029:a44 with SMTP id x3-20020a170902ec8300b0016a30290a44mr23735744plg.141.1656760167422; Sat, 02 Jul 2022 04:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656760167; cv=none; d=google.com; s=arc-20160816; b=Fh/mygNglaewcYpTerr64rQMiuIR8e6XXifc+Dczy0IP0Nsw2YMoWMfqchAtj07m/J 70EYMYoug2ivNN9//+t/b/N866BFnaETUpnGawrWVo3SHC2rWvtGhfineRY8LjmqYRpB Z1N/sc/XQ0G2L6iQEHb2Mtxu+U7fzCFCpWRL8Rd09UViKYbBQrSQEVndFG4BMb9UIMN3 o8ThsnqCwuVJ7pXyHIWd9TEpTz45eAlAPwCNKTrxv8UKBV+PgC46DiUlxXr9qiQcJOmR dPXkOnIvrWXdcVplDn4Xkx354XiUJIRmr2q/svEg7/igYXiVzzdRr+l2bUgwF1FtAjGF Boug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=58z7Nx43gpvNxRmUdXWtXlt1xY1JlGnGsfh5SUKFewA=; b=A48/zvCHT/+IiJQ0y2MHcYKU0+r1W7x1Gv0ax33iSgUt+DzA5aKmj+6WxRo6WF37Ue gXw1gGC8iLqYQjL7LAtoEbGEZVy8OgMkqWrzsuBntXFAzTgUAtjx6G6PQJVj9fAtmRdU +K/7CZ392RA9v4MMCr0/pXA7bim5AuH5bxdMj6wTbxsZ9/vk3aAGtFTJ0LBwR9twCPQh txLoVVxvgjfDEuQxt7rcenueDO1/vO03J5mdJxsuM62pIsIVczr2Sbxgp2Topi9dDw5D xEjvyADl2nC+j/QX+CxW+wd3L4/MtMhUVZtzmjNpnzFj5Gn7MCpu0DS4bZgtUpxTfOv3 ZrWg== 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=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lj14-20020a17090b344e00b001cbbd85faa9si8664072pjb.20.2022.07.02.04.09.10; Sat, 02 Jul 2022 04:09:27 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbiGBKsp (ORCPT + 99 others); Sat, 2 Jul 2022 06:48:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbiGBKso (ORCPT ); Sat, 2 Jul 2022 06:48:44 -0400 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53AA1AE6F for ; Sat, 2 Jul 2022 03:48:42 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=guanghuifeng@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0VI6ToP3_1656758915; Received: from 30.39.96.230(mailfrom:guanghuifeng@linux.alibaba.com fp:SMTPD_---0VI6ToP3_1656758915) by smtp.aliyun-inc.com; Sat, 02 Jul 2022 18:48:37 +0800 Message-ID: <6dc308db-3685-4df5-506a-71f9e3794ec8@linux.alibaba.com> Date: Sat, 2 Jul 2022 18:48:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3] arm64: mm: fix linear mapping mem access performance degradation To: Catalin Marinas Cc: baolin.wang@linux.alibaba.com, will@kernel.org, akpm@linux-foundation.org, david@redhat.com, jianyong.wu@arm.com, james.morse@arm.com, quic_qiancai@quicinc.com, christophe.leroy@csgroup.eu, jonathan@marek.ca, mark.rutland@arm.com, thunder.leizhen@huawei.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, rppt@kernel.org, geert+renesas@glider.be, ardb@kernel.org, linux-mm@kvack.org, yaohongbo@linux.alibaba.com, alikernel-developer@linux.alibaba.com References: <1656586222-98555-1-git-send-email-guanghuifeng@linux.alibaba.com> From: "guanghui.fgh" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 Thanks. 在 2022/7/2 1:24, Catalin Marinas 写道: > On Thu, Jun 30, 2022 at 06:50:22PM +0800, Guanghui Feng wrote: >> +static void init_pmd_remap(pud_t *pudp, unsigned long addr, unsigned long end, >> + phys_addr_t phys, pgprot_t prot, >> + phys_addr_t (*pgtable_alloc)(int), int flags) >> +{ >> + unsigned long next; >> + pmd_t *pmdp; >> + phys_addr_t map_offset; >> + 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); > > This doesn't follow the architecture requirements for "break before > make" when changing live page tables. While it may work, it risks > triggering a TLB conflict abort. The correct sequence normally is: > > pmd_clear(); > flush_tlb_kernel_range(); > __pmd_populate(); > > However, do we have any guarantees that the kernel doesn't access the > pmd range being unmapped temporarily? The page table itself might live > in one of these sections, so set_pmd() etc. can get a translation fault. Thanks. 1. When reserving and remapping mem, there is only one boot cpu running, no other cpu/thread/process running. At the same time, only the boot cpu remap and modify linear mem mapping when there is no cpu access the same linear mapped mem(the boot cpu is rebuilding it, and other cpu have't been booted). 2.Because the kernel image and linear mem mapping are splited in two method: map_kernel and map_mem. When rebuilding the linear mem mapping(mapped by map_mem), there is no effect to the kernle image mapping. As a result, I thins there is no effect to the linear mem mapping and kernel image mapping. >