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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C42AC02183 for ; Tue, 14 Jan 2025 02:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Q3uCzTDF/NUXWi9pKun3Q1ZeVpbVlQmIUTgvJ2reRXQ=; b=NXIW6+ZL8jTyCN9t/c37RoAhTX sK1NcuUnTTrRMyriFlWsqG+TFATxAAL88U1AR7H1+kAybHVOFqq47P+/rY+xdmqYwXshx7ber180o RA+Si52rdOpGs7tHCWfbAhOXlsbbyV+iCSNr93TtSLdo4oFeHMKZ11xPaZEaxAejcaMRhpcucndow rKbLV4DmpHL+VgFmEfUyzyCLbsVWvJ75voaors+CwJajTkwVePbbESbKoDm5mr5K80nmd+DTdgAG0 2sj7z83sUXFujRBPwLcUK2eiaFw40exdZHcshX20k+KD6iN3RA3LglUR5nqnYCgyfYstXYDgOSLg+ vv5Lt+BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tXWfQ-00000007FcR-13Gm; Tue, 14 Jan 2025 02:28:32 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tXWeB-00000007FFJ-3INz for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2025 02:27:16 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-21680814d42so72595075ad.2 for ; Mon, 13 Jan 2025 18:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1736821632; x=1737426432; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Q3uCzTDF/NUXWi9pKun3Q1ZeVpbVlQmIUTgvJ2reRXQ=; b=K8aFXw7gyJhWX0ZBNHlubOLIyYeZADf7IRPumXDNCzaApV1dG46yEU2I1D87/q3gwc srhCA0xEEMcYalOoXcZnxIJxvEJIzdTwYP6m6g5b7g4cbkUxD+t6+RKFCjn735RnPelR qtQq7mlAfQ7NAF95IifDQz3IbLAZKqUGk0CicxngD/MjebqfLMaKaQBU3RnjOy58mBkq f0g3xr0RFFmBUoTtG9a1raVhnDVswyKqZb/eSlkxfWc6qwn0hL1mXi4mvDVQRnlM6IYm AX1Jdhm+JmSDI2s4wdU5S5ZXU9i2HCUuzm+ns+vwLuRUT9keuRyh8dv7Qjqp467G+kAQ OtMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736821632; x=1737426432; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Q3uCzTDF/NUXWi9pKun3Q1ZeVpbVlQmIUTgvJ2reRXQ=; b=rd+CFp0TqyKkxq68dQoS92XaLw4ixSd9w4uWfE52msI5FlmvOgn884OUZWWqw/yE3b 5qKGL1TpPyWvGtQUcXuXoAaankxmWTPyHlF5bjt577OqxB/LBLm6eqKz+6Zrw/D/Jt3u eZAYJptBOW6DU/GpGKhRD2birQDKv4zw+FYuedBeUYkzlc6sHEshCjx/yu2IPeAT2IDP X/KoZeXrFqDV2TVIsPI0qNJemk2iSMHvrFaDa9ptnCP3fuG0ShWEKpqksFs+y3D5vvBS mjczJYGaFOZvctMG//a2ZdWN7E7GHyPWpz/o3wan7OvbzW5SXRjTQ75u1gtSkjyPg14h k85w== X-Forwarded-Encrypted: i=1; AJvYcCVgxZyyf/mee9zamw1HKhRWk6apTnSWAVr10/XYE9r2aa6LD9FPUSVs6+50z4fzyBfw2MbVDLE5gXHyoGGsO5zG@lists.infradead.org X-Gm-Message-State: AOJu0Yyuy4z84O5YR2iQn08EIaXms357pu3o94u0i+kKDMcwgBm24WV+ y3V3QyeLEvQOQy+6scmwSYjvKvLvCwdHvhV0o30LTUIvKKOb4HpX9QEzcaCUCEM= X-Gm-Gg: ASbGncvm5W5JS67Vnu8tlg06SlsCd+jROqHNaRd77JqwUV/oKEnbdmEliSdO66WDuLX 5O1giz6PX8Bh2MB9RZhLrWYjVx35OMI6QYm4kHn5/GyRc/zNPMt9vsQRys0bTtU4rDOk4v4Ga09 gkIQSUXZMMI3IHuiyVWM6Kudz6zn4L9c0ubtWVCFmn6YZ8LhMdfN/vmRAB7LUdUDC9goMqrCv+i TjI6A1kmregOX5+G5HG7AGU2YFcklbAcXDys3/uZslbKKIUM8MpEW+IA9BFkpWXIx3fS3BA0N2y 9EUZ X-Google-Smtp-Source: AGHT+IFszANM2ttg3bHXqwu4kokOxCLHcRwKXlC7FRtBmzrGdqYoySfArdJur+xTrJx3xY86w59zAA== X-Received: by 2002:a05:6a20:7f8a:b0:1db:de38:294b with SMTP id adf61e73a8af0-1e88d2f6820mr38362107637.38.1736821632027; Mon, 13 Jan 2025 18:27:12 -0800 (PST) Received: from [10.84.148.23] ([63.216.146.178]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d4056a5e8sm6847007b3a.53.2025.01.13.18.26.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 18:27:11 -0800 (PST) Message-ID: Date: Tue, 14 Jan 2025 10:26:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 05/17] arm64: pgtable: use mmu gather to free p4d level page table To: Will Deacon Cc: 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, 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 References: <3fd48525397b34a64f7c0eb76746da30814dc941.1736317725.git.zhengqi.arch@bytedance.com> <20250113162600.GA14101@willie-the-truck> Content-Language: en-US From: Qi Zheng In-Reply-To: <20250113162600.GA14101@willie-the-truck> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250113_182715_830975_89A79294 X-CRM114-Status: GOOD ( 15.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Will, On 2025/1/14 00:26, Will Deacon wrote: > On Wed, Jan 08, 2025 at 02:57:21PM +0800, Qi Zheng wrote: >> 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) >> Reviewed-by: Kevin Brodsky >> 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); >> +} > > Should we update p4d_free() to call the destructor, too? It looks like > it just does free_page() atm. The patch #3 introduces the generic p4d_free() and lets arm64 to use it. The patch #4 adds the destructor to generic p4d_free(). So IIUC, there is no problem here. Thanks! > > Will