All of lore.kernel.org
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: Muchun Song <songmuchun@bytedance.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	stable@vger.kernel.org, david@kernel.org, osalvador@suse.de,
	dave.hansen@linux.intel.com, luto@kernel.org,
	peterz@infradead.org, tglx@kernel.org, mingo@redhat.com,
	bp@alien8.de, x86@kernel.org, hpa@zytor.com,
	catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
	linux-arm-kernel@lists.infradead.org, pjw@kernel.org,
	palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr,
	linux-riscv@lists.infradead.org, agordeev@linux.ibm.com,
	kevin.brodsky@arm.com, bjorn@rivosinc.com, apopple@nvidia.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] x86/mm: fix missing pgtable destructor for vmemmap tables
Date: Thu, 8 Oct 2026 10:32:58 +0200	[thread overview]
Message-ID: <ECC604FF-E74D-43B1-9105-A6683EEDE558@linux.dev> (raw)
In-Reply-To: <20261008073021.2512665-2-songmuchun@bytedance.com>



> On Oct 8, 2026, at 09:30, Muchun Song <songmuchun@bytedance.com> wrote:
> 
> Since commit 49f599666420 ("mm: call ctor/dtor for kernel PTEs"),
> pte_alloc_one_kernel() runs the page-table constructor for kernel PTE
> tables.
> 
> 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 that table through
> free_pagetable(). That path currently calls pagetable_free() directly
> without decrementing NR_PAGETABLE.
> 
> Use PageTable() to identify constructor-backed tables and run the
> matching destructor before freeing them. Keep reserved and
> constructor-free tables on their existing paths. This also prepares
> vmemmap teardown for generic runtime allocations through the normal
> pgalloc helpers.
> 
> Fixes: 49f599666420 ("mm: call ctor/dtor for kernel PTEs")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
> arch/x86/mm/init_64.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 70e682180291..a3ea627157ab 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1003,6 +1003,8 @@ static void __meminit free_pagetable(struct page *page)
> {
> 	if (PageReserved(page))
> 		free_reserved_page(page);
> + 	else if (PageTable(page))
> + 		pagetable_dtor_free(page_ptdesc(page));

Sashiko mentioned that kernel page table pages and vmemmap pages are
freed to the buddy allocator before their parent entries are cleared
and before the TLB is flushed, creating a dangling pointer window.

That's a a real but pre-existing issue, I will not fix that in this
series.

> 	else
> 		pagetable_free(page_ptdesc(page));
> }
> -- 
> 2.54.0
> 


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Muchun Song <muchun.song@linux.dev>
To: Muchun Song <songmuchun@bytedance.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	stable@vger.kernel.org, david@kernel.org, osalvador@suse.de,
	dave.hansen@linux.intel.com, luto@kernel.org,
	peterz@infradead.org, tglx@kernel.org, mingo@redhat.com,
	bp@alien8.de, x86@kernel.org, hpa@zytor.com,
	catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
	linux-arm-kernel@lists.infradead.org, pjw@kernel.org,
	palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr,
	linux-riscv@lists.infradead.org, agordeev@linux.ibm.com,
	kevin.brodsky@arm.com, bjorn@rivosinc.com, apopple@nvidia.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] x86/mm: fix missing pgtable destructor for vmemmap tables
Date: Thu, 8 Oct 2026 10:32:58 +0200	[thread overview]
Message-ID: <ECC604FF-E74D-43B1-9105-A6683EEDE558@linux.dev> (raw)
In-Reply-To: <20261008073021.2512665-2-songmuchun@bytedance.com>



> On Oct 8, 2026, at 09:30, Muchun Song <songmuchun@bytedance.com> wrote:
> 
> Since commit 49f599666420 ("mm: call ctor/dtor for kernel PTEs"),
> pte_alloc_one_kernel() runs the page-table constructor for kernel PTE
> tables.
> 
> 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 that table through
> free_pagetable(). That path currently calls pagetable_free() directly
> without decrementing NR_PAGETABLE.
> 
> Use PageTable() to identify constructor-backed tables and run the
> matching destructor before freeing them. Keep reserved and
> constructor-free tables on their existing paths. This also prepares
> vmemmap teardown for generic runtime allocations through the normal
> pgalloc helpers.
> 
> Fixes: 49f599666420 ("mm: call ctor/dtor for kernel PTEs")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
> arch/x86/mm/init_64.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 70e682180291..a3ea627157ab 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1003,6 +1003,8 @@ static void __meminit free_pagetable(struct page *page)
> {
> 	if (PageReserved(page))
> 		free_reserved_page(page);
> + 	else if (PageTable(page))
> + 		pagetable_dtor_free(page_ptdesc(page));

Sashiko mentioned that kernel page table pages and vmemmap pages are
freed to the buddy allocator before their parent entries are cleared
and before the TLB is flushed, creating a dangling pointer window.

That's a a real but pre-existing issue, I will not fix that in this
series.

> 	else
> 		pagetable_free(page_ptdesc(page));
> }
> -- 
> 2.54.0
> 



  reply	other threads:[~2026-10-08  8:33 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08  7:30 [PATCH 0/4] mm: Fix page-table teardown during memory hot-remove Muchun Song
2026-10-08  7:30 ` Muchun Song
2026-10-08  7:30 ` [PATCH 1/4] x86/mm: fix missing pgtable destructor for vmemmap tables Muchun Song
2026-10-08  7:30   ` Muchun Song
2026-10-08  8:32   ` Muchun Song [this message]
2026-10-08  8:32     ` Muchun Song
2026-10-09 20:29     ` David Hildenbrand (Arm)
2026-10-09 20:29       ` David Hildenbrand (Arm)
2026-10-10  3:44       ` Muchun Song
2026-10-10  3:44         ` Muchun Song
2026-10-09 20:33   ` David Hildenbrand (Arm)
2026-10-09 20:33     ` David Hildenbrand (Arm)
2026-10-09 20:36     ` David Hildenbrand (Arm)
2026-10-09 20:36       ` David Hildenbrand (Arm)
2026-10-10  3:49       ` Muchun Song
2026-10-10  3:49         ` Muchun Song
2026-10-09 20:54   ` Dave Hansen
2026-10-09 20:54     ` Dave Hansen
2026-10-10  5:11     ` Muchun Song
2026-10-10  5:11       ` Muchun Song
2026-10-08  7:30 ` [PATCH 2/4] riscv/mm: fix hotplug page-table destructor handling Muchun Song
2026-10-08  7:30   ` Muchun Song
2026-10-09  6:09   ` Björn Töpel
2026-10-09  6:09     ` Björn Töpel
2026-10-09 14:14     ` Muchun Song
2026-10-09 14:14       ` Muchun Song
2026-10-09 20:37   ` David Hildenbrand (Arm)
2026-10-09 20:37     ` David Hildenbrand (Arm)
2026-10-10  2:58     ` Muchun Song
2026-10-10  2:58       ` Muchun Song
2026-10-10 12:27       ` David Hildenbrand (Arm)
2026-10-10 12:27         ` David Hildenbrand (Arm)
2026-10-08  7:30 ` [PATCH 3/4] riscv/mm: fix missing destructor for hotplug PUD tables Muchun Song
2026-10-08  7:30   ` Muchun Song
2026-10-09 20:38   ` David Hildenbrand (Arm)
2026-10-09 20:38     ` David Hildenbrand (Arm)
2026-10-08  7:30 ` [PATCH 4/4] arm64/mm: fix destructor for unconstructed hotplug page tables Muchun Song
2026-10-08  7:30   ` Muchun Song
2026-10-09 20:43   ` David Hildenbrand (Arm)
2026-10-09 20:43     ` David Hildenbrand (Arm)
2026-10-10  3:43     ` Muchun Song
2026-10-10  3:43       ` Muchun Song
2026-10-09 20:48 ` [PATCH 0/4] mm: Fix page-table teardown during memory hot-remove Dave Hansen
2026-10-09 20:48   ` Dave Hansen
2026-10-10  9:42   ` Muchun Song
2026-10-10  9:42     ` Muchun Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ECC604FF-E74D-43B1-9105-A6683EEDE558@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=apopple@nvidia.com \
    --cc=bjorn@rivosinc.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@kernel.org \
    --cc=hpa@zytor.com \
    --cc=kevin.brodsky@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=osalvador@suse.de \
    --cc=palmer@dabbelt.com \
    --cc=peterz@infradead.org \
    --cc=pjw@kernel.org \
    --cc=songmuchun@bytedance.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.