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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81921C433EF for ; Sat, 2 Jul 2022 10:12:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C31D6B0071; Sat, 2 Jul 2022 06:12:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 372756B0073; Sat, 2 Jul 2022 06:12:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 262046B0074; Sat, 2 Jul 2022 06:12:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 151896B0071 for ; Sat, 2 Jul 2022 06:12:43 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D2EB621311 for ; Sat, 2 Jul 2022 10:12:42 +0000 (UTC) X-FDA: 79641745764.27.8330F4C Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf02.hostedemail.com (Postfix) with ESMTP id DF10C8004D for ; Sat, 2 Jul 2022 10:12:40 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R231e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=guanghuifeng@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0VI6PZke_1656756754; Received: from 30.39.96.230(mailfrom:guanghuifeng@linux.alibaba.com fp:SMTPD_---0VI6PZke_1656756754) by smtp.aliyun-inc.com; Sat, 02 Jul 2022 18:12:35 +0800 Message-ID: <0bcb98ed-0e35-7242-377a-fee4eb751452@linux.alibaba.com> Date: Sat, 2 Jul 2022 18:12:33 +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 ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of guanghuifeng@linux.alibaba.com designates 115.124.30.44 as permitted sender) smtp.mailfrom=guanghuifeng@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656756762; h=from:from:sender: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=9OtGNyEso0/z4oT9v8AMmqSlcnpF7RVLFkKA59Stsbs=; b=tc1ijrBi302/taKwddXSSLc5FfAiFrVGPsmze3/mSG96hmYrO1whl/xycnkpmdRh/8piB1 1+VB9F55ZFrqVXibVhv4gX89JunUybnedGm3Z00w3KAksFaFxGuOYmxvY/xrFeBnHznuu5 nAEBEDqXdGvUkLtGXG1UuhhZDffvHlk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656756762; a=rsa-sha256; cv=none; b=hpeAr74FvBS7F78R8gtmLWidmxD/zGeUDnD8GJIB47VlIQZAeKlAPxEQ9kfWAAGxDqAR5M U1J2eWgojbC/oMITCeNOvMvw+P8p+wPDqhGIEonRtyazrAms3cB8otj4kuvTiQAji7LqHr dwCz3smw6bSjk1eY4iLlrOFvQepnCcU= X-Stat-Signature: 1a4thtcxuhj59z5u1s9aniemtzrhwzz7 X-Rspamd-Queue-Id: DF10C8004D Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of guanghuifeng@linux.alibaba.com designates 115.124.30.44 as permitted sender) smtp.mailfrom=guanghuifeng@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1656756760-114529 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. I'll follow this. I'll resend the path as soon as possible.