Merge branch 'akpm' (patches from Andrew Morton)
[sfrench/cifs-2.6.git] / arch / x86 / mm / numa.c
index a32b706c401add2e47943cf1650ca63f26b8c1ae..1a883705a12a8a12410914be93b2ee65807cc423 100644 (file)
@@ -185,26 +185,14 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)
        return numa_add_memblk_to(nid, start, end, &numa_meminfo);
 }
 
-/* Initialize NODE_DATA for a node on the local memory */
-static void __init setup_node_data(int nid, u64 start, u64 end)
+/* Allocate NODE_DATA for a node on the local memory */
+static void __init alloc_node_data(int nid)
 {
        const size_t nd_size = roundup(sizeof(pg_data_t), PAGE_SIZE);
        u64 nd_pa;
        void *nd;
        int tnid;
 
-       /*
-        * Don't confuse VM with a node that doesn't have the
-        * minimum amount of memory:
-        */
-       if (end && (end - start) < NODE_MIN_SIZE)
-               return;
-
-       start = roundup(start, ZONE_ALIGN);
-
-       printk(KERN_INFO "Initmem setup node %d [mem %#010Lx-%#010Lx]\n",
-              nid, start, end - 1);
-
        /*
         * Allocate node data.  Try node-local memory and then any node.
         * Never allocate in DMA zone.
@@ -222,7 +210,7 @@ static void __init setup_node_data(int nid, u64 start, u64 end)
        nd = __va(nd_pa);
 
        /* report and initialize */
-       printk(KERN_INFO "  NODE_DATA [mem %#010Lx-%#010Lx]\n",
+       printk(KERN_INFO "NODE_DATA(%d) allocated [mem %#010Lx-%#010Lx]\n", nid,
               nd_pa, nd_pa + nd_size - 1);
        tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT);
        if (tnid != nid)
@@ -230,9 +218,6 @@ static void __init setup_node_data(int nid, u64 start, u64 end)
 
        node_data[nid] = nd;
        memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
-       NODE_DATA(nid)->node_id = nid;
-       NODE_DATA(nid)->node_start_pfn = start >> PAGE_SHIFT;
-       NODE_DATA(nid)->node_spanned_pages = (end - start) >> PAGE_SHIFT;
 
        node_set_online(nid);
 }
@@ -478,6 +463,42 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
        return true;
 }
 
+static void __init numa_clear_kernel_node_hotplug(void)
+{
+       int i, nid;
+       nodemask_t numa_kernel_nodes = NODE_MASK_NONE;
+       unsigned long start, end;
+       struct memblock_region *r;
+
+       /*
+        * At this time, all memory regions reserved by memblock are
+        * used by the kernel. Set the nid in memblock.reserved will
+        * mark out all the nodes the kernel resides in.
+        */
+       for (i = 0; i < numa_meminfo.nr_blks; i++) {
+               struct numa_memblk *mb = &numa_meminfo.blk[i];
+
+               memblock_set_node(mb->start, mb->end - mb->start,
+                                 &memblock.reserved, mb->nid);
+       }
+
+       /* Mark all kernel nodes. */
+       for_each_memblock(reserved, r)
+               node_set(r->nid, numa_kernel_nodes);
+
+       /* Clear MEMBLOCK_HOTPLUG flag for memory in kernel nodes. */
+       for (i = 0; i < numa_meminfo.nr_blks; i++) {
+               nid = numa_meminfo.blk[i].nid;
+               if (!node_isset(nid, numa_kernel_nodes))
+                       continue;
+
+               start = numa_meminfo.blk[i].start;
+               end = numa_meminfo.blk[i].end;
+
+               memblock_clear_hotplug(start, end - start);
+       }
+}
+
 static int __init numa_register_memblks(struct numa_meminfo *mi)
 {
        unsigned long uninitialized_var(pfn_align);
@@ -495,6 +516,15 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
                                  &memblock.memory, mb->nid);
        }
 
+       /*
+        * At very early time, the kernel have to use some memory such as
+        * loading the kernel image. We cannot prevent this anyway. So any
+        * node the kernel resides in should be un-hotpluggable.
+        *
+        * And when we come here, alloc node data won't fail.
+        */
+       numa_clear_kernel_node_hotplug();
+
        /*
         * If sections array is gonna be used for pfn -> nid mapping, check
         * whether its granularity is fine enough.
@@ -523,8 +553,17 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
                        end = max(mi->blk[i].end, end);
                }
 
-               if (start < end)
-                       setup_node_data(nid, start, end);
+               if (start >= end)
+                       continue;
+
+               /*
+                * Don't confuse VM with a node that doesn't have the
+                * minimum amount of memory:
+                */
+               if (end && (end - start) < NODE_MIN_SIZE)
+                       continue;
+
+               alloc_node_data(nid);
        }
 
        /* Dump memblock with node info and return. */
@@ -554,41 +593,6 @@ static void __init numa_init_array(void)
        }
 }
 
-static void __init numa_clear_kernel_node_hotplug(void)
-{
-       int i, nid;
-       nodemask_t numa_kernel_nodes = NODE_MASK_NONE;
-       unsigned long start, end;
-       struct memblock_region *r;
-
-       /*
-        * At this time, all memory regions reserved by memblock are
-        * used by the kernel. Set the nid in memblock.reserved will
-        * mark out all the nodes the kernel resides in.
-        */
-       for (i = 0; i < numa_meminfo.nr_blks; i++) {
-               struct numa_memblk *mb = &numa_meminfo.blk[i];
-               memblock_set_node(mb->start, mb->end - mb->start,
-                                 &memblock.reserved, mb->nid);
-       }
-
-       /* Mark all kernel nodes. */
-       for_each_memblock(reserved, r)
-               node_set(r->nid, numa_kernel_nodes);
-
-       /* Clear MEMBLOCK_HOTPLUG flag for memory in kernel nodes. */
-       for (i = 0; i < numa_meminfo.nr_blks; i++) {
-               nid = numa_meminfo.blk[i].nid;
-               if (!node_isset(nid, numa_kernel_nodes))
-                       continue;
-
-               start = numa_meminfo.blk[i].start;
-               end = numa_meminfo.blk[i].end;
-
-               memblock_clear_hotplug(start, end - start);
-       }
-}
-
 static int __init numa_init(int (*init_func)(void))
 {
        int i;
@@ -643,15 +647,6 @@ static int __init numa_init(int (*init_func)(void))
        }
        numa_init_array();
 
-       /*
-        * At very early time, the kernel have to use some memory such as
-        * loading the kernel image. We cannot prevent this anyway. So any
-        * node the kernel resides in should be un-hotpluggable.
-        *
-        * And when we come here, numa_init() won't fail.
-        */
-       numa_clear_kernel_node_hotplug();
-
        return 0;
 }