From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F5B14C10F3 for ; Tue, 13 Oct 2026 06:34:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791873254; cv=none; b=KxHy9Cx1epJpKaC/pNS0EngzTJ5zRnfT+vTgMyy7Xor9JwceLQijfTSkLjxFYgpVUHpRtvMxjdewwWPZJM1QHrCGrPpmqD3QrzEGgB2XKS0OmVBpdmQ5nIMt9FrG8KyTLhJXTxppMCm7abUK22289Yrj/hm3USnbFvDG8vWMfEM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791873254; c=relaxed/simple; bh=x3TJ+nLYXw+aqTgNhbnY0u+0hp8FGUc5AIcm44+MuiU=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=mza+TqETeWtf3qqW6ENYBMJMyw2vhAvrPU9I7yH0i7e6x4cIbHlufCtQB9q5yxPh5WKYhMdjDYCOfP1uT49e+0IKETtiv7GvHnpVqawuZMwCAQSAVDlav1JpN4yPHEXnDo/EaB5Mk2omydr+Ct9oFjV3lU6mdQ79bELmjIj1Pw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=jPEz53G9; arc=none smtp.client-ip=95.215.58.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="jPEz53G9" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=x3TJ+nLYXw+aqTgNhbnY0u+0hp8FGUc5AIcm44+MuiU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1791873249; v=1; x=1792478049; b=jPEz53G9zFtMf7S7MMA3ep20v99EcICky/EP9W6meqhELt5OpbuudGf6WopZUAQNGX9cbUKp oL5ue2WlC4wtiqVIRa6KGdXuVmtzRp5adDL+7FzQKnKieXPXu4d223bjJvrQA680vlem2AgFhI7 Sdrm3rr1ohq7fHe9xPgdcgq0= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 4af039548b386c01; Tue, 13 Oct 2026 06:34:09 +0000 X-Mizu-Trace-ID: 4af039548b386c01 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.100.1.1.12\)) Subject: Re: [PATCH v2 1/4] mm: fix missing page-table destructor in pagetable_free() From: Muchun Song In-Reply-To: <3ab63358-8bbe-4457-b21c-bb81bca804cc@gmail.com> Date: Tue, 13 Oct 2026 14:33:49 +0800 Cc: Andrew Morton , Muchun Song , David Hildenbrand , Oscar Salvador , Dave Hansen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , Catalin Marinas , Will Deacon , Mark Rutland , Kevin Brodsky , Alexander Gordeev , Alistair Popple , linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <2B2F2818-9309-450B-A2A4-9F53D802F1C6@linux.dev> References: <20261010112457.49485-1-songmuchun@bytedance.com> <20261010112457.49485-2-songmuchun@bytedance.com> <145CD5DC-6457-4E1E-8B9D-AE7D1EDB0AB8@linux.dev> <3ab63358-8bbe-4457-b21c-bb81bca804cc@gmail.com> To: "Jose A. Perez de Azpillaga" X-Mailer: Apple Mail (2.3901.100.1.1.12) > On Oct 13, 2026, at 01:21, Jose A. Perez de Azpillaga = wrote: >=20 > On 10/12/26 2:55 PM, Muchun Song wrote: >>=20 >>=20 >>> On Oct 12, 2026, at 19:15, Jose A. Perez de Azpillaga = wrote: >>>=20 >>> On Sat, Oct 10, 2026 at 07:24:54PM +0800, Muchun Song wrote: >>>> Since commit 49f599666420 ("mm: call ctor/dtor for kernel PTEs"), >>>> pte_alloc_one_kernel() runs the page-table constructor for kernel = PTE >>>> tables. >>>>=20 >>>> HVO (HugeTLB Vmemmap Optimization) uses pte_alloc_one_kernel() when >>>> splitting a PMD. Restoring the vmemmap backing pages does not = collapse >>>> the PTE table, so a later memory hot-remove eventually frees it = through >>>> pagetable_free() on x86-64. That releases the page without running = the >>>> matching destructor and leaves NR_PAGETABLE elevated. >>>>=20 >>>> Make pagetable_free() detect constructor-backed pages and run the >>>> destructor before releasing their memory to fix the problem. >>>>=20 >>>> Fixes: 49f599666420 ("mm: call ctor/dtor for kernel PTEs") >>>> Cc: stable@vger.kernel.org >>>=20 >>> is the x86 case covered for 6.16-6.18? as far as I can see, x86 >>> free_pagetable() only uses pagetable_free() since bf9e4e30f353 >>> ("x86/mm: use pagetable_free()") in v6.19, so the backport wouldn't >>> change anything there. or am I missing something? >>=20 >> Yes, you are absolutely right =E2=80=94 thanks for catching this. >>=20 >> I double-checked and indeed x86's free_pagetable() only starts using >> pagetable_free() since bf9e4e30f353 ("x86/mm: use pagetable_free()"), >> which landed in v6.19. So for 6.16-6.18 the prerequisite is not = present >> and the backport would be a no-op there. >>=20 >> The correct trailer is: >>=20 >> Cc: # 6.16-6.18: bf9e4e30f353: x86/mm: use = pagetable_free() >=20 > also, bf9e4e30f353 alone leaks PMD-sized vmemmap pages on those trees, > it needs 39406c05f8f1 ("x86/mm: Fix freeing of PMD-sized vmemmap = pages") > as well :) Yeah, you are so meticulous. >=20 > Reviewed-by: Jose A. Perez de Azpillaga >=20 Thanks. > --=20 > cheers, > jose a. p-a