Skip to contentSkip to conversation

mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory()

PATCH Applied Mike Rapoport 4 participants 4 messages Jun 5, 2024 – Jun 10, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/memory_hotplug: Drop memblock_phys_free() call in try_remove_memory()

From: Jonathan Cameron <[email protected]>

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().

[rppt: rewrite the commit message]
---
 mm/memory_hotplug.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/memory_hotplug.c +1 -3
index 431b1f6753c0..e0d49f128e0d 100644
@@ -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);
 
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Mike Rapoport

From: Jonathan Cameron <[email protected]>

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.

Quoted 7 lines

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

Quoted 24 lines
[rppt: rewrite the commit message]
---
  mm/memory_hotplug.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
mm/memory_hotplug.c +1 -3
index 431b1f6753c0..e0d49f128e0d 100644
@@ -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);
 
Signature · 9 lines
Cheers,

David / dhildenb


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 1/1
#2 lore raw
In reply to Mike Rapoport
Quoted 16 lines · Mike Rapoport

From: Jonathan Cameron <[email protected]>

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.

Quoted 5 lines

Drop memblock_phys_free() call in try_remove_memory().

[rppt: rewrite the commit message]
Signature · 2 lines
Oscar Salvador
SUSE Labs
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Mike Rapoport
Quoted 16 lines · Mike Rapoport

From: Jonathan Cameron <[email protected]>

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.

Quoted 5 lines

Drop memblock_phys_free() call in try_remove_memory().

[rppt: rewrite the commit message]
Quoted 23 lines
---
 mm/memory_hotplug.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/memory_hotplug.c +1 -3
index 431b1f6753c0..e0d49f128e0d 100644
@@ -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);
 
Signature · 1 line
2.43.0
Signature · 2 lines
Oscar Salvador
SUSE Labs