]> www.infradead.org Git - users/willy/linux.git/commitdiff
mm/sparse: add common helper to mark all memblocks present
authorLogan Gunthorpe <logang@deltatee.com>
Wed, 5 Dec 2018 00:14:20 +0000 (11:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 10 Dec 2018 08:29:15 +0000 (19:29 +1100)
Presently the arches arm64, arm and sh have a function which loops through
each memblock and calls memory present. riscv will require a similar
function.

Introduce a common memblocks_present() function that can be used by
all the arches. Subsequent patches will cleanup the arches that
make use of this.

Link: http://lkml.kernel.org/r/20181107205433.3875-3-logang@deltatee.com
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
include/linux/mmzone.h
mm/sparse.c

index 6793532bdc1a3f9e45cb90b34fb56a0c742fc0ca..2e700c43af1ac70ef812a26d30206af1d220c7b8 100644 (file)
@@ -781,6 +781,12 @@ void memory_present(int nid, unsigned long start, unsigned long end);
 static inline void memory_present(int nid, unsigned long start, unsigned long end) {}
 #endif
 
+#if defined(CONFIG_SPARSEMEM)
+void memblocks_present(void);
+#else
+static inline void memblocks_present(void) {}
+#endif
+
 #ifdef CONFIG_HAVE_MEMORYLESS_NODES
 int local_memory_node(int node_id);
 #else
index 541286200d747c9a6d64d2f0afb65b292ffcd247..4ba44af27d1cebaced9e01527a9687b0b827cf95 100644 (file)
@@ -239,6 +239,22 @@ void __init memory_present(int nid, unsigned long start, unsigned long end)
        }
 }
 
+/*
+ * Mark all memblocks as present using memory_present(). This is a
+ * convienence function that is useful for a number of arches
+ * to mark all of the systems memory as present during initialization.
+ */
+void __init memblocks_present(void)
+{
+       struct memblock_region *reg;
+
+       for_each_memblock(memory, reg) {
+               memory_present(memblock_get_region_node(reg),
+                              memblock_region_memory_base_pfn(reg),
+                              memblock_region_memory_end_pfn(reg));
+       }
+}
+
 /*
  * Subtle, we encode the real pfn into the mem_map such that
  * the identity pfn - section_mem_map will return the actual