linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] aarch64/mm: speedup memory initialisation
@ 2019-09-10  8:59 Hubert Ralf
  2019-09-10 13:07 ` Robin Murphy
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Hubert Ralf @ 2019-09-10  8:59 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Hubert Ralf

On ARM64 memmap_init_zone is used during bootmem_init, which iterates over
all pages in the memory starting at the lowest address until the highest
address is reached. On arm64 this ends up in searching a memmory region
containing for each single page between lowest and highest available
physicall address.

Having a sparse memory system there may be some big holes in the
memory map. For each page in this holes a lookup is done, which is
implemented as a binary search on the available memory blocks.

Adding a memmap_init for aarch64 to do the init only for the available
memory areas reduces the time needed for initialising memory on startup.
On a Renesas R-CAR M3 based system with a total hole of 20GB bootmem_init
execution time is reduced from 378ms to 84ms.

Signed-off-by: Ralf Hubert <ralf.hubert@preh.de>
---
 arch/arm64/include/asm/pgtable.h |  7 +++++++
 arch/arm64/mm/init.c             | 24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index e09760ece844..8c6eefc08b0b 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -298,6 +298,13 @@ static inline int pte_same(pte_t pte_a, pte_t pte_b)
 	return (lhs == rhs);
 }
 
+#ifdef CONFIG_SPARSEMEM
+/* arch mem_map init routine is needed due to holes in a memmap */
+#   define __HAVE_ARCH_MEMMAP_INIT
+	void memmap_init(unsigned long size, int nid, unsigned long zone,
+			 unsigned long start_pfn);
+#endif /* CONFIG_SPARSEMEM */
+
 /*
  * Huge pte definitions.
  */
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index f3c795278def..206b28310872 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -250,6 +250,30 @@ int pfn_valid(unsigned long pfn)
 }
 EXPORT_SYMBOL(pfn_valid);
 
+#ifdef CONFIG_SPARSEMEM
+void __meminit
+memmap_init(unsigned long size, int nid, unsigned long zone,
+	    unsigned long start_pfn)
+{
+	struct memblock_region *reg;
+
+	for_each_memblock(memory, reg) {
+		unsigned long start = memblock_region_memory_base_pfn(reg);
+		unsigned long end = memblock_region_memory_end_pfn(reg);
+
+		if (start < start_pfn)
+			start = start_pfn;
+		if (end > start_pfn + size)
+			end = start_pfn + size;
+
+		if (start < end) {
+			memmap_init_zone(end - start, nid, zone, start,
+					 MEMMAP_EARLY, NULL);
+		}
+	}
+}
+#endif /* CONFIG_SPARSEMEM */
+
 static phys_addr_t memory_limit = PHYS_ADDR_MAX;
 
 /*
-- 
2.23.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] 7+ messages in thread

end of thread, other threads:[~2019-09-12  8:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-10  8:59 [PATCH] aarch64/mm: speedup memory initialisation Hubert Ralf
2019-09-10 13:07 ` Robin Murphy
2019-09-11 16:22 ` James Morse
2019-09-12  5:36   ` Hubert Ralf
2019-09-12  8:12 ` Anshuman Khandual
2019-09-12  8:40   ` Hubert Ralf
2019-09-12  8:59     ` Anshuman Khandual

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