* [PATCH] mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory()
@ 2024-06-05 8:20 Mike Rapoport
2024-06-05 13:29 ` David Hildenbrand
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mike Rapoport @ 2024-06-05 8:20 UTC (permalink / raw)
To: linux-mm
Cc: Andrew Morton, David Hildenbrand, Jonathan Cameron, Mike Rapoport,
Oscar Salvador, linux-arm-kernel, linux-kernel
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The call for memblock_phys_free() in try_remove_memory() does not balance
any call to memblock_alloc() (or memblock_reserve() for that matter).
There are no memblock_reserve() calls in mm/memory_hotplug.c, no memblock
allocations possible after mm_core_init(), and even if memblock_add_node()
called from add_memory_resource() would need to allocate memory, that
memory would ba allocated from slab.
The patch f9126ab9241f ("memory-hotplug: fix wrong edge when hot add a new
node") that introduced that call to memblock_free() does not provide
adequate description why that was required and tinkering with memblock in
the context of memory hotplug on x86 seems bogus because x86 never kept
memblock after boot anyway.
Drop memblock_phys_free() call in try_remove_memory().
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
[rppt: rewrite the commit message]
Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
---
mm/memory_hotplug.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 431b1f6753c0..e0d49f128e0d 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -2283,10 +2283,8 @@ static int __ref try_remove_memory(u64 start, u64 size)
remove_memory_blocks_and_altmaps(start, size);
}
- if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) {
- memblock_phys_free(start, size);
+ if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
memblock_remove(start, size);
- }
release_mem_region_adjustable(start, size);
--
2.43.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory()
2024-06-05 8:20 [PATCH] mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory() Mike Rapoport
@ 2024-06-05 13:29 ` David Hildenbrand
2024-06-07 7:37 ` Oscar Salvador
2024-06-10 4:56 ` Oscar Salvador
2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2024-06-05 13:29 UTC (permalink / raw)
To: Mike Rapoport, linux-mm
Cc: Andrew Morton, Jonathan Cameron, Oscar Salvador, linux-arm-kernel,
linux-kernel
On 05.06.24 10:20, Mike Rapoport wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> The call for memblock_phys_free() in try_remove_memory() does not balance
> any call to memblock_alloc() (or memblock_reserve() for that matter).
>
> There are no memblock_reserve() calls in mm/memory_hotplug.c, no memblock
> allocations possible after mm_core_init(), and even if memblock_add_node()
> called from add_memory_resource() would need to allocate memory, that
> memory would ba allocated from slab.
>
> The patch f9126ab9241f ("memory-hotplug: fix wrong edge when hot add a new
> node") that introduced that call to memblock_free() does not provide
> adequate description why that was required and tinkering with memblock in
> the context of memory hotplug on x86 seems bogus because x86 never kept
> memblock after boot anyway.
>
> Drop memblock_phys_free() call in try_remove_memory().
See my example regarding leftovers from previous bootmem allocations.
But I don't think we'd encounter that situation often in practice.
Maybe more likely to happen on ppc with very small memory blocks? No idea.
Let's see if anything would really break
Acked-by: David Hildenbrand <david@redhat.com>
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> [rppt: rewrite the commit message]
> Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
> ---
> mm/memory_hotplug.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 431b1f6753c0..e0d49f128e0d 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -2283,10 +2283,8 @@ static int __ref try_remove_memory(u64 start, u64 size)
> remove_memory_blocks_and_altmaps(start, size);
> }
>
> - if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) {
> - memblock_phys_free(start, size);
> + if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
> memblock_remove(start, size);
> - }
>
> release_mem_region_adjustable(start, size);
>
--
Cheers,
David / dhildenb
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory()
2024-06-05 8:20 [PATCH] mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory() Mike Rapoport
2024-06-05 13:29 ` David Hildenbrand
@ 2024-06-07 7:37 ` Oscar Salvador
2024-06-10 4:56 ` Oscar Salvador
2 siblings, 0 replies; 4+ messages in thread
From: Oscar Salvador @ 2024-06-07 7:37 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-mm, Andrew Morton, David Hildenbrand, Jonathan Cameron,
linux-arm-kernel, linux-kernel
On Wed, Jun 05, 2024 at 11:20:49AM +0300, Mike Rapoport wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> The call for memblock_phys_free() in try_remove_memory() does not balance
> any call to memblock_alloc() (or memblock_reserve() for that matter).
>
> There are no memblock_reserve() calls in mm/memory_hotplug.c, no memblock
> allocations possible after mm_core_init(), and even if memblock_add_node()
> called from add_memory_resource() would need to allocate memory, that
> memory would ba allocated from slab.
>
> The patch f9126ab9241f ("memory-hotplug: fix wrong edge when hot add a new
> node") that introduced that call to memblock_free() does not provide
> adequate description why that was required and tinkering with memblock in
> the context of memory hotplug on x86 seems bogus because x86 never kept
> memblock after boot anyway.
>
> Drop memblock_phys_free() call in try_remove_memory().
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> [rppt: rewrite the commit message]
> Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory()
2024-06-05 8:20 [PATCH] mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory() Mike Rapoport
2024-06-05 13:29 ` David Hildenbrand
2024-06-07 7:37 ` Oscar Salvador
@ 2024-06-10 4:56 ` Oscar Salvador
2 siblings, 0 replies; 4+ messages in thread
From: Oscar Salvador @ 2024-06-10 4:56 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-mm, Andrew Morton, David Hildenbrand, Jonathan Cameron,
linux-arm-kernel, linux-kernel
On Wed, Jun 05, 2024 at 11:20:49AM +0300, Mike Rapoport wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> The call for memblock_phys_free() in try_remove_memory() does not balance
> any call to memblock_alloc() (or memblock_reserve() for that matter).
>
> There are no memblock_reserve() calls in mm/memory_hotplug.c, no memblock
> allocations possible after mm_core_init(), and even if memblock_add_node()
> called from add_memory_resource() would need to allocate memory, that
> memory would ba allocated from slab.
>
> The patch f9126ab9241f ("memory-hotplug: fix wrong edge when hot add a new
> node") that introduced that call to memblock_free() does not provide
> adequate description why that was required and tinkering with memblock in
> the context of memory hotplug on x86 seems bogus because x86 never kept
> memblock after boot anyway.
>
> Drop memblock_phys_free() call in try_remove_memory().
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> [rppt: rewrite the commit message]
> Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
> ---
> mm/memory_hotplug.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 431b1f6753c0..e0d49f128e0d 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -2283,10 +2283,8 @@ static int __ref try_remove_memory(u64 start, u64 size)
> remove_memory_blocks_and_altmaps(start, size);
> }
>
> - if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) {
> - memblock_phys_free(start, size);
> + if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
> memblock_remove(start, size);
> - }
>
> release_mem_region_adjustable(start, size);
>
> --
> 2.43.0
>
--
Oscar Salvador
SUSE Labs
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-10 4:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 8:20 [PATCH] mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory() Mike Rapoport
2024-06-05 13:29 ` David Hildenbrand
2024-06-07 7:37 ` Oscar Salvador
2024-06-10 4:56 ` Oscar Salvador
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).