Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	stable@vger.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 4/4] arm64/mm: fix destructor for unconstructed hotplug page tables
Date: Sat, 10 Oct 2026 11:43:23 +0800	[thread overview]
Message-ID: <DDFF90A3-86D7-42D6-844A-5D29A44BAB4D@linux.dev> (raw)
In-Reply-To: <d47bdf83-1db4-4601-a516-7e23488ea9cf@kernel.org>



> On Oct 10, 2026, at 04:43, David Hildenbrand (Arm) <david@kernel.org> wrote:
> 
> On 10/8/26 09:30, Muchun Song wrote:
>> Commit c594b83457cc ("arm64: mm: call pagetable dtor when freeing
>> hot-removed page tables") made free_hotplug_pgtable_page()
>> unconditionally run the page-table destructor. This matches page tables
>> allocated by the arm64 mapping code, which runs the corresponding
>> constructors.
>> 
>> However, arm64 also uses the generic sparse-vmemmap population code.
>> Runtime intermediate page tables allocated by that code do not run a
>> page-table constructor.
> 
> Why do we have that inconsistency? It seems to cause pain :)

Ha, yeah, it's a bit painful :)

I think it's because the arch folks didn't realize that vmemmap population
does not run a page-table constructor.

But the inconsistency is temporary — I deliberately kept it so the bug fixes
are easier to backport. After those fixes land, I'll follow up with the
unified series, which will make vmemmap population run a page-table
constructor.

> 
>> Freeing one during memory hot-remove therefore
>> runs a destructor without a matching constructor and corrupts
>> NR_PAGETABLE accounting.
>> 
>> Use PageTable() to run the destructor only for page-table pages whose
>> constructor initialized them. This keeps the arm64-created page-table
>> lifecycle balanced while safely freeing constructor-free vmemmap tables.
>> 
>> Fixes: c594b83457cc ("arm64: mm: call pagetable dtor when freeing hot-removed page tables")
>> Cc: stable@vger.kernel.org
>> Assisted-by: LLM
>> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>> ---
>> arch/arm64/mm/mmu.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
>> index 7343ac9294f8..688b33095651 100644
>> --- a/arch/arm64/mm/mmu.c
>> +++ b/arch/arm64/mm/mmu.c
>> @@ -1495,7 +1495,8 @@ static void free_hotplug_page_range(struct page *page, size_t size,
>> 
>> static void free_hotplug_pgtable_page(struct page *page)
>> {
>> - 	pagetable_dtor(page_ptdesc(page));
>> + 	if (PageTable(page))
>> + 		pagetable_dtor(page_ptdesc(page));
>> 	free_hotplug_page_range(page, PAGE_SIZE, NULL);
> 
> That results in a __free_pages() for  ones allocated by sparse-vmemmap
> population code. Are we sure that's the right thing to do?

Good point. free_hotplug_pgtable_page() is used to free intermediate
page-table pages, so pagetable_free() is the more appropriate interface
here.

> 
> This is all so inconsistent and confusing :(

Yeah, so I'm working on removing these inconsistencies.

Thanks,
Muchun

> 
> -- 
> Cheers,
> 
> David




  reply	other threads:[~2026-10-10  3:43 UTC|newest]

Thread overview: 22+ 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 ` [PATCH 1/4] x86/mm: fix missing pgtable destructor for vmemmap tables Muchun Song
2026-10-08  8:32   ` Muchun Song
2026-10-09 20:29     ` David Hildenbrand (Arm)
2026-10-10  3:44       ` Muchun Song
2026-10-09 20:33   ` David Hildenbrand (Arm)
2026-10-09 20:36     ` David Hildenbrand (Arm)
2026-10-10  3:49       ` Muchun Song
2026-10-09 20:54   ` Dave Hansen
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-09  6:09   ` Björn Töpel
2026-10-09 14:14     ` Muchun Song
2026-10-09 20:37   ` David Hildenbrand (Arm)
2026-10-10  2:58     ` Muchun Song
2026-10-08  7:30 ` [PATCH 3/4] riscv/mm: fix missing destructor for hotplug PUD tables Muchun Song
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-09 20:43   ` David Hildenbrand (Arm)
2026-10-10  3:43     ` Muchun Song [this message]
2026-10-09 20:48 ` [PATCH 0/4] mm: Fix page-table teardown during memory hot-remove Dave Hansen
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=DDFF90A3-86D7-42D6-844A-5D29A44BAB4D@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox