From patchwork Mon Dec 23 09:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13918670 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 DA7DFE7718B for ; Mon, 23 Dec 2024 09:44:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 757FC6B0099; Mon, 23 Dec 2024 04:44:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 707746B009A; Mon, 23 Dec 2024 04:44:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A9626B009B; Mon, 23 Dec 2024 04:44:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3A50A6B0099 for ; Mon, 23 Dec 2024 04:44:10 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BCBF08107D for ; Mon, 23 Dec 2024 09:44:09 +0000 (UTC) X-FDA: 82925737104.16.614BBEB Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf10.hostedemail.com (Postfix) with ESMTP id 5DAC6C0002 for ; Mon, 23 Dec 2024 09:43:51 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=fLDg3Ytl; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.177 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=1734947012; a=rsa-sha256; cv=none; b=qFvpg5gSMEpwPTnwPgg4Uzgaq5/kmY0ZnhM53mB85QOkyX6KNaZY8S2SnwNABu076of+cF t7dyKeWmYfFAmGi5i+LE79owpnnxmlpnCN0WAG56D8KL+IBPqBus9+K+hQQzXUogX/6bXD Cqc7/0WUnQuWPZPPksYWU7NaHUHEkug= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=fLDg3Ytl; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.177 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=1734947012; 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=eYmLHVK0AtU6ilI7ucnXt5jLNeYE7S1uMrvnVL/VK/o=; b=aouRqdGP514gg/3A82li6DxlEN4YmfB5bAULvZztX/BxU0nHYA6wqfJg/PWItuUShwQaEI 7dptwb+PIxOTCWBbFxtJUfkcs3A7E7QfPpgGgdYBDItDXdOaqjXtVSxHPpfVhba7qKlkC0 gh4BLdiDgM7hvz9y8v+AVB0iW/7B7nw= Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7fd526d4d9eso3050886a12.2 for ; Mon, 23 Dec 2024 01:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734947047; x=1735551847; 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=eYmLHVK0AtU6ilI7ucnXt5jLNeYE7S1uMrvnVL/VK/o=; b=fLDg3Ytl905tWOAqwyvidw+NuT607izuH04XFclQF6m1vA9u2YdoPBJRUw/wW34Ag0 VnnZfO/wdCj5MwRfGXBvONCvGpMfHstSkA8tbK5U5o7t7GwxI4bfSdbpfoKX9ebASPum rGCo9IYMKfsiqGHSPZNckquNESace4gfsM0DOmdpwyAIkX2JNupjL8oeceExGS/BKDKI 30j1sY6Ww8DWKJM/aIHGV2xpbCFJXvGUvSq827nDRcKaC/2prOVi8tvc98QiKJNiF9Bi 0mMkHU19vYbmmysHwLu/29AuiFLwgxbzGns1uBMTvWBGeHUmgs6IYOV6DrqqE9H6zlyq GIUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734947047; x=1735551847; 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=eYmLHVK0AtU6ilI7ucnXt5jLNeYE7S1uMrvnVL/VK/o=; b=eIz4B+/zZrqfJbh6jW03xFos1FbFPAOz77Gc6NHvd/GwEswCD19nLPw4ypmlZyakgD GLtGJENzkips0PF8k00ivXX7pWDQJYjHBo9GN+J7Uh9CeCAbVxB62o6F6EayqpopOcOf qt1trqJPQW9Ur99C9pFZvErfxSae7qh27DeaQDRqiZVRSJef+dCSeMGqbBVy0U0Gr99y jyWYXaHxwFKIZlV5anj6cYn6QLlnL6dYsvGEE09awHms9t571d9rowQZwi4bsIQtEDOZ +XWqKq0QmvZFzTr25Zi/ccWlr32pAjiplTfHZprbQ+lBBts/gXnS453Lm+bknCupnB2D Hs7w== X-Gm-Message-State: AOJu0YxjRamEvhb8mXQ/cHJL46XVFCSdR5xkY7VlsJlWNioK4ako1Hkv m1Kr0EL3X7o5P7mAKpOeQ0L7VL+h4CtPU/9eCq6EgUk+37FvYtkgdEb9qz5S9WM= X-Gm-Gg: ASbGncucAZL73AIS3JUqRV6EzIFuoYvcXQsTDjHy0Jx39ZlfAL+73xY6afW0YJUEkt5 /xZmbpnuGhtJV2zTuy5wWNEFFRFt2/LCoHfaNs+/NiVLmNevJyxKqduPtJZtgGsSGDjQqkn55uY k/KTtmjcc/aOy4beLPjfX/6PNqeoQBm4+Z1Tr4yzVBzMMAoSB/vNJQAWWhRWPfFTfMF/st3XzDd SjQHbFu26EGsYO2g5g3T5M9HsCnKuNnti3Zft0BSbBfaThqIUbjOgnOL1TC4E3SLyTEwlI6nkeZ CdGMdPLtr4F4rrSzMD1Jng== X-Google-Smtp-Source: AGHT+IEE3DAo82DBKWUM6FD2Qxwd8GTGkBziQ/dfcNtaRbY+efEiB7FXaTM2aY8g2l19VVq60zkLag== X-Received: by 2002:a05:6a20:7f82:b0:1e0:d575:8d4f with SMTP id adf61e73a8af0-1e5e081c5acmr19810935637.37.1734947046731; Mon, 23 Dec 2024 01:44:06 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.150]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8486c6sm7468309b3a.85.2024.12.23.01.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 01:44:06 -0800 (PST) From: Qi Zheng To: peterz@infradead.org, agordeev@linux.ibm.com, kevin.brodsky@arm.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 v3 05/17] arm64: pgtable: use mmu gather to free p4d level page table Date: Mon, 23 Dec 2024 17:40:51 +0800 Message-Id: <7c12112047ac230809aacd0379259414b9b0d3a3.1734945104.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: 5DAC6C0002 X-Stat-Signature: qhmejf5epe4bjy63yhrdfiriu4fkza79 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734947031-918296 X-HE-Meta: U2FsdGVkX19DnBxp3F5E7YGHYUjihQbEB8iPqdiTYNyy/BFZRbMOVm1uPPurza4YGMnHqt3fTfXjF6IrRy7r9nJcFUYevr/kEW627k1WFnjcFoDJ/N3zVkscjT8hNW2Srko9dxJbXPoy5INmNQckVzs/Ypqn7V04MScOYRDHlC8KJNoOuGkcCtNpnx7cBhIhXsdQWm8DJow6CtGhGfz+e2I1sD2tzL3OopcFEHHQmHy9teEvuNxKz6yb3T9FQ4uqLuIxkSrqu1aPrKP1eDHgeUVf+rK72tZ8vSrOljXuribmoHN/uqtt2IqRMulGt7FjkkRDaT6OGhYNH8fxqXuMGSoXg5vjM2M2Kji5cbVQ3EBFkw9kXCoAGCV41bAbC/+A8aLJiDgU0EpBOAZsnszRHHytN35dLjReRZQNZf1JgqHiFgG6GAyVKCNFsI42apdj4NpSwK9LnWjHVjO0LmLiy0nkcNX4fdLI6vgX+tq2XYiiZlcqq+4Gan7aC9PD/BfenEXF7WhlymQnSZ7r9LZnWWku5lixVCaNQtBWF2jRa9Y0pUIbB5E6Vouiu04+Wxm2xc5j75ySvMRReb9dopxSpSMfcsNk+6MOpGnmUN+0jlYJwJJiruZD6gz3b5xdH9D+XiRSqG9xaIk/DZCjPQPnCKNiq7LvaUOn/6iEtM5vUA5Dm7qAbeg+kgmK1iOaty3juBUwu9vSR4lfcKE6D0EpV4qvKnCpRNIqDjGYge3TqiLl92sNhKBUmYw9nMtMNvpe/diqmuC0pVOCuGpwIIcjb6EuA2c6e7MdjeltjJuJD+YCsji66xqSpui55Iz1tUKoCK5Og8Wwlfg2cKv0Hhg3LNgFSJ8u3fyq15jMrEUUg8/qnmA/mifngC93hnXubkwH96bwCorNflj3NsZtlqf6xiob1ESNZdcJ9L0e+T3Nc25L0RU7xmCX3GaZcfKlXHR03DUh6/2M8yLSTRorCBQ xNw3jv8M E6ypdbZu8lssYcafCo0mUNoppRG6NEXSrHaxsaXwCNlwC70AbTicJxK4sy2/V3T1wBuHX6DyriTVQNmDuS63gZh4G3RmqzS4YJRFz7JIb8oPpp+E3jBxp+IaTFLRAfPmF8+43cBeHtQwnMc7v/cs1NEUxiCtpCKfauzC/b49xbTxEQ7U7+YfD1WK5WwqEOd6xROgSdzVGaaTq3gKPJTfbT1lNHHy3M7X0In2VA7nkWcOMTfGE1wu70pmEOQu8ELfnJKdy+wBVoN6yeV1kEn//UAMC2sOKnVPSRiqD2ENePtGM81wlu9yFA4tfFjXNVe5vvwdJ5r1vM84icfuKrO5G9SEV+7BHzYVabPVitvw4U0c+Ze/Y1DDLzc5B47uDbwdMMmsM5psaaxrkw1fCdSlQaf6Y61RGa/801Jsllcs+nF77nM4UgyqYnJVPvAanyNIdVNvo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000463, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Like other levels of page tables, also use mmu gather mechanism to free p4d level page table. Signed-off-by: Qi Zheng Originally-by: Peter Zijlstra (Intel) Cc: linux-arm-kernel@lists.infradead.org --- arch/arm64/include/asm/pgalloc.h | 1 - arch/arm64/include/asm/tlb.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h index 2965f5a7e39e3..1b4509d3382c6 100644 --- a/arch/arm64/include/asm/pgalloc.h +++ b/arch/arm64/include/asm/pgalloc.h @@ -85,7 +85,6 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgdp, p4d_t *p4dp) __pgd_populate(pgdp, __pa(p4dp), pgdval); } -#define __p4d_free_tlb(tlb, p4d, addr) p4d_free((tlb)->mm, p4d) #else static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t p4dp, pgdval_t prot) { diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h index a947c6e784ed2..445282cde9afb 100644 --- a/arch/arm64/include/asm/tlb.h +++ b/arch/arm64/include/asm/tlb.h @@ -111,4 +111,18 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp, } #endif +#if CONFIG_PGTABLE_LEVELS > 4 +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; + + pagetable_p4d_dtor(ptdesc); + tlb_remove_ptdesc(tlb, ptdesc); +} +#endif + #endif