Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp148172lqp; Tue, 21 May 2024 23:13:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXwJZ8X1QTN5aow3MWmJUm2k4puCcrqAIIYmOIE75+KerOOTlIiLrXdnp7HzhxUQhMuetPyOxDNiHIslHheZPt05YMrc9O+VeDm4Kuqsg== X-Google-Smtp-Source: AGHT+IFDFy+NWILBRRmpuNhZJro0YS+upgKfGjuPjj3eK5OzgRfFO95osbAwskxr9UZeSTtEXVd4 X-Received: by 2002:a50:f60c:0:b0:572:9a99:cae6 with SMTP id 4fb4d7f45d1cf-57832a2c265mr517474a12.15.1716358435818; Tue, 21 May 2024 23:13:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716358435; cv=pass; d=google.com; s=arc-20160816; b=euVNA3As+xZPaExBsiLmHDcdYamCyCLroIrqUXG3L6pD5b5/Wc/QM8Ea0LdPTMkBdU eUAcB7DXXXCS5R4n1xowospWFFeqEoDSdr9TN7UmeAZZzqxyyvFDZ8RCtXl3cwyWyIdH 23h9uk5ADR7ihErlZwrMeUojoMgr9Y2+aqUWq/NQ83e58VUg2fD+FjBc5z5Y7ztcaKxj /flFOK3NvJ6kyFgNd06VzNPAqbR388IcOKFW/JqGW8i+nX60bdgUftuy/ZQSkWlbuxr1 Y2aXX3CGvVcLaxvryLtuAAD2gNVvabFXGbnR2wZ9E+ZuMqGRFPMM2BzXFUt2C5MWuSPY o3WA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NpGCr7uMs7nN0Q+sV09/b3UAtSy1OaurTOZpW7g+KIc=; fh=ZaPvTvk3greVAhtlw/faBL7y/bcze5JBULOYO1tsevI=; b=Ny0hOlG+PPMSZ621IUgb6mC/G4twAbkm/v7Ectm74VG3ha3Q0fAlGqzKMTyYJPEW3o WcBbi+VSDeUpgaVYliZ0ofxSbQZFBRJqFBCgzfg4J+cF4SbXGLq1QS1XM35FDDzcpwXL 9uoSadk9Gr2MpNSz/lXpkqdnJU2XUS1BU3Ir5lQBb+stDHHw1oMIl0onrx17KBJSU71k YTVQj6pcrju4vXCSMHH3qnMoIc0x0jweyfySIafX/VryY+4HLd0rDcuNgv7L0okkhe1h k2jQ1LF+JvH2mLRuScyISPyqA2wP133OmarLhmsAqggIU6kLZg/m4qS6qo1rL+f2fQyz AFew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=n4XTxQW7; arc=pass (i=1 spf=pass spfdomain=antgroup.com dkim=pass dkdomain=antgroup.com dmarc=pass fromdomain=antgroup.com); spf=pass (google.com: domain of linux-kernel+bounces-185799-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57837446af5si134684a12.298.2024.05.21.23.13.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 23:13:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185799-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=n4XTxQW7; arc=pass (i=1 spf=pass spfdomain=antgroup.com dkim=pass dkdomain=antgroup.com dmarc=pass fromdomain=antgroup.com); spf=pass (google.com: domain of linux-kernel+bounces-185799-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 644E91F227BE for ; Wed, 22 May 2024 06:13:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9703B78C80; Wed, 22 May 2024 06:13:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="n4XTxQW7" Received: from out0-218.mail.aliyun.com (out0-218.mail.aliyun.com [140.205.0.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD9937580A for ; Wed, 22 May 2024 06:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716358413; cv=none; b=meWiHTPNepB0+Yp/EmZbVXiAw3LxnoLdNOt0gN6Lc3CT97fduL8N0hUQXkyDIUyKpC6W7KfZVNQXlkuniZNwDAsoEf9xCPh67dICLTo4li5BVbWfjYQ3zqkKax6xL5Im3KH88m1hvB/PKKlvrPLUpopHYn8UE7Tk0BQIFYHzn/w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716358413; c=relaxed/simple; bh=Xt0REtd+DR/3fOTEBJmnS1QOQXtPn9QES5jayrguzf0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=peSC4nHBIv6GMuxiiX4FucoY1Y2G654JK/pJbqdMHjyMRCma5jwTrsJZ0Ftz/upZ4+GcM9LsivWREdWMlPPpEaRMNxqVmR7tnonzs41x5T1Nhx09UxAhwjfKi8ghQS7QLYcg9bw8eJQsryEE7YZtLBQMpPBLwjSHWzzhzA8grZQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=n4XTxQW7; arc=none smtp.client-ip=140.205.0.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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) -- 2.19.1.6.gb485710b