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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A86C2C43331 for ; Fri, 3 Apr 2020 09:06:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6F46620678 for ; Fri, 3 Apr 2020 09:06:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F46620678 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 013908E000A; Fri, 3 Apr 2020 05:06:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F076D8E0008; Fri, 3 Apr 2020 05:06:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCF578E000A; Fri, 3 Apr 2020 05:06:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0254.hostedemail.com [216.40.44.254]) by kanga.kvack.org (Postfix) with ESMTP id C55C48E0008 for ; Fri, 3 Apr 2020 05:06:46 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7C74E181AEF0B for ; Fri, 3 Apr 2020 09:06:46 +0000 (UTC) X-FDA: 76665963612.26.man17_75414e637544e X-HE-Tag: man17_75414e637544e X-Filterd-Recvd-Size: 6375 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Apr 2020 09:06:45 +0000 (UTC) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D2B1D7657395ACD9A9A0; Fri, 3 Apr 2020 17:01:11 +0800 (CST) Received: from DESKTOP-KKJBAGG.china.huawei.com (10.173.220.25) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Fri, 3 Apr 2020 17:01:04 +0800 From: Zhenyu Ye To: , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v1 4/6] tlb: mmu_gather: add tlb_set_*_range APIs Date: Fri, 3 Apr 2020 17:00:46 +0800 Message-ID: <20200403090048.938-5-yezhenyu2@huawei.com> X-Mailer: git-send-email 2.22.0.windows.1 In-Reply-To: <20200403090048.938-1-yezhenyu2@huawei.com> References: <20200403090048.938-1-yezhenyu2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.173.220.25] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable 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: From: "Peter Zijlstra (Intel)" tlb_set_{pte|pmd|pud|p4d}_range() adjust the tlb->start and tlb->end, then set corresponding cleared_*. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Zhenyu Ye --- include/asm-generic/tlb.h | 55 ++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index f391f6b500b4..ee91310a65c6 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -511,6 +511,38 @@ static inline void tlb_end_vma(struct mmu_gather *tl= b, struct vm_area_struct *vm } #endif =20 +/* + * tlb_set_{pte|pmd|pud|p4d}_range() adjust the tlb->start and tlb->end, + * and set corresponding cleared_*. + */ +static inline void tlb_set_pte_range(struct mmu_gather *tlb, + unsigned long address, unsigned long size) +{ + __tlb_adjust_range(tlb, address, size); + tlb->cleared_ptes =3D 1; +} + +static inline void tlb_set_pmd_range(struct mmu_gather *tlb, + unsigned long address, unsigned long size) +{ + __tlb_adjust_range(tlb, address, size); + tlb->cleared_pmds =3D 1; +} + +static inline void tlb_set_pud_range(struct mmu_gather *tlb, + unsigned long address, unsigned long size) +{ + __tlb_adjust_range(tlb, address, size); + tlb->cleared_puds =3D 1; +} + +static inline void tlb_set_p4d_range(struct mmu_gather *tlb, + unsigned long address, unsigned long size) +{ + __tlb_adjust_range(tlb, address, size); + tlb->cleared_p4ds =3D 1; +} + #ifndef __tlb_remove_tlb_entry #define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0) #endif @@ -524,19 +556,17 @@ static inline void tlb_end_vma(struct mmu_gather *t= lb, struct vm_area_struct *vm */ #define tlb_remove_tlb_entry(tlb, ptep, address) \ do { \ - __tlb_adjust_range(tlb, address, PAGE_SIZE); \ - tlb->cleared_ptes =3D 1; \ + tlb_set_pte_range(tlb, address, PAGE_SIZE); \ __tlb_remove_tlb_entry(tlb, ptep, address); \ } while (0) =20 #define tlb_remove_huge_tlb_entry(h, tlb, ptep, address) \ do { \ unsigned long _sz =3D huge_page_size(h); \ - __tlb_adjust_range(tlb, address, _sz); \ if (_sz =3D=3D PMD_SIZE) \ - tlb->cleared_pmds =3D 1; \ + tlb_set_pmd_range(tlb, address, _sz); \ else if (_sz =3D=3D PUD_SIZE) \ - tlb->cleared_puds =3D 1; \ + tlb_set_pud_range(tlb, address, _sz); \ __tlb_remove_tlb_entry(tlb, ptep, address); \ } while (0) =20 @@ -550,8 +580,7 @@ static inline void tlb_end_vma(struct mmu_gather *tlb= , struct vm_area_struct *vm =20 #define tlb_remove_pmd_tlb_entry(tlb, pmdp, address) \ do { \ - __tlb_adjust_range(tlb, address, HPAGE_PMD_SIZE); \ - tlb->cleared_pmds =3D 1; \ + tlb_set_pmd_range(tlb, address, HPAGE_PMD_SIZE); \ __tlb_remove_pmd_tlb_entry(tlb, pmdp, address); \ } while (0) =20 @@ -565,8 +594,7 @@ static inline void tlb_end_vma(struct mmu_gather *tlb= , struct vm_area_struct *vm =20 #define tlb_remove_pud_tlb_entry(tlb, pudp, address) \ do { \ - __tlb_adjust_range(tlb, address, HPAGE_PUD_SIZE); \ - tlb->cleared_puds =3D 1; \ + tlb_set_pud_range(tlb, address, HPAGE_PUD_SIZE); \ __tlb_remove_pud_tlb_entry(tlb, pudp, address); \ } while (0) =20 @@ -591,9 +619,8 @@ static inline void tlb_end_vma(struct mmu_gather *tlb= , struct vm_area_struct *vm #ifndef pte_free_tlb #define pte_free_tlb(tlb, ptep, address) \ do { \ - __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + tlb_set_pmd_range(tlb, address, PAGE_SIZE); \ tlb->freed_tables =3D 1; \ - tlb->cleared_pmds =3D 1; \ __pte_free_tlb(tlb, ptep, address); \ } while (0) #endif @@ -601,9 +628,8 @@ static inline void tlb_end_vma(struct mmu_gather *tlb= , struct vm_area_struct *vm #ifndef pmd_free_tlb #define pmd_free_tlb(tlb, pmdp, address) \ do { \ - __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + tlb_set_pud_range(tlb, address, PAGE_SIZE); \ tlb->freed_tables =3D 1; \ - tlb->cleared_puds =3D 1; \ __pmd_free_tlb(tlb, pmdp, address); \ } while (0) #endif @@ -611,9 +637,8 @@ static inline void tlb_end_vma(struct mmu_gather *tlb= , struct vm_area_struct *vm #ifndef pud_free_tlb #define pud_free_tlb(tlb, pudp, address) \ do { \ - __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + tlb_set_p4d_range(tlb, address, PAGE_SIZE); \ tlb->freed_tables =3D 1; \ - tlb->cleared_p4ds =3D 1; \ __pud_free_tlb(tlb, pudp, address); \ } while (0) #endif --=20 2.19.1