From patchwork Wed Jan 8 06:57:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13930202 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 41F7DE77188 for ; Wed, 8 Jan 2025 07:02:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB6AE6B00A6; Wed, 8 Jan 2025 02:02:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C40196B00A7; Wed, 8 Jan 2025 02:02:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1DDE6B00A8; Wed, 8 Jan 2025 02:02:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7BA196B00A6 for ; Wed, 8 Jan 2025 02:02:10 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F2DE01C7F5E for ; Wed, 8 Jan 2025 07:02:09 +0000 (UTC) X-FDA: 82983390378.07.6B44222 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf17.hostedemail.com (Postfix) with ESMTP id 0D7CB4000A for ; Wed, 8 Jan 2025 07:02:07 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=cGtZjN5f; spf=pass (imf17.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 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=1736319728; 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=0duyzCo9dAwX01bCrGbAFGgpbJyQOIdvGclplTLFMvs=; b=Gu3SV1tH2DKpsxH56IzVhxQYLHRWY6sJzoPF9RPTQXa6b6vBOQLxI/bJk645AtJpBLnkE7 95tKxeV6Kz5rMxj7rbo6XB5oiNIVdoMrKng8Y6wyW57hMLeSCbUlksl7cxIkqHNeo31/dR 3MbTyyVTwJYfti/QdfLNhGMlhe3yJJw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=cGtZjN5f; spf=pass (imf17.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 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=1736319728; a=rsa-sha256; cv=none; b=GVuDuEgrnCWsRiswZhIDxHGtkVXpCZDPBxMGxD72eNQfLUaJjcmq5QUlycgLA1cueXSBeK 8JDCH46Gcodaq6+tAX+v9KI0mUlxyhxsUU8qdE/YP9pltOkVYMNg43rFusVo45qWMs2yeO axg/axbj571B9+95N9F44SDmSQqVQhE= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-21634338cfdso29972945ad.2 for ; Tue, 07 Jan 2025 23:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1736319727; x=1736924527; 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=0duyzCo9dAwX01bCrGbAFGgpbJyQOIdvGclplTLFMvs=; b=cGtZjN5fyc6fQPN8ZMP6cskBdhWFRp0AUOeqgibwg6CfH7vg7+7cnOkxpWN79KTdwR sQxnaLSYqx5FWuV9pjQD0jMLQaN01+7CEt3U7i6hNoMS0wuXFNS5mwYKIOWenLaLG+Ay /HrGxORP2TUKBDS6ogLkySVc5PJr7+iigHdgHC/ByNzDnrD4DL/uUbciw0J8KjT5LAvs S/Fr/oo18AXw0hiUBjuSxhH7sLgb2agANrKcYzdQbJKK4slddtvIednMjk4ZqSqO9cde EsAvxbMRsN+/tkBAjECRHwn957k1bpqe0O+rB9IoQXY8X4pmTtbFB6DoijmikAlXYy8f ejCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736319727; x=1736924527; 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=0duyzCo9dAwX01bCrGbAFGgpbJyQOIdvGclplTLFMvs=; b=aHbG6vYWuHLvhb7btirI7nECWIA0veh/cVHsaIeKNKPWvcAag92IjjsAHT36/5Ljvh Ui3tuY08GLB56zKFJ+dSI47/l+MFYAlayea1E7Gku8FWllHSLRotemPQKxTyqYQGR2p/ APc/F61mYS9t6R30L1o6G9IMUI0rsqNrWz2r1FPyrWgiGFJFqHL+gIpYFZYIB3slq/8D awCyWvAMxWFkKw9iDX++P3aMWGsjbvRLlZUAJ5LIYA1/IfNUye/DfzlJthgm8FKXUR8j 1vN/kzAkGb1LCFERlb94WhNDfw2cyPWcP8tfDuCey9P5jM6HPe3TgPps7uBynh0cTGc8 WtKQ== X-Gm-Message-State: AOJu0YyuMU6YFRpEHS2JYjIuaTKQC/sjV7B8Xa1k856xc1GHvwSYXPoa f/+1qKSq2Zh/PIzb8Fv72aXvmJAkyVSrFq8dC5dowemoNWak8SOavyCZwcw8Pf0= X-Gm-Gg: ASbGnctIa7WkDdaYDhK+L7WpcPqONs0J26xuTGnjwNTgPrNRMwGj4Pk3PLuJu+LzjZK OhR+WbF4lPxmRTfyPxD16nurWpJCesvKtG9TXlIWeVObQTg1m45wCbcxhnh9jcNXvJGz8wFYyQJ bFPZ0FvJZfSONoorcGVwAuXbk1P5Sxw69R6KOQWCk2g/YNebYYQcIuCsfVVIPYyn9nffGcI50fX 0kPAgiBZ9NQS7QbxqWPclhyTaazudTwiN8WX72AcuoMbPP7aETdysWYT0BFeMU/GEqgJZuXWFBr S08bL18BzO72s48w0vLHBZ4W1ow= X-Google-Smtp-Source: AGHT+IFHWir1ocwTjoDZn2JicpigLOS4g472SxX6v3Yl/J2b2LHmsbTHHj3CMM+1OfXcdbPj30xuWQ== X-Received: by 2002:a17:902:c406:b0:216:7ee9:21ff with SMTP id d9443c01a7336-21a83fdf307mr27262725ad.49.1736319726731; Tue, 07 Jan 2025 23:02:06 -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.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 23:02:06 -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 11/17] x86: pgtable: convert __tlb_remove_table() to use struct ptdesc Date: Wed, 8 Jan 2025 14:57:27 +0800 Message-Id: <39f60f93143ff77cf5d6b3c3e75af0ffc1480adb.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-Rspamd-Queue-Id: 0D7CB4000A X-Rspamd-Server: rspam12 X-Stat-Signature: mkgjky5dszzzi67ku6budxkc8n65nbbd X-Rspam-User: X-HE-Tag: 1736319727-402577 X-HE-Meta: U2FsdGVkX1+vni5AnuPZpsdHlwEsFNkqqglcul8pAYXC314Dev33BDt37X8IYKSsp1Zmh0dF4FBN/fI50VKx6nImXL2QWT5cWYJsN88lGpI57rYMs6Dh2tMCdNPVvUCTgjTwZX+F7nYbkWabPjrtLFCdmV1t0PO3eKrrIe2YC487E2I6ChvyLFOKeomi+X8mHxarh19hLiMAwPBSeC0ynI8SinmbuE7wfEG+wfF9lE4mQsvXwe/uNsNDZ6ho0LA7n4QTcBU73wnNR+gMsc0ltCi+eqSlHoHtM97Ox+adi9pJuNI4JWiCi0AEiRJcvk4HsG52LRmRY+r5imYPCg7q6wSbMfvunu3M50qIQQEoOMJzCmX7QkTEhbbdPVSABXI2eccyBEhpKKpjq3caL+/Ndy9bOkDOk6873q4XT20z0uUHSTxHkKJySQVEOLgxUUGXGNrgpxsPoWnGcUW0XhSFzPIZ3BRMqx1Slbk3HMOXowtYDynLWK4GlgxdPK5Efcn2Eb8YOqB8Ru+jUxywhik8Ty3/IlulyHZU4YDC0NKA1I3h+cncCBijblrt9Ib9r32tcq0LqKZonYEoxEk9vrdQGuLxm7RPS2Q3wNujWMG9V5vVk3zuKf0Od4GbX6fM2mwPfU+jphbTfQylKu+FNybAzkKhsN7XFtZquUx5eNtLED9cRzLm3NKlojefdc51yo30vbd2jqSf/mNKepcc7Z22JGoTPUSzr2EPbb6yR/cie1hxRWqC5pQ5gUlkGlwqMPRsaj82xedbhWMESAGIbnZ2z9EDpfhfeapym5ylvCT8ZLn7vWV3HoMOr2kLF2XsCpUe3dPSsm4ZEQHYcps3TknA68YJlepbbTTPxlz2BHbvYy7a1/B/sTGYfSCYgyzkn5zUhOXlP9mkoJnd9flT4IejIO1ODzW1qZBBIIikv0IVKy/b+mXFWeh0brgfWuuyFGpOJ3dMHaEX+yOweNUcZJC /y+B+3RE JSsC1DbvZdANaBAjv7gLPLlQsMVuWiCHwyMwneMfPMm81kJRsHxTEubINMbUeATtfKNwCIvZylBdlKZICL9UbNNNC3tfx/oR0TlQvzOqV7Zxy4nyEEqa4sdewC1EU6sQo+3NmtgQl0cJxVcnxoiJUSS3YgrgZj2JRIYDKavSwhvnRorXlusmYvSMTA/OsmytV6QijVTUrawJ6P2hP4TukGNYpdnTqS+BdolMZ8dFppKbU7L2nuV1/G8FjKAA/zvclEj6c70cmKjXQar4CthFu5B171ClA+2e3MBdxaErgefNwDU17RKxqTfW6fAFhcfQebBvrD0UqX2VhNECcQulCzNZ2ZxcbsHOnjJFPHGAhMjEHa7pF/rYYutClIFtnXmb3FwrlX1F/V8Vr+wDUvhkooULAqQLfMDFzR9thJMSg/Ko+ImR5I96rAf9jWA== 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: Convert __tlb_remove_table() to use struct ptdesc, which will help to move pagetable_dtor() to __tlb_remove_table(). And page tables shouldn't have swap cache, so use pagetable_free() instead of free_page_and_swap_cache() to free page table pages. Signed-off-by: Qi Zheng Reviewed-by: Kevin Brodsky --- arch/x86/include/asm/tlb.h | 16 +++++++++------- arch/x86/kernel/paravirt.c | 4 +++- arch/x86/mm/pgtable.c | 12 +++++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h index 73f0786181cc9..680ec3d47915a 100644 --- a/arch/x86/include/asm/tlb.h +++ b/arch/x86/include/asm/tlb.h @@ -31,24 +31,26 @@ static inline void tlb_flush(struct mmu_gather *tlb) */ static inline void __tlb_remove_table(void *table) { - free_page_and_swap_cache(table); + struct ptdesc *ptdesc = (struct ptdesc *)table; + + pagetable_free(ptdesc); } #ifdef CONFIG_PT_RECLAIM static inline void __tlb_remove_table_one_rcu(struct rcu_head *head) { - struct page *page; + struct ptdesc *ptdesc; - page = container_of(head, struct page, rcu_head); - put_page(page); + ptdesc = container_of(head, struct ptdesc, pt_rcu_head); + __tlb_remove_table(ptdesc); } static inline void __tlb_remove_table_one(void *table) { - struct page *page; + struct ptdesc *ptdesc; - page = table; - call_rcu(&page->rcu_head, __tlb_remove_table_one_rcu); + ptdesc = table; + call_rcu(&ptdesc->pt_rcu_head, __tlb_remove_table_one_rcu); } #define __tlb_remove_table_one __tlb_remove_table_one #endif /* CONFIG_PT_RECLAIM */ diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 7bdcf152778c0..dc1ab9301d2c6 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -62,7 +62,9 @@ void __init native_pv_lock_init(void) #ifndef CONFIG_PT_RECLAIM static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) { - tlb_remove_page(tlb, table); + struct ptdesc *ptdesc = (struct ptdesc *)table; + + tlb_remove_page(tlb, ptdesc_page(ptdesc)); } #else static void native_tlb_remove_table(struct mmu_gather *tlb, void *table) diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index a6cd9660e29ec..f9516024cbe5d 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -23,7 +23,9 @@ EXPORT_SYMBOL(physical_mask); static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) { - tlb_remove_page(tlb, table); + struct ptdesc *ptdesc = (struct ptdesc *)table; + + tlb_remove_page(tlb, ptdesc_page(ptdesc)); } #else static inline @@ -62,7 +64,7 @@ void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte) { pagetable_dtor(page_ptdesc(pte)); paravirt_release_pte(page_to_pfn(pte)); - paravirt_tlb_remove_table(tlb, pte); + paravirt_tlb_remove_table(tlb, page_ptdesc(pte)); } #if CONFIG_PGTABLE_LEVELS > 2 @@ -78,7 +80,7 @@ void ___pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) tlb->need_flush_all = 1; #endif pagetable_dtor(ptdesc); - paravirt_tlb_remove_table(tlb, ptdesc_page(ptdesc)); + paravirt_tlb_remove_table(tlb, ptdesc); } #if CONFIG_PGTABLE_LEVELS > 3 @@ -88,7 +90,7 @@ void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) pagetable_dtor(ptdesc); paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); - paravirt_tlb_remove_table(tlb, virt_to_page(pud)); + paravirt_tlb_remove_table(tlb, ptdesc); } #if CONFIG_PGTABLE_LEVELS > 4 @@ -98,7 +100,7 @@ void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) pagetable_dtor(ptdesc); paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); - paravirt_tlb_remove_table(tlb, virt_to_page(p4d)); + paravirt_tlb_remove_table(tlb, ptdesc); } #endif /* CONFIG_PGTABLE_LEVELS > 4 */ #endif /* CONFIG_PGTABLE_LEVELS > 3 */