Merge tag 'memblock-v5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt...
[sfrench/cifs-2.6.git] / mm / memblock.c
index 67e0e24f8cc97b11517db7d49671eca1348196fc..0041ff62c584e7e128a138a1a9a996449ebc1cdf 100644 (file)
@@ -92,7 +92,7 @@
  * system initialization completes.
  */
 
-#ifndef CONFIG_NEED_MULTIPLE_NODES
+#ifndef CONFIG_NUMA
 struct pglist_data __refdata contig_page_data;
 EXPORT_SYMBOL(contig_page_data);
 #endif
@@ -609,7 +609,7 @@ repeat:
                 * area, insert that portion.
                 */
                if (rbase > base) {
-#ifdef CONFIG_NEED_MULTIPLE_NODES
+#ifdef CONFIG_NUMA
                        WARN_ON(nid != memblock_get_region_node(rgn));
 #endif
                        WARN_ON(flags != rgn->flags);
@@ -908,6 +908,11 @@ int __init_memblock memblock_mark_mirror(phys_addr_t base, phys_addr_t size)
  * @base: the base phys addr of the region
  * @size: the size of the region
  *
+ * The memory regions marked with %MEMBLOCK_NOMAP will not be added to the
+ * direct mapping of the physical memory. These regions will still be
+ * covered by the memory map. The struct page representing NOMAP memory
+ * frames in the memory map will be PageReserved()
+ *
  * Return: 0 on success, -errno on failure.
  */
 int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size)
@@ -1207,7 +1212,7 @@ void __init_memblock __next_mem_pfn_range(int *idx, int nid,
 int __init_memblock memblock_set_node(phys_addr_t base, phys_addr_t size,
                                      struct memblock_type *type, int nid)
 {
-#ifdef CONFIG_NEED_MULTIPLE_NODES
+#ifdef CONFIG_NUMA
        int start_rgn, end_rgn;
        int i, ret;
 
@@ -1850,7 +1855,7 @@ static void __init_memblock memblock_dump(struct memblock_type *type)
                size = rgn->size;
                end = base + size - 1;
                flags = rgn->flags;
-#ifdef CONFIG_NEED_MULTIPLE_NODES
+#ifdef CONFIG_NUMA
                if (memblock_get_region_node(rgn) != MAX_NUMNODES)
                        snprintf(nid_buf, sizeof(nid_buf), " on node %d",
                                 memblock_get_region_node(rgn));
@@ -2004,6 +2009,26 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
        return end_pfn - start_pfn;
 }
 
+static void __init memmap_init_reserved_pages(void)
+{
+       struct memblock_region *region;
+       phys_addr_t start, end;
+       u64 i;
+
+       /* initialize struct pages for the reserved regions */
+       for_each_reserved_mem_range(i, &start, &end)
+               reserve_bootmem_region(start, end);
+
+       /* and also treat struct pages for the NOMAP regions as PageReserved */
+       for_each_mem_region(region) {
+               if (memblock_is_nomap(region)) {
+                       start = region->base;
+                       end = start + region->size;
+                       reserve_bootmem_region(start, end);
+               }
+       }
+}
+
 static unsigned long __init free_low_memory_core_early(void)
 {
        unsigned long count = 0;
@@ -2012,8 +2037,7 @@ static unsigned long __init free_low_memory_core_early(void)
 
        memblock_clear_hotplug(0, -1);
 
-       for_each_reserved_mem_range(i, &start, &end)
-               reserve_bootmem_region(start, end);
+       memmap_init_reserved_pages();
 
        /*
         * We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id