From nobody Thu Dec 18 20:19:15 2025 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC5CD1B0416 for ; Wed, 18 Dec 2024 13:06:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734527205; cv=none; b=t52kOaXHcB5EpHdESz86xf8HYSMwQcs1IjP6sRS7GNWuijMsi+51vIgFmRMblVDJEixlGjysmYGWjLH5i/DwmJIuwAqrPoxdrstOMnEzozK/lzr1jWdiqnQsc0F2pSS/Y0R3lyHXCvMtnz+Bsv5G9mFKwaaB411VTCFeMx3qVgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734527205; c=relaxed/simple; bh=Svs1pv7W8nli3pB3EWaqja1Gw7JXvPlzfs8XYKPSzj4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GfPXpJSSGM4Y5KTTdxras/twxXy7hqqi+9pPZ7HSAPQ5MEqlhdDVq6NFxOwJrsjaXIGaVK5ZdRKCyEr32b7M7Kf4zzsBxSzA8L9ycbtKBERHPWXYmBaNMYMkx1rGblT9e2wc9/1HTLCqVKfND3VedgFbEvp/bzvnfRI3LYEJtkM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=Bnaewscd; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="Bnaewscd" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2164b662090so51907345ad.1 for ; Wed, 18 Dec 2024 05:06:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734527203; x=1735132003; darn=vger.kernel.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=BnaewscdtTEKgFEq2ufO9Bc4eN+bAandePOmzoAB5wDAqPSy27FD7gwN/Z5UKUuoHF aeiKxA8Ll0HyW/me4uevv15OmGGHT7kwGis+Xtab3bXunRY2bljJwW0LKPdcfRywHQXh oKpxklS1LpeGATMSHh21/m/Qd+5FS8XjOMHuRCwslOEMjpcGK1m+2GMAfnYk24RY2cw5 z1umM2CpQEO3kq9ZQVmdTjtLDF7SfhU3e84K2RZRd/XwvkpLsHtunX2iMqCVF5O1f+Bi fXWWGVekK0l6zkQdVRJ/ISS00eGPkkY8ZjrfyhL0koQk5B3MSTlALgG4iXm1P/TplMbW 1lhA== 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=MHFuC27FVKrwM7i2q/7iz0t35tK+oC0c9j4VVmDB2AXB6PkmQJyEFNeKWlZNOwUf5N FAGB0IbXrsrqUwExYq1wJM0n3tXldpWbRQ1+Mnew/kdF8lluQfXQECbSdUzYzZM60Suu Tuh9td0U1X8JLIsznbI/ZE+OMQj+T6ZLH9vmKH/bqu6WzQLbAlQQYHErU3G0kTG12k7r Xfm2uMKuH/X2WkvycG2qUHU8DQGewNwZk4ONyjMbY9oJwsc+NnWvjZXKFGcu4o7Q72b0 3ea36NV4DmjcbrVvaeda44vuodkGG2kGouIr118vhaCghCbmtMBmyujfmCyu+h81kfCu ab0A== X-Forwarded-Encrypted: i=1; AJvYcCVSrXBdqGhbcpTF3uptt12asRB2qrdraUQSGXxfmMjijHp/Kg9aBJzd9wBpzWUiyrBHUSvi+5JXapm1K+s=@vger.kernel.org X-Gm-Message-State: AOJu0YzBQN1g7XX9sBf9dNnRE4ul90uhpL+do24rsuAScErZD3Xfa8tD gAVLHxWhTBKWqYlLnrFlWfz759MtSKJ1YziUkxUbFOyrPXif1UysyrGBa6F/oco= X-Gm-Gg: ASbGncuwAyTlTRHYS9wq1/FPNXX/pMlL3tuxHL6YYsxg0ksmt81qMtHbMAzX+pjuWKc aHrsP3YR4zQCkUODmdpg25Qu9mOrneRn3xotk8rowtRhw5/Us43tr1kEEYyQOpLnV3B4kyHZChu 2zmpljHVyWTq5IGA8lnG8R/uLN16VLBov2jRDu9aTYX7NPzgENw0yn8T9mScYGR6XFepqVYWxqs vnfkR/bTFjwcqEGWvvxQiZQVQ0hLmtzFNQqSYxlxfbT2f1gIOXOGZg0iBnVLTQh3Idj6cIXUldb 2+LxShfkGpxor21RHOUnVA== 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D 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, u= nsigned long addr) __tlb_adjust_range(tlb, addr - PAGE_SIZE, 2 * PAGE_SIZE); #endif =20 - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, pte); } =20 static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) { #ifdef CONFIG_ARM_LPAE - struct ptdesc *ptdesc =3D virt_to_ptdesc(pmdp); - - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, virt_to_page(pmdp)); #endif } =20 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 =3D page_ptdesc(pte); - - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, pte); } =20 #if CONFIG_PGTABLE_LEVELS > 2 static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) { - struct ptdesc *ptdesc =3D virt_to_ptdesc(pmdp); - - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, virt_to_page(pmdp)); } #endif =20 @@ -94,12 +90,10 @@ static inline void __pmd_free_tlb(struct mmu_gather *tl= b, pmd_t *pmdp, static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp, unsigned long addr) { - struct ptdesc *ptdesc =3D virt_to_ptdesc(pudp); - if (!pgtable_l4_enabled()) return; =20 - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, virt_to_page(pudp)); } #endif =20 @@ -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 =3D virt_to_ptdesc(p4dp); - if (!pgtable_l5_enabled()) return; =20 - tlb_remove_ptdesc(tlb, ptdesc); + tlb_remove_table(tlb, virt_to_page(p4dp)); } #endif =20 diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgal= loc.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 *p= t) { 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); } } =20 @@ -120,7 +120,7 @@ static inline void __pud_free_tlb(struct mmu_gather *tl= b, 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)); } =20 #define p4d_alloc_one p4d_alloc_one @@ -143,7 +143,7 @@ static inline void __p4d_free_tlb(struct mmu_gather *tl= b, 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 */ =20 @@ -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)); } =20 #endif /* __PAGETABLE_PMD_FOLDED */ @@ -180,7 +180,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tl= b, 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 */ =20 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, p= gtable_t pte, tlb->cleared_pmds =3D 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); } =20 /* @@ -105,7 +105,7 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb,= pmd_t *pmd, tlb->mm->context.flush_mm =3D 1; tlb->freed_tables =3D 1; tlb->cleared_puds =3D 1; - tlb_remove_ptdesc(tlb, pmd); + tlb_remove_table(tlb, pmd); } =20 /* @@ -123,7 +123,7 @@ static inline void pud_free_tlb(struct mmu_gather *tlb,= pud_t *pud, tlb->mm->context.flush_mm =3D 1; tlb->freed_tables =3D 1; tlb->cleared_p4ds =3D 1; - tlb_remove_ptdesc(tlb, pud); + tlb_remove_table(tlb, pud); } =20 /* @@ -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 =3D 1; tlb->freed_tables =3D 1; - tlb_remove_ptdesc(tlb, p4d); + tlb_remove_table(tlb, p4d); } =20 #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 =3D (struct ptdesc *)table; + struct ptdesc *ptdesc =3D page_ptdesc((struct page *)table); =20 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); } =20 -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_ga= ther *tlb) #ifdef CONFIG_PT_RECLAIM static inline void __tlb_remove_table_one_rcu(struct rcu_head *head) { - struct ptdesc *ptdesc; + struct page *page; =20 - ptdesc =3D container_of(head, struct ptdesc, pt_rcu_head); - __tlb_remove_table(ptdesc); + page =3D container_of(head, struct page, rcu_head); + __tlb_remove_table(page); } =20 static inline void __tlb_remove_table_one(void *table) { - struct ptdesc *ptdesc; + struct page *page =3D (struct page *)table; =20 - ptdesc =3D 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) --=20 2.20.1