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) From patchwork Wed May 22 06:12:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bang Li X-Patchwork-Id: 13670454 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 59548C25B77 for ; Wed, 22 May 2024 06:13:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 419F76B0088; Wed, 22 May 2024 02:13:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37DB16B0089; Wed, 22 May 2024 02:13:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21CC46B008A; Wed, 22 May 2024 02:13:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id ECC896B0088 for ; Wed, 22 May 2024 02:13:30 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B11021C03BA for ; Wed, 22 May 2024 06:13:30 +0000 (UTC) X-FDA: 82145014980.23.7C247DA Received: from out0-209.mail.aliyun.com (out0-209.mail.aliyun.com [140.205.0.209]) by imf07.hostedemail.com (Postfix) with ESMTP id 6D8FC40016 for ; Wed, 22 May 2024 06:13:28 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=antgroup.com header.s=default header.b=LwysctnJ; dmarc=pass (policy=quarantine) header.from=antgroup.com; spf=pass (imf07.hostedemail.com: domain of libang.li@antgroup.com designates 140.205.0.209 as permitted sender) smtp.mailfrom=libang.li@antgroup.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716358408; 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=TlFp/9e3+paphJkYj5hBfGpalgoFCMsN0GnLIT6/eZ4=; b=09PLKuf13VzYYzJCLkSXMzs0ffPNv+jnoXXJgMhS/Mdan9bvoUhOLr5rKhdbS9NZY+TtFR YR+nMmTy9rPxDw6LULWtP7NFQg3SKdJthrA8hZ8Nf8JZyKXIcsghhdKrkPCq38EzafwjfN VayDje25H9pBw/Stiua2417j4fUdyng= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=antgroup.com header.s=default header.b=LwysctnJ; dmarc=pass (policy=quarantine) header.from=antgroup.com; spf=pass (imf07.hostedemail.com: domain of libang.li@antgroup.com designates 140.205.0.209 as permitted sender) smtp.mailfrom=libang.li@antgroup.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716358408; a=rsa-sha256; cv=none; b=uctL68XI3FgWxbQKd2QRsa5WyiDLDJR+AlQeE1ug3UfIPstgDZ2SQ6gVvrvzhvxIIRVcAT Ig38JfUzkizBIG09p7LEKQBRxB4br9Dz8Q/fF96/V6pCKKnFLoGhezUz1PMAQe2m0CrMXo Zr4ysIWs/NenR4qUPvokvHsVmuqJsDM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1716358405; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=TlFp/9e3+paphJkYj5hBfGpalgoFCMsN0GnLIT6/eZ4=; b=LwysctnJ1/b2rmEt9CJtG2f20irwsnxK53iCF3wFsBa4+94AqrP4dfAo1AlYvEqJGf2F6RKHTmYkE1tkDxrFWSr586tgBfVgpkM0+DycmrIh8fm2wUqrEnyqLEH04hWEL1E25Sj5yf2QbjLFY6zWBgixwGEObsBnQUR0hIIM+i0= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033070043001;MF=libang.li@antgroup.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---.XjzNVv6_1716358403; Received: from localhost(mailfrom:libang.li@antgroup.com fp:SMTPD_---.XjzNVv6_1716358403) by smtp.aliyun-inc.com; Wed, 22 May 2024 14:13:24 +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 2/3] mm: implement update_mmu_tlb() using update_mmu_tlb_range() Date: Wed, 22 May 2024 14:12:03 +0800 Message-Id: <20240522061204.117421-3-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-Rspamd-Queue-Id: 6D8FC40016 X-Stat-Signature: yi3zi7yk75am9kwy99454ekcmm1p11ek X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1716358408-877265 X-HE-Meta: U2FsdGVkX198z2gtzS8WJjdoN8WqvWVS7i89JxEXrkayTVZ9v+ik95U2T7WKD+PiyivRdXWAJshIkAVzgq5Pm+NP+F2SoGYRcvvkVdK3pG26qBkfdHI1u/9p5WtxHGE+Ng5kZQ5sWR9+DAmCEmDsgsgxSDNg6bDsSBcpMrn6cD18vM61iNkyHQFZBWI3DX36m5FNHUnrkGEw/36p6oKAoMLFvtv4B7ZQZEf8R/jy1OGnalfro3qk1h5uTIqM5SQhqJLBATd914YAIxNyGbSfxSrLOQXH1DPnVx5sHSNJhVVMLKC0XIoQ0H2FJe5EI8aFQ4Qy0buAoq3wzbiTmFsk9iphlhM+FRhNN3XpLJ6i9w49p738thatntrs+jqUIaSS2H1slPDo5vWLVe8M39cETYFNoNBfkPgH9bHL0YU/lvgjn770J76TNhuAFTZJdqBSNni54VGvL32I2oj2R/MLeNMz/jYkEg9qTlNykeQa2VhumfvUHuew19DqFAmx1A170HqGM0GB6I9J9Zi1SNjaTVN/9r134Ma+DT+3tgGDF3e+/bDYAU4gMRqzwLck+UZ6vvagGFLR1ijgVkC6f1a+qoc+H07jVtd92N8xSTIcax1pBiNSQ47RzT7HJqYHAKCrYL7QbwCvfdckYRaUVVrMYuRv5fcctypDyrXYIREQhlOSJ+C/BYKnFVWGzg/rGjDmfhKzoiUNZC5fVmscnaPVBnnnAjYCRv6mvlYwWgdCoqC6h3EyR433cbwGGmaaPa4RwDcg71qVBdE14sTmyhElYRurYylzbnU7oGT1EuH+fIbTWhg6gw3eM/xyp56g/gvntpxvqBikFFMlSHaVHeyRdqF9r5efUVNf8P5hn1JDaL6sQOJ+ZAoKL7UyhoTtg4SL3kDKzAdF67XtNz2S85skyPT3EpjuCWZ8dY5GEuTglbIlueCjHSDLwOYVZls5MM/1qbwM5z15NosKBSs3AC0 WYMamJeQ C6sDLUbzvI0UTyFBfZa/FkpMcaOLX4kQCMCzi3TsPPFd9H11EHauBZGFo/KBMcx6QPWVzeSJdZyot/DN4Kimen+Tgna4tEIb3BbGoqBIZIcMJT721/+tY637SscKAqMQWG8HAofWsESuNQBGoG8JyTMatSCalpnnMT0ZdccEhSIP/0GGgPBoj1XRCLtI+iC37EVWSCFLC0iDxxds83bf9ptEmeyGzgZ0HEzed5rBNoEvOemyYAkOqFVsRh8TJrT+xA2zhTrQXGuq7kD5s1grXDbfVb0btG6B6pr++DT//R1gT5Ib8N/uK4OfRT58EXi78NeWIpmnKRBXYL2XAzg/6wNX+MwlHuyMn53vYHfgy4zQQV+YgklDmtxA+ZiHTOg3iwSMVlXm9N7iv76k= 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: Let's make update_mmu_tlb() simply a generic wrapper around update_mmu_tlb_range(). Only the latter can now be overridden by the architecture. We can now remove __HAVE_ARCH_UPDATE_MMU_TLB as well. Acked-by: David Hildenbrand 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 | 4 +--- 6 files changed, 1 insertion(+), 18 deletions(-) diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index 5ccc2a3a6f7a..161dd6e10479 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -467,8 +467,6 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf, #define update_mmu_cache(vma, addr, ptep) \ update_mmu_cache_range(NULL, vma, addr, ptep, 1) -#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) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index 0891ad7d43b6..c29a551eb0ca 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -594,8 +594,6 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf, #define update_mmu_cache(vma, address, ptep) \ update_mmu_cache_range(NULL, vma, address, ptep, 1) -#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) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 4630815b0253..ddfd6f8cdcb3 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -489,8 +489,6 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf, #define update_mmu_cache(vma, addr, ptep) \ update_mmu_cache_range(NULL, vma, addr, ptep, 1) -#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) diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h index 436158bd9030..1647a7cc3fbf 100644 --- a/arch/xtensa/include/asm/pgtable.h +++ b/arch/xtensa/include/asm/pgtable.h @@ -410,9 +410,6 @@ void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma, 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 diff --git a/arch/xtensa/mm/tlb.c b/arch/xtensa/mm/tlb.c index 05efba86b870..0a1a815dc796 100644 --- a/arch/xtensa/mm/tlb.c +++ b/arch/xtensa/mm/tlb.c @@ -163,12 +163,6 @@ void local_flush_tlb_kernel_range(unsigned long start, unsigned long end) } } -void update_mmu_tlb(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep) -{ - 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) { diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 17d1caee39ab..117b807e3f89 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -736,13 +736,11 @@ static inline void update_mmu_tlb_range(struct vm_area_struct *vma, } #endif -#ifndef __HAVE_ARCH_UPDATE_MMU_TLB static inline void update_mmu_tlb(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { + update_mmu_tlb_range(vma, address, ptep, 1); } -#define __HAVE_ARCH_UPDATE_MMU_TLB -#endif /* * Some architectures may be able to avoid expensive synchronization From patchwork Wed May 22 06:12:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bang Li X-Patchwork-Id: 13670455 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 36129C25B77 for ; Wed, 22 May 2024 06:13:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D64F6B0089; Wed, 22 May 2024 02:13:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 885FB6B008A; Wed, 22 May 2024 02:13:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74D5D6B008C; Wed, 22 May 2024 02:13:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4E4496B0089 for ; Wed, 22 May 2024 02:13:33 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C68FD141404 for ; Wed, 22 May 2024 06:13:32 +0000 (UTC) X-FDA: 82145015064.15.B0223C5 Received: from out0-198.mail.aliyun.com (out0-198.mail.aliyun.com [140.205.0.198]) by imf06.hostedemail.com (Postfix) with ESMTP id 88074180009 for ; Wed, 22 May 2024 06:13:30 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=antgroup.com header.s=default header.b=ZjKPR4ec; spf=pass (imf06.hostedemail.com: domain of libang.li@antgroup.com designates 140.205.0.198 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=1716358411; a=rsa-sha256; cv=none; b=kmRHKM/lruNyhsgfWOIfMzFeuMYsf4mCzGusoWc0Jv1f5I7uxaEXBiTRZ4c6YoRtyIasLl s0PyJj9ae5S6wuRiJxFsVv5l0KhM+IoaOQJMrLQ6fz0raewCRW5dYFphF+t8jf8s5k60Zl ga8bKQU63euyQP3m8cbpjQqolr87LMk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=antgroup.com header.s=default header.b=ZjKPR4ec; spf=pass (imf06.hostedemail.com: domain of libang.li@antgroup.com designates 140.205.0.198 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=1716358411; 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=+clcXfgLVBiQX5MySmBhLxW05UlCMsdDj9QlU2/Rreg=; b=QZS8kBk2RWiHYjAA2ZWA4E7msJC4Md9KmnA9P7TAebAQYmxWDaftUIGp/GxvqBn7FzMUEm 8bbogh/r5acsiiNhSgtGlGGmYhZt15CV8znv/hNXBzKprnEMscgZNm44v8lWlV7TSBMnsa kIY5eebvcseTNvVtzuu61cyprBK+0mo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1716358407; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=+clcXfgLVBiQX5MySmBhLxW05UlCMsdDj9QlU2/Rreg=; b=ZjKPR4ecna7g4lVxy83K70sx+gDSrYJadj0Zhc7uYD23/TFA730XJ6LPbtUDMG788r8d06230EUxvjtthztl5IgEoJnae68wmvjfZyXJCu1AuWWcr++rUC4qRojStwqafw33vMoPKe1Yw7DO/T9lT/PAD0UJvjHvjQiHHdtKA5M= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R851e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045129160;MF=libang.li@antgroup.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---.Xk0LCMY_1716358405; Received: from localhost(mailfrom:libang.li@antgroup.com fp:SMTPD_---.Xk0LCMY_1716358405) by smtp.aliyun-inc.com; Wed, 22 May 2024 14:13:26 +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 3/3] mm: Use update_mmu_tlb_range() to simplify code Date: Wed, 22 May 2024 14:12:04 +0800 Message-Id: <20240522061204.117421-4-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-Rspamd-Queue-Id: 88074180009 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: pm6ukx5j4t1mrmengqmqya5zbth7bwf3 X-HE-Tag: 1716358410-101242 X-HE-Meta: U2FsdGVkX1/f1xIepP5+0a38YtQqxyPzGolsoLidAcqHUWaqrSvX5cxTc/Ti42GIYKLufvkCZJyIP76sDEPtwVuysy9etaCK9eBfEIlwWqXz2B46ncuO6F6G8i73VRvT0azkI05wW44mxtNCQrZrTXnVh3okbsH9iIABrX47PXPuKnP6hxihHcZWAkRJAjX5QfK1ry4QX0uDMufHfj6pAPxqGV4qb1YaMRc597u71pF3oaG2YUAy7ChiX1sKfbTjRliqRXNcsso2zoutg/kXeO2cM27+ES5r+ZQJTfe7xECK1Qx/NS2FgZayPStgUyOzzLMZ/X0cvYl1BswUvpW9uEPKN6o0MOkwsuIwAzCUiTwX8ytp5nDoyK2UC/kG+BlVqc46+aEByo5ryKMt/cC5PyFkZoFLKpk4GE284MpxuCaeKmltqgz6CifweHbcqITAq/4G9wtBBIbK0EKuyp5VXLFnMb/Rf9e2tMGVFP2VLynzUI3Z/u3XTyvPfOjEh8zQw7tq6JdA2AdTn4ETXapCg5xULYr/lXxpORzCGBZ53VGppHOtXFkcCM1nKybY4DIykIaO77bjPMw8tEOC909eQ0L8OSunyoeqzOqAyiETWkEEZFkK60dm4Lu8BhySa67R3X7iXrduYyVdeLSaffcQKzeJlbO6+HiFeOLsveJfGRAsObhG8SDySGWIhqt0WlDPwS3cExYUrcCFK4keUGb9unrCjQbfEZDlUbPEEfYNsB/6AUWePi/3SMFONC5y3v+dCWD1e5pFx9QAvGEpL5iS8SCk4W1063pklsuB9WBQ/2E2yB+wbsoRGaercMY5pMnxcyDUzYmTjiXmCNlmeI2kugqaK7QjnGPNCIsh2zLodnoFuUMZJBTuBp5YH7o99I9eUfuY+UiSJHDKiuBJJzL5ngruTyfVLdKnU8kr3fxmbeHu30FMq1Mpeb7CWgCVz47pvbwigucW2ZcOqdZa8xd DnenJcTN eChW8lDbwYHHEJdf/rLdNWjUzftAQfwQakqGXMn++G286J7jHLLdYBuC0HKzbFXu8RThL9zsgExpjfF7Lvn8Kk1URk4kpueP3ZuqWfJ7B50wtIGuHUTXrEwP3eGUJSC8csuzNqm0eVCauETmDDhXgYtolV7p8Rmn/eiwvJ9Yz3i50oxw4LR8pJKwlQReJwI1akYZBjK1k4lVzAm6ROeyljMve2JBlKjYC0efF8h+YtojO8uvgkUdf1b2Md/ncnYrA7bcYMnbwFNAkrhmTb+y/aSGZeCO8g2LSczK6TapLHvxkAoExy5C2r8pwYYhNIt5KwqwqKS8HCrRs5upOenfylB6lMqDZ9PsdB+Nyn6pmgjouxJ4KDYeTtng+2w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Let us simplify the code by update_mmu_tlb_range(). Reviewed-by: Lance Yang Acked-by: David Hildenbrand Signed-off-by: Bang Li --- mm/memory.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index b5453b86ec4b..1297474546d6 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4416,7 +4416,6 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) vm_fault_t ret = 0; int nr_pages = 1; pte_t entry; - int i; /* File mapping without ->vm_ops ? */ if (vma->vm_flags & VM_SHARED) @@ -4486,8 +4485,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) update_mmu_tlb(vma, addr, vmf->pte); goto release; } else if (nr_pages > 1 && !pte_range_none(vmf->pte, nr_pages)) { - for (i = 0; i < nr_pages; i++) - update_mmu_tlb(vma, addr + PAGE_SIZE * i, vmf->pte + i); + update_mmu_tlb_range(vma, addr, vmf->pte, nr_pages); goto release; }