|
@@ -461,10 +461,9 @@ int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int link_mem_sections(int nid)
|
|
|
+int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages)
|
|
|
{
|
|
|
- unsigned long start_pfn = NODE_DATA(nid)->node_start_pfn;
|
|
|
- unsigned long end_pfn = start_pfn + NODE_DATA(nid)->node_spanned_pages;
|
|
|
+ unsigned long end_pfn = start_pfn + nr_pages;
|
|
|
unsigned long pfn;
|
|
|
struct memory_block *mem_blk = NULL;
|
|
|
int err = 0;
|
|
@@ -552,10 +551,7 @@ static int node_memory_callback(struct notifier_block *self,
|
|
|
return NOTIFY_OK;
|
|
|
}
|
|
|
#endif /* CONFIG_HUGETLBFS */
|
|
|
-#else /* !CONFIG_MEMORY_HOTPLUG_SPARSE */
|
|
|
-
|
|
|
-static int link_mem_sections(int nid) { return 0; }
|
|
|
-#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
|
|
|
+#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
|
|
|
|
|
|
#if !defined(CONFIG_MEMORY_HOTPLUG_SPARSE) || \
|
|
|
!defined(CONFIG_HUGETLBFS)
|
|
@@ -569,39 +565,32 @@ static void init_node_hugetlb_work(int nid) { }
|
|
|
|
|
|
#endif
|
|
|
|
|
|
-int register_one_node(int nid)
|
|
|
+int __register_one_node(int nid)
|
|
|
{
|
|
|
- int error = 0;
|
|
|
+ int p_node = parent_node(nid);
|
|
|
+ struct node *parent = NULL;
|
|
|
+ int error;
|
|
|
int cpu;
|
|
|
|
|
|
- if (node_online(nid)) {
|
|
|
- int p_node = parent_node(nid);
|
|
|
- struct node *parent = NULL;
|
|
|
-
|
|
|
- if (p_node != nid)
|
|
|
- parent = node_devices[p_node];
|
|
|
-
|
|
|
- node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL);
|
|
|
- if (!node_devices[nid])
|
|
|
- return -ENOMEM;
|
|
|
-
|
|
|
- error = register_node(node_devices[nid], nid, parent);
|
|
|
+ if (p_node != nid)
|
|
|
+ parent = node_devices[p_node];
|
|
|
|
|
|
- /* link cpu under this node */
|
|
|
- for_each_present_cpu(cpu) {
|
|
|
- if (cpu_to_node(cpu) == nid)
|
|
|
- register_cpu_under_node(cpu, nid);
|
|
|
- }
|
|
|
+ node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL);
|
|
|
+ if (!node_devices[nid])
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
- /* link memory sections under this node */
|
|
|
- error = link_mem_sections(nid);
|
|
|
+ error = register_node(node_devices[nid], nid, parent);
|
|
|
|
|
|
- /* initialize work queue for memory hot plug */
|
|
|
- init_node_hugetlb_work(nid);
|
|
|
+ /* link cpu under this node */
|
|
|
+ for_each_present_cpu(cpu) {
|
|
|
+ if (cpu_to_node(cpu) == nid)
|
|
|
+ register_cpu_under_node(cpu, nid);
|
|
|
}
|
|
|
|
|
|
- return error;
|
|
|
+ /* initialize work queue for memory hot plug */
|
|
|
+ init_node_hugetlb_work(nid);
|
|
|
|
|
|
+ return error;
|
|
|
}
|
|
|
|
|
|
void unregister_one_node(int nid)
|