From patchwork Wed Jan 8 06:57:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13930208 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 503E8E77188 for ; Wed, 8 Jan 2025 07:03:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEE1E6B00B2; Wed, 8 Jan 2025 02:03:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D77386B00B3; Wed, 8 Jan 2025 02:03:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC9FB6B00B4; Wed, 8 Jan 2025 02:03:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9490E6B00B2 for ; Wed, 8 Jan 2025 02:03:43 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6242F1C7E5F for ; Wed, 8 Jan 2025 07:03:43 +0000 (UTC) X-FDA: 82983394326.06.4292F94 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf22.hostedemail.com (Postfix) with ESMTP id 845ADC000A for ; Wed, 8 Jan 2025 07:03:41 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=jmKIbT4L; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf22.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736319821; a=rsa-sha256; cv=none; b=WvdH5T/5zBnY7VnpSTRsBRtntAUxi7OvwCX40dPUgKeRltBUgir6G5C96NPbEoLsGl2F0x hrjMynT6SGuH7QKqiMeiZyoQ/NR0HO5I6sNEUNK2Y2saMvWrabBRR9HsuvVFyXU9ViDEfW 96gsb+bUyJvD4RLoleyGK0cRTXNP7jY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=jmKIbT4L; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf22.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736319821; 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=SmV2C/123ilQKoYc6h41pKDzG2aiaIfZ7nQkaBcWxp0=; b=Zfo2y9p24VC26TiqkRYO4Nb/YRt6uJl8c1OPDkkef/qV6bUEt1JcYjvo7dfN64TW5DIoFF TAZRf41Rhqczxk1pRq33W/UnZRu2wJ6oJmbq4qc6FALBgiBN7nJxF2QZ/Vm3b7ukyDqJ0R 0XxEYiVudEEXCF/87CnW3QzKbs9H0Ds= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2167141dfa1so9535535ad.1 for ; Tue, 07 Jan 2025 23:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1736319820; x=1736924620; 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=SmV2C/123ilQKoYc6h41pKDzG2aiaIfZ7nQkaBcWxp0=; b=jmKIbT4LT4Rpz2ffRDBRSXZV1+SZbGu/RG8jpBiiP5iap9z7loXBI0DMv6MoT4NeR4 roTP422aq5jRwsJURqifTzxLIFdMUh5gQoFhnzIed2ZBN1FVDH7EHS3W91GoE+DZPrhv p5cPGX1foFWOvkGzdIR3lBZfcNsrd3Jle9lDjW8OrzMboMHmNWlC7h/JMznQ0it+s0sr sGqr3tUPJjjPJImD1BysKTFEP3QLAMydhItoz3AHLrkrFxD72x+MiqW39NbLDe+F00XU lqeeEpGHFTV+wBuROev+Dx+j/5Hw3zuWbkOjxtDu8Lp5lBFZcaZ4DhaYbkiD8bMDKT4D CmBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736319820; x=1736924620; 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=SmV2C/123ilQKoYc6h41pKDzG2aiaIfZ7nQkaBcWxp0=; b=hR/ikIaxUDv+kksdBAzzEEnZjgHulM+h9CEksT/zzZkaq7wfIJiMyflYSYqC7hodez E4kZQtErG084ew2SF7sDF4wzUKzYHjF8m7DkoJNad/+/30UU+ynX/LFVCsQ9QESVC4wZ QDQlDENCwTVNwl1mXIqETKl12kAdnQh2aF9MhIeEAiRzJ0Cfwf/a4teU1aX/t1sWiLzi /3ukDzRYegi69IoSVPSrXDgIrIF1rVDXA8+MmjP9AibKQuIlanpyytZ6cDSKJNAqsAdm Wq3I3qxQDNkaerzvdcRW+yy8UNQ3Ee3+Ug7DrRRHFB4pEewbi7JPOdShA097zEdAISZD GMCg== X-Gm-Message-State: AOJu0Yzz6IYwYo+qudEInDv1vt5ukXVwPrFkWVVML48LMATI4hBuFagl RPw82wJ+tCrrkj7MAmxmi88XT1mAQMchPD4lLWT2Sd+9FW6oHUO4O5aLdKrHT0w= X-Gm-Gg: ASbGncsMBpkgbAzn/DKlbHOBVDs7gIZLKEOx4E5u228Kdb45CSBqgpaRNYwchXvxQC7 1aFvSj0NDiRe9piVUE9uu23TWZrgnwgaMh6nUYtudbswGJ+xP8RcszO7BsyIRCRb/yPCd+odwkh W1G9GolTim2OT6cGshvpbbvnQyWLtv+fye6Cf+ji3y1qZ5vT/3Hg7B/JBj4fs+KkyRFjSrZo0D1 77lpqGXlx6hVE8KyDj+mCfK84PkoITSEcSLTy+OXJZt0tRTEPdy91iFQBSUO83sZewc2dMFMxXf Ohq9xlXJlPSDXG3iV06xn1hXV/w= X-Google-Smtp-Source: AGHT+IFPhscn4ro6sBJsBOR2a8pRlJGCRsiSDouRo+43OGNlwIzbjZLHQRkjQ8iB7a2FmZbbQjyk4w== X-Received: by 2002:a17:902:fc46:b0:216:4fad:35d0 with SMTP id d9443c01a7336-21a7a1d4731mr100818035ad.9.1736319820276; Tue, 07 Jan 2025 23:03:40 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dca023a3sm320067275ad.250.2025.01.07.23.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 23:03:39 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, agordeev@linux.ibm.com, kevin.brodsky@arm.com, alex@ghiti.fr, andreas@gaisler.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 Cc: 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, Qi Zheng Subject: [PATCH v5 17/17] mm: pgtable: introduce generic pagetable_dtor_free() Date: Wed, 8 Jan 2025 14:57:33 +0800 Message-Id: <1663a0565aca881d1338ceb7d1db4aa9c333abd6.1736317725.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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 845ADC000A X-Stat-Signature: cnstqhhsnikjwn6a3pd7khgej81dcupj X-HE-Tag: 1736319821-732799 X-HE-Meta: U2FsdGVkX19xrbgMQjmv4QB0e9BDMkoi7t7G2ygwg3rYuKnrwow7T5G4xIQtoyAmZftJRfjRYqUPGcKzan4gtAYs4xSDwUytz5694agS8GU9r2RPKf+DIl10LN6TrmJW9y4l2yZEpC3AItEEct/Rl0QQ78n2yhvu0rI878IN2pcSb6qP7qCuuxM06CMJERRkuo4uVJmgEAwGsAJrEWVB+8U3Je/N+WOVLhw//5bVMzvH9qf9pjmuwSzC8Jhh/eLQudgTDRVbjMeBIWVVfLNp20cdQsKmphmD0DbxswYQRF6f2od1oiLVRZtLRw5sOz+brk/2SZCvIKs8M/w9KPQkYgvE4y3em5Sny+8npcDmbLoJN5BxXIZgGRgaGfimMB1XiNJw0XfN4p9Fqkd7bfCENMbBsVBtkDc1fXBLX1twXDdAs8VKP7nMwx2+MEHDfNE8rNojPVa2Qt7XzBrPsPDRL9NNDMzO+FEFBC5abuxEVli2arLpQ0wnFaFvwnizQ9VG+PTmocBZ1UHJKy15TZPrJWwWL5zmXOpkxMOCb2UG/kc1LWjoMRfgG3q4Eu7XdS5a7e8IJGN+usTXyvkRq5pkqaiiB7B+ITu1DknYDOlJ2OF0vKZkakC9a9mwnRd7t4uTd1QRUL9pKqGFA2GCUtKlJllV8SB55cYWkIp65J9k3GyzXfS6OLjLOPwK/75Dw7GNGVIOiAEWyLbGYoFaB4Brn3KGaWpnQNWG1a6+cN6adkGFyu1kG6DTR/CFrzbxsO0mklv0gI2RxmYdFQGSyzddRM6HWgeeh19Jk9E16AS3ytGiDm8si9MgM3T8/lpCXpb4lwnlKkf58hFFXuOrCFFJKU2Gs+/TdJoUyldogPAZcyIRfiDhKpm/UuzF8o7e0QqZSvJDN+wPSBUkvsPm7iJtCRdo7BqI1wkkDd84pELMDtOMak1nH6LyVTg7M6Sm2hLWq6GNIpCV3xLYWXFHiHv J4qKVTeE OZkQ6ON8/s0hf1T4X5wIZW357K+gBZg4lhlu38gzuMQU29+1Pv85XeGedDf/erQQneG9/IMd6NjN3+DZUb4mZu2DvL1TMt/PUN275m90vk6oWKtcuRzx/WuShC2HdEDkLhnNempeA575IAW2gCwGjcVHsRRkZM2O9+eSaAOZ8ecAPmFeARWW6fWSBiqEsZgJolmeygXD58a1zeJFsU4CsS9jOOd4CRUYfF1Mo5MVWHEhTJNGBgGd7ukcmOD40vqlpv0O6qySlvK2wvELdZPm0nSA8fpcNWG7/umMJj8MHMelAnGkVnlinMcQgGqrjliTYMide5qFJRtbgFYwnzzQPPGHLyXyt5fDCA4clY75rBtJ5JwpZlvnEKAPVZxd0VmFYMi9T3CyNNVWNEj+O4U3J6RJF46C438KaqN+N5j+pC/irkEPQcQdYovAJM5RirnSsCwE6Qc/l94642Jg26Rrhmplqrl55xT5lqUKt6X8Z8LnFVS2qzXT5uYZFUJLOZkn9miYpRP07VPeDJSOXit8mJXFb1SfJk7rmXmsi5WoY4Q7BligLzap/Qew9HUcUfH5DhXUq 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: The pte_free(), pmd_free(), __pud_free() and __p4d_free() in asm-generic/pgalloc.h and the generic __tlb_remove_table() are basically the same, so let's introduce pagetable_dtor_free() to deduplicate them. In addition, the pagetable_dtor_free() in s390 does the same thing, so let's s390 also calls generic pagetable_dtor_free(). Signed-off-by: Qi Zheng Suggested-by: Peter Zijlstra (Intel) Reviewed-by: Kevin Brodsky Acked-by: Alexander Gordeev # s390 --- arch/s390/mm/pgalloc.c | 6 ------ include/asm-generic/pgalloc.h | 12 ++++-------- include/asm-generic/tlb.h | 3 +-- include/linux/mm.h | 6 ++++++ 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c index 3e002dea6278f..a4e7619020931 100644 --- a/arch/s390/mm/pgalloc.c +++ b/arch/s390/mm/pgalloc.c @@ -180,12 +180,6 @@ unsigned long *page_table_alloc(struct mm_struct *mm) return table; } -static void pagetable_dtor_free(struct ptdesc *ptdesc) -{ - pagetable_dtor(ptdesc); - pagetable_free(ptdesc); -} - void page_table_free(struct mm_struct *mm, unsigned long *table) { struct ptdesc *ptdesc = virt_to_ptdesc(table); diff --git a/include/asm-generic/pgalloc.h b/include/asm-generic/pgalloc.h index 4afb346eae255..e3977ddca15e4 100644 --- a/include/asm-generic/pgalloc.h +++ b/include/asm-generic/pgalloc.h @@ -109,8 +109,7 @@ static inline void pte_free(struct mm_struct *mm, struct page *pte_page) { struct ptdesc *ptdesc = page_ptdesc(pte_page); - pagetable_dtor(ptdesc); - pagetable_free(ptdesc); + pagetable_dtor_free(ptdesc); } @@ -153,8 +152,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) struct ptdesc *ptdesc = virt_to_ptdesc(pmd); BUG_ON((unsigned long)pmd & (PAGE_SIZE-1)); - pagetable_dtor(ptdesc); - pagetable_free(ptdesc); + pagetable_dtor_free(ptdesc); } #endif @@ -202,8 +200,7 @@ static inline void __pud_free(struct mm_struct *mm, pud_t *pud) struct ptdesc *ptdesc = virt_to_ptdesc(pud); BUG_ON((unsigned long)pud & (PAGE_SIZE-1)); - pagetable_dtor(ptdesc); - pagetable_free(ptdesc); + pagetable_dtor_free(ptdesc); } #ifndef __HAVE_ARCH_PUD_FREE @@ -248,8 +245,7 @@ static inline void __p4d_free(struct mm_struct *mm, p4d_t *p4d) struct ptdesc *ptdesc = virt_to_ptdesc(p4d); BUG_ON((unsigned long)p4d & (PAGE_SIZE-1)); - pagetable_dtor(ptdesc); - pagetable_free(ptdesc); + pagetable_dtor_free(ptdesc); } #ifndef __HAVE_ARCH_P4D_FREE diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 53ae7748f555b..e402aef79c93e 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -213,8 +213,7 @@ static inline void __tlb_remove_table(void *table) { struct ptdesc *ptdesc = (struct ptdesc *)table; - pagetable_dtor(ptdesc); - pagetable_free(ptdesc); + pagetable_dtor_free(ptdesc); } #endif diff --git a/include/linux/mm.h b/include/linux/mm.h index cad11fa10c192..94078c488e904 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3001,6 +3001,12 @@ static inline void pagetable_dtor(struct ptdesc *ptdesc) lruvec_stat_sub_folio(folio, NR_PAGETABLE); } +static inline void pagetable_dtor_free(struct ptdesc *ptdesc) +{ + pagetable_dtor(ptdesc); + pagetable_free(ptdesc); +} + static inline bool pagetable_pte_ctor(struct ptdesc *ptdesc) { struct folio *folio = ptdesc_folio(ptdesc);