We want to remove CONFIG_HAVE_BOOTMEM_INFO_NODE. As a first step,
let's limit the remaining harm to x86 and core code, removing
sparc, ppc and s390 leftovers, starting the stepwise removal by removing
and simplifying some code.
Once a related x86 vmemmap fix [1] is in, we can merge part 2 that will
remove CONFIG_HAVE_BOOTMEM_INFO_NODE entirely.
Tested on x86-64 with hugetlb vmemmap optimization in combination with
KMEMLEAK, making sure that the problem reported in dd0ff4d12dd2 ("bootmem:
remove the vmemmap pages from kmemleak in put_page_bootmem") does not
reappear -- hoping I managed to trigger the original problem.
Heavily cross-compiled, but let's let build bots run on it for a bit.
[1] https://lore.kernel.org/r/20260429-vmemmap-v2-1-8dfcacffd877@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
David Hildenbrand (Arm) (8):
sparc/mm: remove register_page_bootmem_info()
mm/bootmem_info: drop initialization of page->lru
mm/bootmem_info: stop using PG_private
mm/bootmem_info: remove call to kmemleak_free_part_phys()
mm/bootmem_info: stop marking the pgdat as NODE_INFO
mm/bootmem_info: stop marking mem_section_usage as MIX_SECTION_INFO
s390/mm: use free_reserved_page() in vmem_free_pages()
powerpc/mm: remove CONFIG_HAVE_BOOTMEM_INFO_NODE
arch/powerpc/mm/init_64.c | 8 --------
arch/s390/mm/vmem.c | 3 +--
arch/sparc/mm/init_64.c | 20 --------------------
include/linux/bootmem_info.h | 1 -
mm/Kconfig | 2 +-
mm/bootmem_info.c | 25 ++-----------------------
6 files changed, 4 insertions(+), 55 deletions(-)
---
base-commit: e9dd96806dbc2d50a66770b6a86962bd5d601153
change-id: 20260511-bootmem_info_prep-bfc0e7a5b87e
--
Cheers,
David
sparc does not select CONFIG_HAVE_BOOTMEM_INFO_NODE, therefore,
register_page_bootmem_info_node() is a nop.
Let's just get rid of register_page_bootmem_info().
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
arch/sparc/mm/init_64.c | 20 --------------------
1 file changed, 20 deletions(-)
@@ -2477,17 +2476,6 @@ int page_in_phys_avail(unsigned long paddr)return0;}-staticvoid__initregister_page_bootmem_info(void)-{-#ifdef CONFIG_NUMA-inti;--for_each_online_node(i)-if(NODE_DATA(i)->node_spanned_pages)-register_page_bootmem_info_node(NODE_DATA(i));-#endif-}-void__initarch_setup_zero_pages(void){phys_addr_tzero_page_pa=kern_base+
In the past, we used to store the type in page->lru.next, introduced by
commit 5f24ce5fd34c ("thp: remove PG_buddy"). The location changed over
the years; ever since commit 0386aaa6e9c8 ("bootmem: stop using
page->index"), we store it alongside the info in page->private.
Consequently, there is no need to reset page->lru anymore.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
mm/bootmem_info.c | 1 -
1 file changed, 1 deletion(-)
Nobody checks PG_private for these pages, and we can happily use
set_page_private() without setting PG_private. So let's just stop
setting/clearing PG_private.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
mm/bootmem_info.c | 2 --
1 file changed, 2 deletions(-)
The call to kmemleak_free_part_phys() was added in 2022 in
commit dd0ff4d12dd2 ("bootmem: remove the vmemmap pages from kmemleak in
put_page_bootmem").
In 2025, commit b2aad24b5333 ("mm/memmap: prevent double scanning of memmap
by kmemleak") started to use MEMBLOCK_ALLOC_NOLEAKTRACE when allocating
the memmap to skip the kmemleak_alloc_phys() in the buddy.
So remove the call to kmemleak_free_part_phys(). If this would still
be required for other purposes, either free_reserved_page() should take
care of it, or selected users.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
include/linux/bootmem_info.h | 1 -
mm/bootmem_info.c | 1 -
2 files changed, 2 deletions(-)
We removed the last user of NODE_INFO in commit 119c31caa59e ("mm/sparse:
remove !CONFIG_SPARSEMEM_VMEMMAP leftovers for CONFIG_MEMORY_HOTPLUG").
But it really was never used it besides for safety-checks ever since it was
introduced in commit 04753278769f ("memory hotplug: register section/node
id to free"), where we had the comment:
5) The node information like pgdat has similar issues. But, this
will be able to be solved too by this.
(Not implemented yet, but, remembering node id in the pages.)
Of course, that never happened, and we are not planning on freeing the
node data (pgdat/pglist_data), during memory hotunplug.
So let's just stop marking the pgdat as NODE_INFO.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
mm/bootmem_info.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
We never free the ms->usage data for boot memory sections (see
section_deactivate()). And to identify whether ms->usage was allocated
from memblock, we simply identify it by looking at PG_reserved.
Consequently, there is no need to mark ms->usage as MIX_SECTION_INFO.
Let's just stop doing that.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
mm/bootmem_info.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
We never select CONFIG_HAVE_BOOTMEM_INFO_NODE on s390. Therefore,
free_bootmem_page() nowadays always translates to free_reserved_page().
Let's use free_reserved_page() to replace the free_bootmem_page() loop.
We can stop including bootmem_info.h.
Likely, vmemmap freeing code could be factored out into the core in the
future.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
arch/s390/mm/vmem.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
register_page_bootmem_info_node() essentially only calls
register_page_bootmem_memmap(). However, on powerpc that function is a
nop. So there is not benefit in using CONFIG_HAVE_BOOTMEM_INFO_NODE
anymore, let's just drop it.
We can stop including bootmem_info.h.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
arch/powerpc/mm/init_64.c | 8 --------
mm/Kconfig | 2 +-
2 files changed, 1 insertion(+), 9 deletions(-)
@@ -537,7 +537,7 @@ endchoiceconfigMEMORY_HOTREMOVEbool"Allow for memory hot remove"-selectHAVE_BOOTMEM_INFO_NODEif(X86_64||PPC64)+selectHAVE_BOOTMEM_INFO_NODEifX86_64depends onMEMORY_HOTPLUGselectMIGRATION
On Mon, May 11, 2026 at 04:05:35PM +0200, David Hildenbrand (Arm) wrote:
quoted hunk
We never select CONFIG_HAVE_BOOTMEM_INFO_NODE on s390. Therefore,
free_bootmem_page() nowadays always translates to free_reserved_page().
Let's use free_reserved_page() to replace the free_bootmem_page() loop.
We can stop including bootmem_info.h.
Likely, vmemmap freeing code could be factored out into the core in the
future.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
arch/s390/mm/vmem.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
On Mon, May 11, 2026 at 04:05:35PM +0200, David Hildenbrand (Arm) wrote:
quoted
We never select CONFIG_HAVE_BOOTMEM_INFO_NODE on s390. Therefore,
free_bootmem_page() nowadays always translates to free_reserved_page().
Let's use free_reserved_page() to replace the free_bootmem_page() loop.
We can stop including bootmem_info.h.
Likely, vmemmap freeing code could be factored out into the core in the
future.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
arch/s390/mm/vmem.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
On Mon, May 11, 2026 at 04:24:16PM +0200, David Hildenbrand (Arm) wrote:
On 5/11/26 16:21, Heiko Carstens wrote:
quoted
On Mon, May 11, 2026 at 04:05:35PM +0200, David Hildenbrand (Arm) wrote:
quoted
We never select CONFIG_HAVE_BOOTMEM_INFO_NODE on s390. Therefore,
free_bootmem_page() nowadays always translates to free_reserved_page().
Let's use free_reserved_page() to replace the free_bootmem_page() loop.
We can stop including bootmem_info.h.
Likely, vmemmap freeing code could be factored out into the core in the
future.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
arch/s390/mm/vmem.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
...
quoted
What about the implicit call of kmemleak_free_part_phys() which gets
removed with this?
From: Michal Hocko <mhocko@suse.com> Date: 2026-05-12 07:45:20
On Mon 11-05-26 16:05:33, David Hildenbrand wrote:
We removed the last user of NODE_INFO in commit 119c31caa59e ("mm/sparse:
remove !CONFIG_SPARSEMEM_VMEMMAP leftovers for CONFIG_MEMORY_HOTPLUG").
But it really was never used it besides for safety-checks ever since it was
introduced in commit 04753278769f ("memory hotplug: register section/node
id to free"), where we had the comment:
5) The node information like pgdat has similar issues. But, this
will be able to be solved too by this.
(Not implemented yet, but, remembering node id in the pages.)
Of course, that never happened, and we are not planning on freeing the
node data (pgdat/pglist_data), during memory hotunplug.
So let's just stop marking the pgdat as NODE_INFO.
With the last user, shouldn't we simply drop NODE_INFO?
From: Michal Hocko <mhocko@suse.com> Date: 2026-05-12 07:46:13
On Mon 11-05-26 16:05:28, David Hildenbrand wrote:
We want to remove CONFIG_HAVE_BOOTMEM_INFO_NODE. As a first step,
let's limit the remaining harm to x86 and core code, removing
sparc, ppc and s390 leftovers, starting the stepwise removal by removing
and simplifying some code.
Once a related x86 vmemmap fix [1] is in, we can merge part 2 that will
remove CONFIG_HAVE_BOOTMEM_INFO_NODE entirely.
Tested on x86-64 with hugetlb vmemmap optimization in combination with
KMEMLEAK, making sure that the problem reported in dd0ff4d12dd2 ("bootmem:
remove the vmemmap pages from kmemleak in put_page_bootmem") does not
reappear -- hoping I managed to trigger the original problem.
Heavily cross-compiled, but let's let build bots run on it for a bit.
[1] https://lore.kernel.org/r/20260429-vmemmap-v2-1-8dfcacffd877@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
David Hildenbrand (Arm) (8):
sparc/mm: remove register_page_bootmem_info()
mm/bootmem_info: drop initialization of page->lru
mm/bootmem_info: stop using PG_private
mm/bootmem_info: remove call to kmemleak_free_part_phys()
mm/bootmem_info: stop marking the pgdat as NODE_INFO
mm/bootmem_info: stop marking mem_section_usage as MIX_SECTION_INFO
s390/mm: use free_reserved_page() in vmem_free_pages()
powerpc/mm: remove CONFIG_HAVE_BOOTMEM_INFO_NODE
arch/powerpc/mm/init_64.c | 8 --------
arch/s390/mm/vmem.c | 3 +--
arch/sparc/mm/init_64.c | 20 --------------------
include/linux/bootmem_info.h | 1 -
mm/Kconfig | 2 +-
mm/bootmem_info.c | 25 ++-----------------------
6 files changed, 4 insertions(+), 55 deletions(-)
Good clean up. Feel free to add
Acked-by: Michal Hocko <mhocko@suse.com>
to all patches but kmemleak one which I do not feel qualified to judge.
Thanks!
--
Michal Hocko
SUSE Labs
On Mon 11-05-26 16:05:33, David Hildenbrand wrote:
quoted
We removed the last user of NODE_INFO in commit 119c31caa59e ("mm/sparse:
remove !CONFIG_SPARSEMEM_VMEMMAP leftovers for CONFIG_MEMORY_HOTPLUG").
But it really was never used it besides for safety-checks ever since it was
introduced in commit 04753278769f ("memory hotplug: register section/node
id to free"), where we had the comment:
5) The node information like pgdat has similar issues. But, this
will be able to be solved too by this.
(Not implemented yet, but, remembering node id in the pages.)
Of course, that never happened, and we are not planning on freeing the
node data (pgdat/pglist_data), during memory hotunplug.
So let's just stop marking the pgdat as NODE_INFO.
With the last user, shouldn't we simply drop NODE_INFO?
I'll drop the whole thing in part 2.
I actually had both parts together until I stumbled into the vmmemmap x86
freeing issue that now causes conflicts until upstream and synced to the MM tree.
--
Cheers,
David
On Mon 11-05-26 16:05:28, David Hildenbrand wrote:
quoted
We want to remove CONFIG_HAVE_BOOTMEM_INFO_NODE. As a first step,
let's limit the remaining harm to x86 and core code, removing
sparc, ppc and s390 leftovers, starting the stepwise removal by removing
and simplifying some code.
Once a related x86 vmemmap fix [1] is in, we can merge part 2 that will
remove CONFIG_HAVE_BOOTMEM_INFO_NODE entirely.
Tested on x86-64 with hugetlb vmemmap optimization in combination with
KMEMLEAK, making sure that the problem reported in dd0ff4d12dd2 ("bootmem:
remove the vmemmap pages from kmemleak in put_page_bootmem") does not
reappear -- hoping I managed to trigger the original problem.
Heavily cross-compiled, but let's let build bots run on it for a bit.
[1] https://lore.kernel.org/r/20260429-vmemmap-v2-1-8dfcacffd877@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
David Hildenbrand (Arm) (8):
sparc/mm: remove register_page_bootmem_info()
mm/bootmem_info: drop initialization of page->lru
mm/bootmem_info: stop using PG_private
mm/bootmem_info: remove call to kmemleak_free_part_phys()
mm/bootmem_info: stop marking the pgdat as NODE_INFO
mm/bootmem_info: stop marking mem_section_usage as MIX_SECTION_INFO
s390/mm: use free_reserved_page() in vmem_free_pages()
powerpc/mm: remove CONFIG_HAVE_BOOTMEM_INFO_NODE
arch/powerpc/mm/init_64.c | 8 --------
arch/s390/mm/vmem.c | 3 +--
arch/sparc/mm/init_64.c | 20 --------------------
include/linux/bootmem_info.h | 1 -
mm/Kconfig | 2 +-
mm/bootmem_info.c | 25 ++-----------------------
6 files changed, 4 insertions(+), 55 deletions(-)
Good clean up. Feel free to add
Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!
to all patches but kmemleak one which I do not feel qualified to judge.
It's black magic to me as well. I tried to test that scenario in particular and
was not able to trigger the problem.
--
Cheers,
David
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:28:09
On Mon, May 11, 2026 at 04:05:29PM +0200, David Hildenbrand (Arm) wrote:
sparc does not select CONFIG_HAVE_BOOTMEM_INFO_NODE, therefore,
register_page_bootmem_info_node() is a nop.
Let's just get rid of register_page_bootmem_info().
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:28:59
On Mon, May 11, 2026 at 04:05:30PM +0200, David Hildenbrand (Arm) wrote:
In the past, we used to store the type in page->lru.next, introduced by
commit 5f24ce5fd34c ("thp: remove PG_buddy"). The location changed over
the years; ever since commit 0386aaa6e9c8 ("bootmem: stop using
page->index"), we store it alongside the info in page->private.
Consequently, there is no need to reset page->lru anymore.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:30:23
On Mon, May 11, 2026 at 04:05:31PM +0200, David Hildenbrand (Arm) wrote:
Nobody checks PG_private for these pages, and we can happily use
set_page_private() without setting PG_private. So let's just stop
setting/clearing PG_private.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:35:00
On Mon, May 11, 2026 at 04:05:32PM +0200, David Hildenbrand (Arm) wrote:
The call to kmemleak_free_part_phys() was added in 2022 in
commit dd0ff4d12dd2 ("bootmem: remove the vmemmap pages from kmemleak in
put_page_bootmem").
In 2025, commit b2aad24b5333 ("mm/memmap: prevent double scanning of memmap
by kmemleak") started to use MEMBLOCK_ALLOC_NOLEAKTRACE when allocating
the memmap to skip the kmemleak_alloc_phys() in the buddy.
So remove the call to kmemleak_free_part_phys(). If this would still
be required for other purposes, either free_reserved_page() should take
care of it, or selected users.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:36:39
On Mon, May 11, 2026 at 04:05:33PM +0200, David Hildenbrand (Arm) wrote:
We removed the last user of NODE_INFO in commit 119c31caa59e ("mm/sparse:
remove !CONFIG_SPARSEMEM_VMEMMAP leftovers for CONFIG_MEMORY_HOTPLUG").
But it really was never used it besides for safety-checks ever since it was
introduced in commit 04753278769f ("memory hotplug: register section/node
id to free"), where we had the comment:
5) The node information like pgdat has similar issues. But, this
will be able to be solved too by this.
(Not implemented yet, but, remembering node id in the pages.)
Of course, that never happened, and we are not planning on freeing the
node data (pgdat/pglist_data), during memory hotunplug.
So let's just stop marking the pgdat as NODE_INFO.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:37:31
On Mon, May 11, 2026 at 04:05:34PM +0200, David Hildenbrand (Arm) wrote:
We never free the ms->usage data for boot memory sections (see
section_deactivate()). And to identify whether ms->usage was allocated
from memblock, we simply identify it by looking at PG_reserved.
Consequently, there is no need to mark ms->usage as MIX_SECTION_INFO.
Let's just stop doing that.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:39:01
On Mon, May 11, 2026 at 04:05:35PM +0200, David Hildenbrand (Arm) wrote:
We never select CONFIG_HAVE_BOOTMEM_INFO_NODE on s390. Therefore,
free_bootmem_page() nowadays always translates to free_reserved_page().
Let's use free_reserved_page() to replace the free_bootmem_page() loop.
We can stop including bootmem_info.h.
Likely, vmemmap freeing code could be factored out into the core in the
future.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:43:39
On Mon, May 11, 2026 at 04:05:36PM +0200, David Hildenbrand (Arm) wrote:
register_page_bootmem_info_node() essentially only calls
register_page_bootmem_memmap(). However, on powerpc that function is a
nop. So there is not benefit in using CONFIG_HAVE_BOOTMEM_INFO_NODE
anymore, let's just drop it.
We can stop including bootmem_info.h.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
@@ -537,7 +537,7 @@ endchoiceconfigMEMORY_HOTREMOVEbool"Allow for memory hot remove"-selectHAVE_BOOTMEM_INFO_NODEif(X86_64||PPC64)+selectHAVE_BOOTMEM_INFO_NODEifX86_64depends onMEMORY_HOTPLUGselectMIGRATION
On Mon, May 11, 2026 at 04:05:32PM +0200, David Hildenbrand (Arm) wrote:
quoted
The call to kmemleak_free_part_phys() was added in 2022 in
commit dd0ff4d12dd2 ("bootmem: remove the vmemmap pages from kmemleak in
put_page_bootmem").
In 2025, commit b2aad24b5333 ("mm/memmap: prevent double scanning of memmap
by kmemleak") started to use MEMBLOCK_ALLOC_NOLEAKTRACE when allocating
the memmap to skip the kmemleak_alloc_phys() in the buddy.
So remove the call to kmemleak_free_part_phys(). If this would still
be required for other purposes, either free_reserved_page() should take
care of it, or selected users.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
A bit odd that kmemleak_free_part_phys() did not complain if we never
did kmemleak_alloc_phys() for these pages?
delete_object_part() calls __find_and_remove_object() and essentially just skips
if it didn't find anything.
Maybe the kmemleak_warn() would trigger, but it's guarded by "#ifdef DEBUG" ...
--
Cheers,
David
From: Oscar Salvador <osalvador@suse.de> Date: 2026-05-12 08:45:15
On Mon, May 11, 2026 at 04:05:28PM +0200, David Hildenbrand (Arm) wrote:
We want to remove CONFIG_HAVE_BOOTMEM_INFO_NODE. As a first step,
let's limit the remaining harm to x86 and core code, removing
sparc, ppc and s390 leftovers, starting the stepwise removal by removing
and simplifying some code.
Once a related x86 vmemmap fix [1] is in, we can merge part 2 that will
remove CONFIG_HAVE_BOOTMEM_INFO_NODE entirely.
Tested on x86-64 with hugetlb vmemmap optimization in combination with
KMEMLEAK, making sure that the problem reported in dd0ff4d12dd2 ("bootmem:
remove the vmemmap pages from kmemleak in put_page_bootmem") does not
reappear -- hoping I managed to trigger the original problem.
Heavily cross-compiled, but let's let build bots run on it for a bit.
[1] https://lore.kernel.org/r/20260429-vmemmap-v2-1-8dfcacffd877@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Awesome cleanup David, thanks for doing this ;-)
--
Oscar Salvador
SUSE Labs
On Mon, May 11, 2026 at 04:05:28PM +0200, David Hildenbrand (Arm) wrote:
quoted
We want to remove CONFIG_HAVE_BOOTMEM_INFO_NODE. As a first step,
let's limit the remaining harm to x86 and core code, removing
sparc, ppc and s390 leftovers, starting the stepwise removal by removing
and simplifying some code.
Once a related x86 vmemmap fix [1] is in, we can merge part 2 that will
remove CONFIG_HAVE_BOOTMEM_INFO_NODE entirely.
Tested on x86-64 with hugetlb vmemmap optimization in combination with
KMEMLEAK, making sure that the problem reported in dd0ff4d12dd2 ("bootmem:
remove the vmemmap pages from kmemleak in put_page_bootmem") does not
reappear -- hoping I managed to trigger the original problem.
Heavily cross-compiled, but let's let build bots run on it for a bit.
[1] https://lore.kernel.org/r/20260429-vmemmap-v2-1-8dfcacffd877@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Awesome cleanup David, thanks for doing this ;-)
Thanks for the review, I'm sure you'll enjoy part 2 :)
--
Cheers,
David
register_page_bootmem_info_node() essentially only calls
register_page_bootmem_memmap(). However, on powerpc that function is a
nop. So there is not benefit in using CONFIG_HAVE_BOOTMEM_INFO_NODE
anymore, let's just drop it.
We can stop including bootmem_info.h.
From: Mike Rapoport <rppt@kernel.org> Date: 2026-05-13 08:25:19
On Mon, May 11, 2026 at 04:05:29PM +0200, David Hildenbrand (Arm) wrote:
sparc does not select CONFIG_HAVE_BOOTMEM_INFO_NODE, therefore,
register_page_bootmem_info_node() is a nop.
Let's just get rid of register_page_bootmem_info().
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
From: Mike Rapoport <rppt@kernel.org> Date: 2026-05-13 08:27:51
On Mon, May 11, 2026 at 04:05:30PM +0200, David Hildenbrand (Arm) wrote:
In the past, we used to store the type in page->lru.next, introduced by
commit 5f24ce5fd34c ("thp: remove PG_buddy"). The location changed over
the years; ever since commit 0386aaa6e9c8 ("bootmem: stop using
page->index"), we store it alongside the info in page->private.
Consequently, there is no need to reset page->lru anymore.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
From: Mike Rapoport <rppt@kernel.org> Date: 2026-05-13 08:30:02
On Mon, May 11, 2026 at 04:05:31PM +0200, David Hildenbrand (Arm) wrote:
Nobody checks PG_private for these pages, and we can happily use
set_page_private() without setting PG_private. So let's just stop
setting/clearing PG_private.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
From: Mike Rapoport <rppt@kernel.org> Date: 2026-05-13 08:32:12
On Mon, May 11, 2026 at 04:05:32PM +0200, David Hildenbrand (Arm) wrote:
The call to kmemleak_free_part_phys() was added in 2022 in
commit dd0ff4d12dd2 ("bootmem: remove the vmemmap pages from kmemleak in
put_page_bootmem").
In 2025, commit b2aad24b5333 ("mm/memmap: prevent double scanning of memmap
by kmemleak") started to use MEMBLOCK_ALLOC_NOLEAKTRACE when allocating
the memmap to skip the kmemleak_alloc_phys() in the buddy.
So remove the call to kmemleak_free_part_phys(). If this would still
be required for other purposes, either free_reserved_page() should take
care of it, or selected users.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
From: Mike Rapoport <rppt@kernel.org> Date: 2026-05-13 08:35:40
On Mon, May 11, 2026 at 04:05:33PM +0200, David Hildenbrand (Arm) wrote:
We removed the last user of NODE_INFO in commit 119c31caa59e ("mm/sparse:
remove !CONFIG_SPARSEMEM_VMEMMAP leftovers for CONFIG_MEMORY_HOTPLUG").
But it really was never used it besides for safety-checks ever since it was
introduced in commit 04753278769f ("memory hotplug: register section/node
id to free"), where we had the comment:
5) The node information like pgdat has similar issues. But, this
will be able to be solved too by this.
(Not implemented yet, but, remembering node id in the pages.)
Of course, that never happened, and we are not planning on freeing the
node data (pgdat/pglist_data), during memory hotunplug.
So let's just stop marking the pgdat as NODE_INFO.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
From: Mike Rapoport <rppt@kernel.org> Date: 2026-05-13 08:39:10
On Mon, May 11, 2026 at 04:05:34PM +0200, David Hildenbrand (Arm) wrote:
We never free the ms->usage data for boot memory sections (see
section_deactivate()). And to identify whether ms->usage was allocated
from memblock, we simply identify it by looking at PG_reserved.
Consequently, there is no need to mark ms->usage as MIX_SECTION_INFO.
Let's just stop doing that.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
From: Mike Rapoport <rppt@kernel.org> Date: 2026-05-13 08:40:14
On Mon, May 11, 2026 at 04:05:35PM +0200, David Hildenbrand (Arm) wrote:
We never select CONFIG_HAVE_BOOTMEM_INFO_NODE on s390. Therefore,
free_bootmem_page() nowadays always translates to free_reserved_page().
Let's use free_reserved_page() to replace the free_bootmem_page() loop.
We can stop including bootmem_info.h.
Likely, vmemmap freeing code could be factored out into the core in the
future.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
From: Mike Rapoport <rppt@kernel.org> Date: 2026-05-13 08:41:49
On Mon, May 11, 2026 at 04:05:36PM +0200, David Hildenbrand (Arm) wrote:
register_page_bootmem_info_node() essentially only calls
register_page_bootmem_memmap(). However, on powerpc that function is a
nop. So there is not benefit in using CONFIG_HAVE_BOOTMEM_INFO_NODE
anymore, let's just drop it.
We can stop including bootmem_info.h.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
@@ -537,7 +537,7 @@ endchoiceconfigMEMORY_HOTREMOVEbool"Allow for memory hot remove"-selectHAVE_BOOTMEM_INFO_NODEif(X86_64||PPC64)+selectHAVE_BOOTMEM_INFO_NODEifX86_64depends onMEMORY_HOTPLUGselectMIGRATION
From: Lance Yang <lance.yang@linux.dev> Date: 2026-05-18 06:55:29
On Mon, May 11, 2026 at 04:05:29PM +0200, David Hildenbrand (Arm) wrote:
sparc does not select CONFIG_HAVE_BOOTMEM_INFO_NODE, therefore,
register_page_bootmem_info_node() is a nop.
Let's just get rid of register_page_bootmem_info().
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
Nice cleanup!
With CONFIG_NUMA=n, the removed helper did nothing.
With CONFIG_NUMA=y, it only looped over nodes and called the empty inline
stub.
So, feel free to add:
Reviewed-by: Lance Yang <lance.yang@linux.dev>
From: Lance Yang <lance.yang@linux.dev> Date: 2026-05-18 07:49:54
On Mon, May 11, 2026 at 04:05:30PM +0200, David Hildenbrand (Arm) wrote:
quoted hunk
In the past, we used to store the type in page->lru.next, introduced by
commit 5f24ce5fd34c ("thp: remove PG_buddy"). The location changed over
the years; ever since commit 0386aaa6e9c8 ("bootmem: stop using
page->index"), we store it alongside the info in page->private.
Consequently, there is no need to reset page->lru anymore.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
mm/bootmem_info.c | 1 -
1 file changed, 1 deletion(-)
if (page_ref_dec_return(page) == 1) {
ClearPagePrivate(page);
set_page_private(page, 0);
- INIT_LIST_HEAD(&page->lru);
Yep, that old INIT_LIST_HEAD() call was dead cleanup. page->lru and
page->buddy_list are in the same union:
union {
struct list_head lru;
/* Or, free page */
struct list_head buddy_list;
};
and free_reserved_page() passes the page to the buddy allocator. The
later buddy list insertion will overwrite the values written by
INIT_LIST_HEAD(&page->lru) anyway.
From: Lance Yang <lance.yang@linux.dev> Date: 2026-05-19 02:56:51
On Mon, May 11, 2026 at 04:05:31PM +0200, David Hildenbrand (Arm) wrote:
quoted hunk
Nobody checks PG_private for these pages, and we can happily use
set_page_private() without setting PG_private. So let's just stop
setting/clearing PG_private.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
mm/bootmem_info.c | 2 --
1 file changed, 2 deletions(-)
A bit odd that kmemleak_free_part_phys() did not complain if we never
did kmemleak_alloc_phys() for these pages?
delete_object_part() calls __find_and_remove_object() and essentially just skips
if it didn't find anything.
Maybe the kmemleak_warn() would trigger, but it's guarded by "#ifdef DEBUG" ...
Right! With kmemleak DEBUG enabled, kmemleak_free_part_phys() does warns
whenever delete_object_part() cannot find the corresponding physical
object ...
Before this patch, booting with:
"kmemleak=on hugetlb_free_vmemmap=on default_hugepagesz=2M hugepagesz=2M hugepages=512"
I got a lot of warnings, something like:
[ 44.481883] kmemleak: Partially freeing unknown object at 0x2acc59000 (size 4096)
[ 44.482754] CPU: 2 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.1.0-rc3 #206 PREEMPT(full)
[ 44.482758] Hardware name: Red Hat KVM, BIOS 1.11.0-2.el7 04/01/2014
[ 44.482760] Call Trace:
[ 44.482762] <TASK>
[ 44.482764] dump_stack_lvl+0x60/0x90
[ 44.482769] dump_stack+0x14/0x1a
[ 44.482774] delete_object_part.cold+0x28/0x2d
[ 44.482779] kmemleak_free_part_phys+0x67/0x80
[ 44.482783] put_page_bootmem+0xc0/0x100
[ 44.482787] free_vmemmap_page_list+0x13e/0x230
[ 44.482791] __hugetlb_vmemmap_optimize_folios+0x351/0x430
[...]
So, yeah, looks like these calls are trying to free physical kmemleak
objects that are no longer tracked after memmap_alloc() started using
MEMBLOCK_ALLOC_NOLEAKTRACE :)
With this patch applied, those stale calls are gone, and so are the
warnings :P
Tested-by: Lance Yang <lance.yang@linux.dev>
From: Lance Yang <lance.yang@linux.dev> Date: 2026-05-20 15:31:25
On Mon, May 11, 2026 at 04:05:33PM +0200, David Hildenbrand (Arm) wrote:
quoted hunk
We removed the last user of NODE_INFO in commit 119c31caa59e ("mm/sparse:
remove !CONFIG_SPARSEMEM_VMEMMAP leftovers for CONFIG_MEMORY_HOTPLUG").
But it really was never used it besides for safety-checks ever since it was
introduced in commit 04753278769f ("memory hotplug: register section/node
id to free"), where we had the comment:
5) The node information like pgdat has similar issues. But, this
will be able to be solved too by this.
(Not implemented yet, but, remembering node id in the pages.)
Of course, that never happened, and we are not planning on freeing the
node data (pgdat/pglist_data), during memory hotunplug.
So let's just stop marking the pgdat as NODE_INFO.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
mm/bootmem_info.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
@@ -62,15 +62,8 @@ static void __init register_page_bootmem_info_section(unsigned long start_pfn)
void __init register_page_bootmem_info_node(struct pglist_data *pgdat)
{
- unsigned long i, pfn, end_pfn, nr_pages;
+ unsigned long pfn, end_pfn;
int node = pgdat->node_id;
- struct page *page;
-
- nr_pages = PAGE_ALIGN(sizeof(struct pglist_data)) >> PAGE_SHIFT;
- page = virt_to_page(pgdat);
-
- for (i = 0; i < nr_pages; i++, page++)
- get_page_bootmem(node, page, NODE_INFO);
Cool. IIUC, pgdat isn't freed during memory hotremove. Offline nodes
stick around and can get reinitialized on hotadd, so NODE_INFO doesn't
buy us anything here :D
LGTM, feel free to add:
Reviewed-by: Lance Yang <lance.yang@linux.dev>
From: Lance Yang <lance.yang@linux.dev> Date: 2026-05-21 05:04:15
On Mon, May 11, 2026 at 04:05:34PM +0200, David Hildenbrand (Arm) wrote:
We never free the ms->usage data for boot memory sections (see
section_deactivate()). And to identify whether ms->usage was allocated
from memblock, we simply identify it by looking at PG_reserved.
Yep, PageReserved() is already enough to tell that case apart :)
Consequently, there is no need to mark ms->usage as MIX_SECTION_INFO.
Let's just stop doing that.
Right, MIX_SECTION_INFO doesn't add much here. For ms->usage, removal
code doesn't use MIX_SECTION_INFO at all :)
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
LGTM, feel free to add:
Reviewed-by: Lance Yang <lance.yang@linux.dev>
From: Lance Yang <lance.yang@linux.dev> Date: 2026-05-21 08:40:26
On Mon, May 11, 2026 at 04:05:35PM +0200, David Hildenbrand (Arm) wrote:
We never select CONFIG_HAVE_BOOTMEM_INFO_NODE on s390. Therefore,
free_bootmem_page() nowadays always translates to free_reserved_page().
Yeah. After patch #04 there is no kmemleak handling left in
free_bootmem_page(), and on s390 it is just a wrapper around
free_reserved_page() :)
Let's use free_reserved_page() to replace the free_bootmem_page() loop.
We can stop including bootmem_info.h.
Likely, vmemmap freeing code could be factored out into the core in the
future.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
Nice cleanup, feel free to add:
Reviewed-by: Lance Yang <lance.yang@linux.dev>
From: Lance Yang <lance.yang@linux.dev> Date: 2026-05-21 08:47:29
On Mon, May 11, 2026 at 04:05:36PM +0200, David Hildenbrand (Arm) wrote:
register_page_bootmem_info_node() essentially only calls
register_page_bootmem_memmap(). However, on powerpc that function is a
nop. So there is not benefit in using CONFIG_HAVE_BOOTMEM_INFO_NODE
anymore, let's just drop it.
We can stop including bootmem_info.h.
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
Nice cleanup! Feel free to add:
Reviewed-by: Lance Yang <lance.yang@linux.dev>