From patchwork Wed Dec 18 13:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13913625 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 93637E77188 for ; Wed, 18 Dec 2024 13:06:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CDED6B00A9; Wed, 18 Dec 2024 08:06:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17EBB6B00AA; Wed, 18 Dec 2024 08:06:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F39EC6B00AB; Wed, 18 Dec 2024 08:06:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D3BE26B00A9 for ; Wed, 18 Dec 2024 08:06:46 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7B4C41C5DB0 for ; Wed, 18 Dec 2024 13:06:46 +0000 (UTC) X-FDA: 82908104034.02.DE33854 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf26.hostedemail.com (Postfix) with ESMTP id 5D841140016 for ; Wed, 18 Dec 2024 13:06:20 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=FLBLP5PP; spf=pass (imf26.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734527190; 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=oQG7I8CTZ7TxV9gz83QsafJIUScPDY5LnGxZvWTV1Wk=; b=VKF3dZDpy6gs8jUPntEI++C80M0sV8J8GpfuVc6dYozmnioqbfVBmOvF4Hno4UNEFGBWgS TQ7c8APkfj7C0p4hPGoRhs3ChACM6AY1BPqWfLwZdqeFJxB1OJcWW5pDs7ZhDQ5ELBwj+t aXsfjQ6gWQvv1hnPXi+yecV2/pcz2uA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=FLBLP5PP; spf=pass (imf26.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734527190; a=rsa-sha256; cv=none; b=AAPGi45sqC6Ozntum1rYf15hRcC9YvA7naiT4S/7OVjNO5a1qp4evisEDFcjvWYUvTGvX1 isn7HfyJDtw2liQJogmWVS0vJPXLnf5LCFGvT0qHGK/Ir8AkyZNiltxG7MV2Gj1kDvBVHT hr7iTwB9z+zanxqUPVvyMhCp/64/Ii4= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2164b662090so51907355ad.1 for ; Wed, 18 Dec 2024 05:06:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734527203; x=1735132003; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oQG7I8CTZ7TxV9gz83QsafJIUScPDY5LnGxZvWTV1Wk=; b=FLBLP5PPhXLVSGSQvOEPuUsBqqyWf71n86MmDzYYcqh2rI/u5b4sv/nRK9OcxewwKs 765HsEeh3u+DuBcAd0OGqIyy2xLTTvSxk35Q9URIbwg/m52exahVIgKk60+D9yLxYl4P Z4Y5VusqFnfGHXnAtF5AwK3nVEFJqHwM/t/klTr81Db7/g55yvOTjPESf3hBINIucaqa 3PMvrNW5h7LTreYXmdQcgF8Px/WI48Z+yghtUV3+qeEv0WKxIqC/YfJUC8J7PkEqBe/j pooA5a50IedqGU5ptdEyf6GtheHCuKy6FqYFzEQTPBWKlFPROeNvOu5+nEzePjUJj3xT 2vyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734527203; x=1735132003; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oQG7I8CTZ7TxV9gz83QsafJIUScPDY5LnGxZvWTV1Wk=; b=uY7h+QQfMPZfENbX7dd6ktfuVsG9rm4aaHTsRLkM+ReMr73Ua9JNNZZJl2cio0ntVH LTf98CT2N/XsZcFvGnasg49SOnF44Slcv7iibSQb1t+hLxDmUIIpv58ri3mzwTvtwA4x dS9EkR2PI7e9I0MAN25N0dEyDjFy5GnE8iOkW9zQiGvzGcG8VVuW17NTkRrNfvRfUsdg eDRSHD6p/O7SuJ08TJwSkgTASLPFTHb2UimytqtHnR77J2RVe83gJGZgvWnCyRBHc+vw 6ATpN8i48E0lbrlXt9Ka+pjE/Jci4HSEk8mWD2a/cJKqLDkgkdCrngZLSGvswuZwFR43 CXAg== X-Gm-Message-State: AOJu0Yy25QhLXqaD/qDiOKyeTj9fHFxFr8Vh6XYmdxz7fv/NgLIFnPl4 4sSdYb+v1a4DPB8MERyeyLEB0lhgLV9FFliR3Y3RjXz+u8VUqpqGnn5R/lBiKRc= X-Gm-Gg: ASbGnctGj+yg1VRo1nX3b6F+U6mQEejVcdPCtY/4y0R3eADjFisiEqueJWvvtW6+oyK oKyO7wS9Ke/+5k9CMbyN8vTtc9hhM0AkhfIuMtlyVh1Jp7yt9nuPHtZOiTi+73HLNBHEPUsawxJ 3x4pW7aePtyxm2POc9DRv4IVA8G3kmoEThOcUAHmk7VppMvVSlU1o/5qGxKxFBKIu91RAHQz8iG DxCUjLB/iNzUBPip4XeuV6rDRj9CgfEOpx4WvsjF7vjo4hcmKHYkuvdxS+ho2MpQ0bxrHrjFgBx sqJ9uE4RY8EVr7OhjuEJyQ== X-Google-Smtp-Source: AGHT+IGqOVtOaXTsC11RmGC0pnVBsbhpRr7fSYpWbIozZcJ8TvZ8U4y91o/Td1tfWFL+H7ThjVOaNw== X-Received: by 2002:a17:902:d50b:b0:215:6816:632e with SMTP id d9443c01a7336-218d725bf5dmr42047505ad.48.1734527203288; Wed, 18 Dec 2024 05:06:43 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.238]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-218a1db755dsm75751825ad.42.2024.12.18.05.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 05:06:42 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, tglx@linutronix.de, david@redhat.com, jannh@google.com, hughd@google.com, yuzhao@google.com, willy@infradead.org, muchun.song@linux.dev, vbabka@kernel.org, lorenzo.stoakes@oracle.com, akpm@linux-foundation.org, rientjes@google.com, vishal.moola@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH v2 14/15] mm: pgtable: remove tlb_remove_ptdesc() Date: Wed, 18 Dec 2024 21:04:50 +0800 Message-Id: <79b20df78eb81a9cd07e3048f2d4d63d98759b4a.1734526570.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 5D841140016 X-Stat-Signature: schm7aqp7jymn8kukitgg9prk66n9zed X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734527180-472046 X-HE-Meta: U2FsdGVkX18cWo2OC6DiP9rVL6h1sgVmIOMxLdzhqYvrmZYQKvV4Xnxh2fujeE3yHZyHrugleIu4t8F9hcSDrd1RcGtXS42ypcOob4N+ShESwbLPWThLxM3UJLmOYoALz7/L7jV87j8y71rLXiynFWiPaQsjFY6LnuN4wv6aT3fx2uvNqA+E9mUpQpk0SOK42VfMcB0O486kXiPQy1DGOCTBd+49S3aG/3114Iczl+dzn/T+3WiPA/x/OyAFPq90vIdhSFseil2GZx8Jpg6gyJAcCVCQLKM4436L1+shPxNgbkCdWO2lqragDQyl2l3wRNW8bakXr6FsKGFwqArxuUwqT61f//JBGZKma4Ntbl027fED/iC0FuRIl4MinLD483ITFOs8hMqe+bQSvQFY6LeznH14K8l47NMjA/hxoKOEt0xsXs5IZU+rzYoLYh4v9E7IiuajRUNujeaggS36G/r1FY37arFgIWyrORVpPSG4YKARWrq5MfmpByZNbE4ggNEokr6foaQmUOB8BzeGMwuDSmHrEkQAjGiHqfDuqY8PzGJdvhaZpXJAeh7xuKUem8PaS6IFRt3NBQJNZUo8yVu9DlIA45bx3GNd5leW4qtK4liDMhzoihyw48nCCNO7Fv3wG+wez5zJdWcTqffluAFr4RxVVwxbFLmW3DmD4ilxL8viJVTiXs/EEIJNHq5byR71IiJRYSqTVe4nui4grZToBZPKF67peEkctyN9Ya7r5XG+smf0ibnl3DrPX6CdvYDk5meDV1j6RRvCYVsVFoJD7Woc2yu5lyOUTSskCetpeU5PpfExP9Jj8Ta2HHopXAcFppu4BOqADSLhwJxn6YVou9YSfufQdHRPjpUqXIxhk6YRBzq6iEmVhs7IdqdL02qNMfdj6Eo2uqjp7p6/vkHwUIRUXCm5jqpLfcuQsRkxeualeHI0HOtfTPzistLv9CFDPaMwDeaE1vFTcJt R9CwJpcY WpwRh4iBkzEBXJlrWP7KzyH+I0JEfXk2qu6ec04QFbnzdNXkxYRmFbHga3nPQyhmHtldJjYg8CvTOff61Votbt+jnlHRzaaxp5Ut3AXbHDT1zGBKbTWRxosq9jcJqZ4soFVWTmjtkhAx6lOOMSn0QqeGCEIrLuBX9UCwlFoUQqVLPIsSP2YuveQl6lDXvS0mb/RKyCue+FMBLc8SrI5+Ct03L9bbwCh9XJBCQInL3AH+e2ggw/GcGtNqdyFPbDftJE2MRXWaZd+FeeI/K0g7+qG581klJya+WTN/i3PFMXkJIi1gm94OZ8L5ccQ1RngS9rvqgrlP60Gpd3GHzVJcHzKE4Qx0Nwl6jtdJCk+pIYKp9dk0MLs7XyAMFQcR8MbZUv7tOQ01AJB1t2RhqzlubdY8JLVaJ5MZ81/s3ooY+KwhRyB7ZDaheIFdIi2IOt8wOEoCV0UVpSmFHo7dXZT7jfzlUxUzsMl1owoXseJRlppUiSg4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Just like removing tlb_remove_page_ptdesc(), remove tlb_remove_ptdesc() as well, and make callers call tlb_remove_table() directly. Signed-off-by: Qi Zheng Originally-by: Peter Zijlstra (Intel) --- arch/arm/include/asm/tlb.h | 8 ++------ arch/arm64/include/asm/tlb.h | 16 ++++------------ arch/riscv/include/asm/pgalloc.h | 14 +++++++------- arch/s390/include/asm/tlb.h | 8 ++++---- include/asm-generic/tlb.h | 7 +------ mm/mmu_gather.c | 11 +++++------ 6 files changed, 23 insertions(+), 41 deletions(-) diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h index ea4fbe7b17f6f..ac3881ec342f1 100644 --- a/arch/arm/include/asm/tlb.h +++ b/arch/arm/include/asm/tlb.h @@ -32,8 +32,6 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr) { - struct ptdesc *ptdesc = page_ptdesc(pte); - #ifndef CONFIG_ARM_LPAE /* * With the classic ARM MMU, a pte page has two corresponding pmd @@ -43,16 +41,14 @@ __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr) __tlb_adjust_range(tlb, addr - PAGE_SIZE, 2 * PAGE_SIZE); #endif - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, pte); } static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) { #ifdef CONFIG_ARM_LPAE - struct ptdesc *ptdesc = virt_to_ptdesc(pmdp); - - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, virt_to_page(pmdp)); #endif } diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h index 8d762607285cc..4a60569fed696 100644 --- a/arch/arm64/include/asm/tlb.h +++ b/arch/arm64/include/asm/tlb.h @@ -75,18 +75,14 @@ static inline void tlb_flush(struct mmu_gather *tlb) static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr) { - struct ptdesc *ptdesc = page_ptdesc(pte); - - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, pte); } #if CONFIG_PGTABLE_LEVELS > 2 static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) { - struct ptdesc *ptdesc = virt_to_ptdesc(pmdp); - - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, virt_to_page(pmdp)); } #endif @@ -94,12 +90,10 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp, unsigned long addr) { - struct ptdesc *ptdesc = virt_to_ptdesc(pudp); - if (!pgtable_l4_enabled()) return; - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, virt_to_page(pudp)); } #endif @@ -107,12 +101,10 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp, static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4dp, unsigned long addr) { - struct ptdesc *ptdesc = virt_to_ptdesc(p4dp); - if (!pgtable_l5_enabled()) return; - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, virt_to_page(p4dp)); } #endif diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h index da782a80f8aad..f319e2c6776e4 100644 --- a/arch/riscv/include/asm/pgalloc.h +++ b/arch/riscv/include/asm/pgalloc.h @@ -29,10 +29,10 @@ static inline void riscv_tlb_remove_ptdesc(struct mmu_gather *tlb, void *pt) { if (riscv_use_sbi_for_rfence()) { - tlb_remove_ptdesc(tlb, pt); + tlb_remove_table(tlb, pt); } else { - pagetable_dtor(pt); - tlb_remove_page(tlb, ptdesc_page((struct ptdesc *)pt)); + pagetable_dtor(page_ptdesc((struct page *)pt)); + tlb_remove_page(tlb, pt); } } @@ -120,7 +120,7 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, unsigned long addr) { if (pgtable_l4_enabled) - riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(pud)); + riscv_tlb_remove_ptdesc(tlb, virt_to_page(pud)); } #define p4d_alloc_one p4d_alloc_one @@ -143,7 +143,7 @@ static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, unsigned long addr) { if (pgtable_l5_enabled) - riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); + riscv_tlb_remove_ptdesc(tlb, virt_to_page(p4d)); } #endif /* __PAGETABLE_PMD_FOLDED */ @@ -172,7 +172,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm) static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, unsigned long addr) { - riscv_tlb_remove_ptdesc(tlb, virt_to_ptdesc(pmd)); + riscv_tlb_remove_ptdesc(tlb, virt_to_page(pmd)); } #endif /* __PAGETABLE_PMD_FOLDED */ @@ -180,7 +180,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr) { - riscv_tlb_remove_ptdesc(tlb, page_ptdesc(pte)); + riscv_tlb_remove_ptdesc(tlb, pte); } #endif /* CONFIG_MMU */ diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h index 7052780740349..fba11949dd2ea 100644 --- a/arch/s390/include/asm/tlb.h +++ b/arch/s390/include/asm/tlb.h @@ -86,7 +86,7 @@ static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, tlb->cleared_pmds = 1; if (mm_alloc_pgste(tlb->mm)) gmap_unlink(tlb->mm, (unsigned long *)pte, address); - tlb_remove_ptdesc(tlb, pte); + tlb_remove_table(tlb, pte); } /* @@ -105,7 +105,7 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; tlb->cleared_puds = 1; - tlb_remove_ptdesc(tlb, pmd); + tlb_remove_table(tlb, pmd); } /* @@ -123,7 +123,7 @@ static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; tlb->cleared_p4ds = 1; - tlb_remove_ptdesc(tlb, pud); + tlb_remove_table(tlb, pud); } /* @@ -141,7 +141,7 @@ static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, __tlb_adjust_range(tlb, address, PAGE_SIZE); tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; - tlb_remove_ptdesc(tlb, p4d); + tlb_remove_table(tlb, p4d); } #endif /* _S390_TLB_H */ diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 8d6cfe5058543..583e95568f52b 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -211,7 +211,7 @@ struct mmu_table_batch { #ifndef __HAVE_ARCH_TLB_REMOVE_TABLE static inline void __tlb_remove_table(void *table) { - struct ptdesc *ptdesc = (struct ptdesc *)table; + struct ptdesc *ptdesc = page_ptdesc((struct page *)table); pagetable_dtor(ptdesc); pagetable_free(ptdesc); @@ -499,11 +499,6 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) return tlb_remove_page_size(tlb, page, PAGE_SIZE); } -static inline void tlb_remove_ptdesc(struct mmu_gather *tlb, void *pt) -{ - tlb_remove_table(tlb, pt); -} - static inline void tlb_change_page_size(struct mmu_gather *tlb, unsigned int page_size) { diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c index 7aa6f18c500b2..c58ce4539c56f 100644 --- a/mm/mmu_gather.c +++ b/mm/mmu_gather.c @@ -314,18 +314,17 @@ static inline void tlb_table_invalidate(struct mmu_gather *tlb) #ifdef CONFIG_PT_RECLAIM static inline void __tlb_remove_table_one_rcu(struct rcu_head *head) { - struct ptdesc *ptdesc; + struct page *page; - ptdesc = container_of(head, struct ptdesc, pt_rcu_head); - __tlb_remove_table(ptdesc); + page = container_of(head, struct page, rcu_head); + __tlb_remove_table(page); } static inline void __tlb_remove_table_one(void *table) { - struct ptdesc *ptdesc; + struct page *page = (struct page *)table; - ptdesc = table; - call_rcu(&ptdesc->pt_rcu_head, __tlb_remove_table_one_rcu); + call_rcu(&page->rcu_head, __tlb_remove_table_one_rcu); } #else static inline void __tlb_remove_table_one(void *table)