Skip to contentSkip to conversation

Cleanup ARM arches to use common memblocks_present

PATCH Superseded Logan Gunthorpe 3 participants 6 messages Jan 9, 2019 – Jan 21, 2019

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Cleanup ARM arches to use common memblocks_present

Hey,

We've recently added a new memblocks_present() helper macro to clean up some common code with ARM and code we are adding in RISC-V. The commit that added the helper is:

9def36e0fa9a ("mm/sparse: add common helper to mark all memblocks present")

This series includes two patches to switch ARM and ARM64 to use the new function.

Thanks,

Logan

--

Logan Gunthorpe (2):
ARM: mm: make use of new memblocks_present() helper
arm64: mm: make use of new memblocks_present() helper

 arch/arm/mm/init.c   | 17 +----------------
 arch/arm64/mm/init.c | 20 +-------------------
 2 files changed, 2 insertions(+), 35 deletions(-)

--
2.19.0

#2 lore raw

PATCH 2/2 arm64: mm: make use of new memblocks_present() helper

Cleanup the arm64_memory_present() function seeing it's very similar to other arches.

memblocks_present() is a direct replacement of arm64_memory_present()

---
 arch/arm64/mm/init.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
arch/arm64/mm/init.c +1 -19
index 7205a9085b4d..2302b4093a63 100644
@@ -285,24 +285,6 @@ int pfn_valid(unsigned long pfn)
 }
 EXPORT_SYMBOL(pfn_valid);
 
-#ifndef CONFIG_SPARSEMEM
-static void __init arm64_memory_present(void)
-{
-}
-#else
-static void __init arm64_memory_present(void)
-{
-	struct memblock_region *reg;
-
-	for_each_memblock(memory, reg) {
-		int nid = memblock_get_region_node(reg);
-
-		memory_present(nid, memblock_region_memory_base_pfn(reg),
-				memblock_region_memory_end_pfn(reg));
-	}
-}
-#endif
-
 static phys_addr_t memory_limit = PHYS_ADDR_MAX;
 
 /*
@@ -489,7 +471,7 @@ void __init bootmem_init(void)
 	 * Sparsemem tries to allocate bootmem in memory_present(), so must be
 	 * done after the fixed reservations.
 	 */
-	arm64_memory_present();
+	memblocks_present();
 
 	sparse_init();
 	zone_sizes_init(min, max);
Signature · 1 line
2.19.0
#1 lore raw

PATCH 1/2 ARM: mm: make use of new memblocks_present() helper

In reply to Logan Gunthorpe

Cleanup the arm_memory_present() function seeing it's very similar to other arches.

The new memblocks_present() helper checks for node ids which the arm version did not. However, this is equivalent seeing HAVE_MEMBLOCK_NODE_MAP should be false in this arch and therefore memblock_get_region_node() should return 0.

Cc Russell King <[email protected]>
Cc Kees Cook <[email protected]>
Cc Philip Derrin <[email protected]>
Cc "Steven Rostedt (VMware)" <[email protected]>
Cc Nicolas Pitre <[email protected]>
---
 arch/arm/mm/init.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
arch/arm/mm/init.c +1 -16
index 478ea8b7db87..6c50dd407ba8 100644
@@ -182,21 +182,6 @@ int pfn_valid(unsigned long pfn)
 EXPORT_SYMBOL(pfn_valid);
 #endif
 
-#ifndef CONFIG_SPARSEMEM
-static void __init arm_memory_present(void)
-{
-}
-#else
-static void __init arm_memory_present(void)
-{
-	struct memblock_region *reg;
-
-	for_each_memblock(memory, reg)
-		memory_present(0, memblock_region_memory_base_pfn(reg),
-			       memblock_region_memory_end_pfn(reg));
-}
-#endif
-
 static bool arm_memblock_steal_permitted = true;
 
 phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)
@@ -292,7 +277,7 @@ void __init bootmem_init(void)
 	 * Sparsemem tries to allocate bootmem in memory_present(),
 	 * so must be done after the fixed reservations
 	 */
-	arm_memory_present();
+	memblocks_present();
 
 	/*
 	 * sparse_init() needs the bootmem allocator up and running.
Signature · 1 line
2.19.0
Acked-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] arm64: mm: make use of new memblocks_present() helper

In reply to Logan Gunthorpe
Quoted 11 lines · Logan Gunthorpe

Cleanup the arm64_memory_present() function seeing it's very similar to other arches.

memblocks_present() is a direct replacement of arm64_memory_present()

---
 arch/arm64/mm/init.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

Did you want us to take this via the arm64 tree?

Will

#4 lore raw

Re: [PATCH 2/2] arm64: mm: make use of new memblocks_present() helper

Quoted 13 lines · Will Deacon
Quoted 11 lines · Logan Gunthorpe

Cleanup the arm64_memory_present() function seeing it's very similar to other arches.

memblocks_present() is a direct replacement of arm64_memory_present()

---
 arch/arm64/mm/init.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
Quoted 3 lines

Did you want us to take this via the arm64 tree?

Yes please.

Thanks,

Logan

maintainer
#5 lore raw

Re: [PATCH 2/2] arm64: mm: make use of new memblocks_present() helper

Quoted 14 lines · Logan Gunthorpe
Quoted 13 lines · Will Deacon
Quoted 11 lines · Logan Gunthorpe

Cleanup the arm64_memory_present() function seeing it's very similar to other arches.

memblocks_present() is a direct replacement of arm64_memory_present()

---
 arch/arm64/mm/init.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
Quoted 5 lines
Quoted 3 lines

Did you want us to take this via the arm64 tree?

Yes please.

Patch 2/2 queued for 5.1. Thanks.

Signature · 1 line
Catalin