From patchwork Wed May 22 06:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bang Li X-Patchwork-Id: 13670453 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 EBB61C25B79 for ; Wed, 22 May 2024 06:13:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A1456B0083; Wed, 22 May 2024 02:13:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 577506B0085; Wed, 22 May 2024 02:13:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43E866B0088; Wed, 22 May 2024 02:13:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 229026B0083 for ; Wed, 22 May 2024 02:13:29 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D6FEB1A12F2 for ; Wed, 22 May 2024 06:13:28 +0000 (UTC) X-FDA: 82145014896.08.D284416 Received: from out0-219.mail.aliyun.com (out0-219.mail.aliyun.com [140.205.0.219]) by imf17.hostedemail.com (Postfix) with ESMTP id 97ED240027 for ; Wed, 22 May 2024 06:13:26 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=antgroup.com header.s=default header.b=n4XTxQW7; spf=pass (imf17.hostedemail.com: domain of libang.li@antgroup.com designates 140.205.0.219 as permitted sender) smtp.mailfrom=libang.li@antgroup.com; dmarc=pass (policy=quarantine) header.from=antgroup.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716358407; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NpGCr7uMs7nN0Q+sV09/b3UAtSy1OaurTOZpW7g+KIc=; b=PafHkqG390d85HSm7kLL7uw1VnYdmBvlaSl9DS2vDEJDszHqyUEmFyCNb17h6iyV8JE3NM YaiLqoOoCw+cOoRy9jTMZb6KwKoGiTasJS2sAKQDsc8Q2BzPXlUgs9EpUPL4WdTLTTgvJ6 xoEBfIpZOMymbEXSlT6lemugJXlAHD8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=antgroup.com header.s=default header.b=n4XTxQW7; spf=pass (imf17.hostedemail.com: domain of libang.li@antgroup.com designates 140.205.0.219 as permitted sender) smtp.mailfrom=libang.li@antgroup.com; dmarc=pass (policy=quarantine) header.from=antgroup.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716358407; a=rsa-sha256; cv=none; b=Mmpy0h1xkTCroxqhTIAHLd/yelshs1e4NCl0HZOxgjStlyCCd/LuPNZBHaFKDOe3xE0kh6 QqptEJa0eTXpk2Ns7NlHEftrPzR2d9O2Xw/HJ8p1SADJRP9vsXtw91PFfq+GYDE+T2hP99 Ay4yWC+fTYebnOvn0oVA2RTMQnmudFI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1716358403; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=NpGCr7uMs7nN0Q+sV09/b3UAtSy1OaurTOZpW7g+KIc=; b=n4XTxQW7iyJ2SH9oAXmAdIPlldLlTIEYLs4dtnbe8LenqEk2V1X7j23n/HMbRoHzcpmmbsVKN39V/YJUbayd6Wtn6A/gUQcsTv7n8q8A/GOnKL/MKRXb2L8cKedl7uBsXBGFZpbJpCea3sQsN7MDu6Ro0aPspWqUeFZI+/ui0XU= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045002061;MF=libang.li@antgroup.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---.XjzNVuG_1716358401; Received: from localhost(mailfrom:libang.li@antgroup.com fp:SMTPD_---.XjzNVuG_1716358401) by smtp.aliyun-inc.com; Wed, 22 May 2024 14:13:22 +0800 From: "Bang Li" To: akpm@linux-foundation.org, chenhuacai@kernel.org, tsbogend@alpha.franken.de, paul.walmsley@sifive.com, palmer@dabbelt.com, chris@zankel.net, jcmvbkbc@gmail.com Cc: , , , , , , , , "Bang Li" Subject: [PATCH v4 1/3] mm: Add update_mmu_tlb_range() Date: Wed, 22 May 2024 14:12:02 +0800 Message-Id: <20240522061204.117421-2-libang.li@antgroup.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240522061204.117421-1-libang.li@antgroup.com> References: <20240522061204.117421-1-libang.li@antgroup.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 97ED240027 X-Stat-Signature: c78eu89czbqr6mtneetykmhwzerhkhq4 X-HE-Tag: 1716358406-815111 X-HE-Meta: U2FsdGVkX18SueEOfiiCIflAVVh4SMTWTOpeSRjZjBLCVSDsRS0qbrLENGE+8b4Ont4CfDHurxS5QK/hf9sfhrtuk/ovn9b+Y2/6zrkSTu4de7PjF098ep+y9fOnSLk6T4HHt5P5qNXvNbQMjwcIUGNa2upMTOAYQm+sfPMMnddE24I7LHe+jEJcOBd7g7I86+FPHkrUJUP7E3vRy84iRLdLg7pkk2dfJc6pWdQMtt0JLKIE5oNpGK6Rbv+U3ujsYQMhE9vW2hC/RzDkWQcRJm/YPpd98q3prxLDdtpIdI+amNgLcB3bCuwaiywvDE1xGJZyqVSR/fBvEMrpI00OgVlhnul7fpXHZB9Mb+5cu6CvMw2fmK2xsGfj91QTjGha7NBQfUGGKk40Fp2Rn1bvPyqPvHpn/MMsRZS1RcX7B1jfI54gjw12lq36+a396HYjjDffEJaCfewxIt+PVSOJ0AP1jaeQC+uRHY7GeyBLTsZBHGZPEAse45Xb2jV3eGm1Hq4Wxl7juCyeR8//EdkWxaLq2D/HBwZKUWBXPx7vwzXrCoy+SZwNb16qdnEapVknalHJP+/u3i0lVZ8vAAAoyiC7XT/3q6K0FRqFlJqgS1JcjOhZRYhQdxjoZplLMqqAdfEvUNWes7zVXCJmK8EPPh25aaMHqbrRU5xFD9XDtYkQMvJV2iEeVMyhi4+f9togl3EEC2wwFxfwrHMNHDCDZrc1EC6YavH+tQSb1UFm6F404EKCq64uZRKRn1OiRuWq6p2p5ZqxILQ+y6upzeDGiTbXYfXj6fLYd4cD3KJNlkWe1o/3B3YfJardNIpuklp9T3qE6RaTq8m5OS/I7F+HOhN1qDMUVuFmvG1tuNdaX7tcpCfUMZJ2+MvMNVMQSxALidYSFRajSAA5Z/TAHzV5TrTR3/CnrAdDmylZfGJMP7eKfUhmilR37zzI3UO14n/bm9OxLZcLZ3XfEHTRnLu lcfOqxb6 gF5+lJIJc96ylOxhKuaqmv2WUS3pq4nZKy1SHQIbHGUaul0PkARlFKMpdNxuUpoaitFb/FFkEKbPFYkCiySYGAzX2rSBD8QfkMpF4i5tM+GALeO1V1MARnyiz1oxKHP6X3eA68zFmqqiaoq/4GFG9gSgLLh5ToHhh8PztmHbNPBVdRFUhqJ5Jlfe71FZESszZYyoCd8XPjJvdIkYvX+IDQjF0beewpGQSamFQR3DiH1qz95xsNedKe1MbFPTvaUcFnwK62QH/L4NdhyZZPVTTrL7EJX6/kR63jpJuCuV5cqGVqjohDYlYXZVP//2QAxwZlVHpcQKipXDDE1u8TznhzlTx+z8s1cjIYZxWg9HV0Tdg5CIBoYKV7SHm9Q== 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: List-Subscribe: List-Unsubscribe: Added update_mmu_tlb_range(), we can batch update tlb of an address range. Signed-off-by: Bang Li --- arch/loongarch/include/asm/pgtable.h | 2 ++ arch/mips/include/asm/pgtable.h | 2 ++ arch/riscv/include/asm/pgtable.h | 2 ++ arch/xtensa/include/asm/pgtable.h | 3 +++ arch/xtensa/mm/tlb.c | 6 ++++++ include/linux/pgtable.h | 7 +++++++ 6 files changed, 22 insertions(+) diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index af3acdf3481a..5ccc2a3a6f7a 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -469,6 +469,8 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf, #define __HAVE_ARCH_UPDATE_MMU_TLB #define update_mmu_tlb update_mmu_cache +#define update_mmu_tlb_range(vma, addr, ptep, nr) \ + update_mmu_cache_range(NULL, vma, addr, ptep, nr) static inline void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index e27a4c83c548..0891ad7d43b6 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -596,6 +596,8 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf, #define __HAVE_ARCH_UPDATE_MMU_TLB #define update_mmu_tlb update_mmu_cache +#define update_mmu_tlb_range(vma, address, ptep, nr) \ + update_mmu_cache_range(NULL, vma, address, ptep, nr) static inline void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 55a7c3ec246b..4630815b0253 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -491,6 +491,8 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf, #define __HAVE_ARCH_UPDATE_MMU_TLB #define update_mmu_tlb update_mmu_cache +#define update_mmu_tlb_range(vma, addr, ptep, nr) \ + update_mmu_cache_range(NULL, vma, addr, ptep, nr) static inline void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h index 9a7e5e57ee9a..436158bd9030 100644 --- a/arch/xtensa/include/asm/pgtable.h +++ b/arch/xtensa/include/asm/pgtable.h @@ -413,6 +413,9 @@ typedef pte_t *pte_addr_t; void update_mmu_tlb(struct vm_area_struct *vma, unsigned long address, pte_t *ptep); #define __HAVE_ARCH_UPDATE_MMU_TLB +void update_mmu_tlb_range(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep, unsigned int nr); +#define update_mmu_tlb_range update_mmu_tlb_range #endif /* !defined (__ASSEMBLY__) */ diff --git a/arch/xtensa/mm/tlb.c b/arch/xtensa/mm/tlb.c index d8b60d6e50a8..05efba86b870 100644 --- a/arch/xtensa/mm/tlb.c +++ b/arch/xtensa/mm/tlb.c @@ -169,6 +169,12 @@ void update_mmu_tlb(struct vm_area_struct *vma, local_flush_tlb_page(vma, address); } +void update_mmu_tlb_range(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep, unsigned int nr) +{ + local_flush_tlb_range(vma, address, address + PAGE_SIZE * nr); +} + #ifdef CONFIG_DEBUG_TLB_SANITY static unsigned get_pte_for_vaddr(unsigned vaddr) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 18019f037bae..17d1caee39ab 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -729,6 +729,13 @@ static inline void clear_full_ptes(struct mm_struct *mm, unsigned long addr, * fault. This function updates TLB only, do nothing with cache or others. * It is the difference with function update_mmu_cache. */ +#ifndef update_mmu_tlb_range +static inline void update_mmu_tlb_range(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep, unsigned int nr) +{ +} +#endif + #ifndef __HAVE_ARCH_UPDATE_MMU_TLB static inline void update_mmu_tlb(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)