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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85B17E77199 for ; Tue, 7 Jan 2025 14:21:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA8906B00C1; Tue, 7 Jan 2025 09:21:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E58996B00C2; Tue, 7 Jan 2025 09:21:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD1AA6B00C3; Tue, 7 Jan 2025 09:21:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id ACDE06B00C1 for ; Tue, 7 Jan 2025 09:21:26 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5E7921604DF for ; Tue, 7 Jan 2025 14:21:26 +0000 (UTC) X-FDA: 82980868572.25.4DE8EE6 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf17.hostedemail.com (Postfix) with ESMTP id 1E02D4000A for ; Tue, 7 Jan 2025 14:21:23 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=XZA2f+w+; spf=pass (imf17.hostedemail.com: domain of agordeev@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=agordeev@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736259684; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PZcAQo2jVZKhpUA/J5KNxIBIcwI9ru7trJmhob0Z6oo=; b=sCnU4SzQIgPq3wMXKXRA3C3ei1yjhG3wVlS8SZPOd+R0tOhrBEk7SKP7fegL8heuoaljVZ 2hhpPCY3ULzyNd23CwkCxzQZWlLWO5kr37N08ZlzG5eYwh+KKtOOdPNHsezzJXoEjee3GO isGqgvZ9bfE9MZiAhajz+tXQO+Yfi68= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736259684; a=rsa-sha256; cv=none; b=iv/303e4pP7mjfb/sBwd3iaYNeuFMYp7iAD0P7FRugCXJ6uPxmI+8vohrhM0Y/HHvEq94C CADJ/ja2jj2ClxBF3lLVCNd1iTLH/0fqvgtaYRpL55Ocn3aVJ3xFvUgouEkDw4qARVFDZ6 ROT+MfYVmm7hbL0P2GFsskD6m+hYApU= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=XZA2f+w+; spf=pass (imf17.hostedemail.com: domain of agordeev@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=agordeev@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50785lmS018139; Tue, 7 Jan 2025 14:20:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pp1; bh=PZcAQo2jVZKhpUA/J5KNxIBIcwI9ru 7trJmhob0Z6oo=; b=XZA2f+w+ZgaVD9bbZcCmyCGgsXz2felIn2ZCDI9+FmzGTH Eainpr7pfGKSTDzrmX3jhKmLGQgNrMONcuqUzI5XahM+03uE0ABbIfzQrAkkXRdQ zQyY3LcpYQtizGCGoFg+C1o070Epat0Ertl+Oj+j5GZbCQJpo6fBpvqaNlv0Uj4h jCp+oWr7fNZcGMEOuZ4JkwAxZo52l1qIWDUqKRwUfHiXmblJLI3ae2nNo1pFrfBS DcDWcjtyioeUbc3EdHzCB9GFsZ3E41si5WIYxTtQP1Lqc0+5shC0eyKIw8ZyhlDs ilv7kx5646E7KIqpUVnFvTxFL5QXObvV+xfaYIjg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4410f39jr5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jan 2025 14:20:55 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 507EKsge024914; Tue, 7 Jan 2025 14:20:54 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4410f39jr2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jan 2025 14:20:54 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 507DRZPg013571; Tue, 7 Jan 2025 14:20:53 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 43ygantsep-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jan 2025 14:20:53 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 507EKpgt21889308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Jan 2025 14:20:51 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59FEC2004B; Tue, 7 Jan 2025 14:20:51 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92F3320043; Tue, 7 Jan 2025 14:20:50 +0000 (GMT) Received: from li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com (unknown [9.155.204.135]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTPS; Tue, 7 Jan 2025 14:20:50 +0000 (GMT) Date: Tue, 7 Jan 2025 15:20:49 +0100 From: Alexander Gordeev To: Qi Zheng Cc: peterz@infradead.org, kevin.brodsky@arm.com, palmer@dabbelt.com, 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, arnd@arndb.de, will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, dave.hansen@linux.intel.com, rppt@kernel.org, ryan.roberts@arm.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-um@lists.infradead.org Subject: Re: [PATCH v4 13/15] mm: pgtable: introduce generic __tlb_remove_table() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pJGOWrM73oMm5Nze_uVYydJm8haany2l X-Proofpoint-ORIG-GUID: yqOSxHIumtcfGGAun6YrBrVvCrkUAfiN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=797 spamscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 impostorscore=0 bulkscore=0 phishscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501070118 X-Rspamd-Queue-Id: 1E02D4000A X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: w9pbfdmyogxxwurju19ux879e7nkejzf X-HE-Tag: 1736259683-794858 X-HE-Meta: U2FsdGVkX19CjvfeiK2tAKZIX5qiDcfpGTyJA7Y0wLeeAzg3qIYtWo2mv1yf8COBhmRpe7sJxquHnx83uKIqHKwR6L4X+qTK/tpaQivErouT5q/HTM50LnyDwl49jTOYioM7Bqw0SHAWUOlpwAXu05fL8RxvCFnKMupWuS1UT5ZqT6XRkfw6A9AFQwiDIDvBzJiHhIAWU3RU5xQphtTqTX1nWJzi9lFBihT+amXfG5qDKAYklOmOi7Vj26dlffx1pVW0QdLzoSGg//SIGrjVxDZgLruf9mPL71DHghPFLGG6IH48aHWiHraagkaTQHVOpp3lI+1pdc/eavXGqEjP+bSk7p7kqvs4rzFEv37ELp/R7aT9WvRfDc+4VGA5eGmf4HK9iWMd1oz9AogCGtaZAozacjOlS7YnNXc+fWiK/+AUQ3wWb152TDVyKO/Di4yFNRDuS0unRZjpdHcX9F/HbyPj25HhLmfxMEJUY5b45Lrf7bUmkBzpHHxdBj7sOn+/vob0oUFIo6tQozAV4qFIdX1P9FKN2VVhZ3PHWvy6Y9tqj+zlZZdIzg8dMTWM8pB0ZFSSkQRqZkfQnNuzzcH4Y2U2c/2BtGZVJcmbzfV/tZe6g0C9dw9jrhKYq6zydWHaPQUzpG35tPm7viJ0X0AMpla1ecmWTSxE9AO4E6NIatDz3Gg/lo0s7F5vcI/VVg0bEJw1J5yM9oMDpIo2wh3bsX928MFvU/qnkSAftXeBMFB9E4x0Gof/L1ySRwaCem/heE/jLcsZGn1VlQWS4l725rY3+CnTDUrWfG4SwcJTV52X2mC0MMf1T1dTfTKhd4XzWVMpm8UlafD8NMJX1A48cst8cA7soBOg8NXpzZmYbuGSP9+egPDkxKSGdnUChckTmsVQRBUfsMpQCdiXEb27JLx+MRb82wWWhp6qmjlguqdQUDLNnZpYgIenSFQ36D7aNml2WTq8s5Vw4H1jaEi gGwXVjIE Y5kg0Lj2ST2/Lcs6hdQgrDb2vSMGFO77ThaMuiOJgpYeakVo44XgKdPB74IkpFlExyRcIiIawgxOy/qIgxG8gMZG1kqk7uK5L9P5UqSWF2un7t2cNmBCo2ySP1Akzb5Bt8IcuspO3oKg++g6Mam0EL6sdICOSZ6E+7FKRFMAuaNfVJ9CLdhJ8ttDeOYUd9fsd6F+AfZt/EzZ7jhYkEEB50OQoR85x87JIjZvHMF6saVfYK1rRTbi6y8cWGQa3muzEXmvDPSQ2ALTZQMa+AyM+uilucU+s//IjZ7CxLUZ0aXDWwF+NVFVUgN6S5GFie7Ek8EUP68XSFYFP2FfWpizR3gYa+yJsqOxEScRoFb6Sg/dMpEcxyDzJrwD5ybu7DnuOqaiCpIMTTGilsG4= 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: On Mon, Dec 30, 2024 at 05:07:48PM +0800, Qi Zheng wrote: > Several architectures (arm, arm64, riscv and x86) define exactly the > same __tlb_remove_table(), just introduce generic __tlb_remove_table() to > eliminate these duplications. > > The s390 __tlb_remove_table() is nearly the same, so also make s390 > __tlb_remove_table() version generic. > > Signed-off-by: Qi Zheng > --- > arch/arm/include/asm/tlb.h | 9 --------- > arch/arm64/include/asm/tlb.h | 7 ------- > arch/powerpc/include/asm/tlb.h | 1 + > arch/riscv/include/asm/tlb.h | 12 ------------ > arch/s390/include/asm/tlb.h | 9 ++++----- > arch/s390/mm/pgalloc.c | 7 ------- > arch/sparc/include/asm/tlb_32.h | 1 + > arch/sparc/include/asm/tlb_64.h | 1 + > arch/x86/include/asm/tlb.h | 17 ----------------- > include/asm-generic/tlb.h | 15 +++++++++++++-- > 10 files changed, 20 insertions(+), 59 deletions(-) ... > diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h > index 79df7c0932c56..da4a7d175f69c 100644 > --- a/arch/s390/include/asm/tlb.h > +++ b/arch/s390/include/asm/tlb.h > @@ -22,7 +22,6 @@ > * Pages used for the page tables is a different story. FIXME: more > */ > > -void __tlb_remove_table(void *_table); > static inline void tlb_flush(struct mmu_gather *tlb); > static inline bool __tlb_remove_page_size(struct mmu_gather *tlb, > struct page *page, bool delay_rmap, int page_size); > @@ -87,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_ptdesc(tlb, virt_to_ptdesc(pte)); > } > > /* > @@ -106,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_ptdesc(tlb, virt_to_ptdesc(pmd)); > } > > /* > @@ -124,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_ptdesc(tlb, virt_to_ptdesc(pud)); > } > > /* > @@ -142,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_ptdesc(tlb, virt_to_ptdesc(p4d)); > } > > #endif /* _S390_TLB_H */ > diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c > index c73b89811a264..3e002dea6278f 100644 > --- a/arch/s390/mm/pgalloc.c > +++ b/arch/s390/mm/pgalloc.c > @@ -193,13 +193,6 @@ void page_table_free(struct mm_struct *mm, unsigned long *table) > pagetable_dtor_free(ptdesc); > } > > -void __tlb_remove_table(void *table) > -{ > - struct ptdesc *ptdesc = virt_to_ptdesc(table); > - > - pagetable_dtor_free(ptdesc); > -} > - > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > static void pte_free_now(struct rcu_head *head) > { ... > diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h > index 709830274b756..69de47c7ef3c5 100644 > --- a/include/asm-generic/tlb.h > +++ b/include/asm-generic/tlb.h > @@ -153,8 +153,9 @@ > * > * Useful if your architecture has non-page page directories. > * > - * When used, an architecture is expected to provide __tlb_remove_table() > - * which does the actual freeing of these pages. > + * When used, an architecture is expected to provide __tlb_remove_table() or > + * use the generic __tlb_remove_table(), which does the actual freeing of these > + * pages. > * > * MMU_GATHER_RCU_TABLE_FREE > * > @@ -207,6 +208,16 @@ struct mmu_table_batch { > #define MAX_TABLE_BATCH \ > ((PAGE_SIZE - sizeof(struct mmu_table_batch)) / sizeof(void *)) > > +#ifndef __HAVE_ARCH_TLB_REMOVE_TABLE > +static inline void __tlb_remove_table(void *table) > +{ > + struct ptdesc *ptdesc = (struct ptdesc *)table; > + > + pagetable_dtor(ptdesc); > + pagetable_free(ptdesc); > +} > +#endif > + > extern void tlb_remove_table(struct mmu_gather *tlb, void *table); > > #else /* !CONFIG_MMU_GATHER_HAVE_TABLE_FREE */ For s390: Acked-by: Alexander Gordeev Thanks!