memory_hotplug.c (d822b86a99e8d2b7ebbe3aba099288354287a885) | memory_hotplug.c (a1e565aa3cfc7c6252cabc93de8391d12b9216aa) |
---|---|
1/* 2 * linux/mm/memory_hotplug.c 3 * 4 * Copyright (C) 5 */ 6 7#include <linux/stddef.h> 8#include <linux/mm.h> --- 1003 unchanged lines hidden (view full) --- 1012/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ 1013static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) 1014{ 1015 struct pglist_data *pgdat; 1016 unsigned long zones_size[MAX_NR_ZONES] = {0}; 1017 unsigned long zholes_size[MAX_NR_ZONES] = {0}; 1018 unsigned long start_pfn = start >> PAGE_SHIFT; 1019 | 1/* 2 * linux/mm/memory_hotplug.c 3 * 4 * Copyright (C) 5 */ 6 7#include <linux/stddef.h> 8#include <linux/mm.h> --- 1003 unchanged lines hidden (view full) --- 1012/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ 1013static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) 1014{ 1015 struct pglist_data *pgdat; 1016 unsigned long zones_size[MAX_NR_ZONES] = {0}; 1017 unsigned long zholes_size[MAX_NR_ZONES] = {0}; 1018 unsigned long start_pfn = start >> PAGE_SHIFT; 1019 |
1020 pgdat = arch_alloc_nodedata(nid); 1021 if (!pgdat) 1022 return NULL; | 1020 pgdat = NODE_DATA(nid); 1021 if (!pgdat) { 1022 pgdat = arch_alloc_nodedata(nid); 1023 if (!pgdat) 1024 return NULL; |
1023 | 1025 |
1024 arch_refresh_nodedata(nid, pgdat); | 1026 arch_refresh_nodedata(nid, pgdat); 1027 } |
1025 1026 /* we can use NODE_DATA(nid) from here */ 1027 1028 /* init node's zones as empty zones, we don't have any present pages.*/ 1029 free_area_init_node(nid, zones_size, start_pfn, zholes_size); 1030 1031 /* 1032 * The node we allocated has no zone fallback lists. For avoiding --- 36 unchanged lines hidden (view full) --- 1069 unlock_memory_hotplug(); 1070 return ret; 1071} 1072 1073/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ 1074int __ref add_memory(int nid, u64 start, u64 size) 1075{ 1076 pg_data_t *pgdat = NULL; | 1028 1029 /* we can use NODE_DATA(nid) from here */ 1030 1031 /* init node's zones as empty zones, we don't have any present pages.*/ 1032 free_area_init_node(nid, zones_size, start_pfn, zholes_size); 1033 1034 /* 1035 * The node we allocated has no zone fallback lists. For avoiding --- 36 unchanged lines hidden (view full) --- 1072 unlock_memory_hotplug(); 1073 return ret; 1074} 1075 1076/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ 1077int __ref add_memory(int nid, u64 start, u64 size) 1078{ 1079 pg_data_t *pgdat = NULL; |
1077 int new_pgdat = 0; | 1080 bool new_pgdat; 1081 bool new_node; |
1078 struct resource *res; 1079 int ret; 1080 1081 lock_memory_hotplug(); 1082 1083 res = register_memory_resource(start, size); 1084 ret = -EEXIST; 1085 if (!res) 1086 goto out; 1087 | 1082 struct resource *res; 1083 int ret; 1084 1085 lock_memory_hotplug(); 1086 1087 res = register_memory_resource(start, size); 1088 ret = -EEXIST; 1089 if (!res) 1090 goto out; 1091 |
1088 if (!node_online(nid)) { | 1092 { /* Stupid hack to suppress address-never-null warning */ 1093 void *p = NODE_DATA(nid); 1094 new_pgdat = !p; 1095 } 1096 new_node = !node_online(nid); 1097 if (new_node) { |
1089 pgdat = hotadd_new_pgdat(nid, start); 1090 ret = -ENOMEM; 1091 if (!pgdat) 1092 goto error; | 1098 pgdat = hotadd_new_pgdat(nid, start); 1099 ret = -ENOMEM; 1100 if (!pgdat) 1101 goto error; |
1093 new_pgdat = 1; | |
1094 } 1095 1096 /* call arch's memory hotadd */ 1097 ret = arch_add_memory(nid, start, size); 1098 1099 if (ret < 0) 1100 goto error; 1101 1102 /* we online node here. we can't roll back from here. */ 1103 node_set_online(nid); 1104 | 1102 } 1103 1104 /* call arch's memory hotadd */ 1105 ret = arch_add_memory(nid, start, size); 1106 1107 if (ret < 0) 1108 goto error; 1109 1110 /* we online node here. we can't roll back from here. */ 1111 node_set_online(nid); 1112 |
1105 if (new_pgdat) { | 1113 if (new_node) { |
1106 ret = register_one_node(nid); 1107 /* 1108 * If sysfs file of new node can't create, cpu on the node 1109 * can't be hot-added. There is no rollback way now. 1110 * So, check by BUG_ON() to catch it reluctantly.. 1111 */ 1112 BUG_ON(ret); 1113 } --- 716 unchanged lines hidden --- | 1114 ret = register_one_node(nid); 1115 /* 1116 * If sysfs file of new node can't create, cpu on the node 1117 * can't be hot-added. There is no rollback way now. 1118 * So, check by BUG_ON() to catch it reluctantly.. 1119 */ 1120 BUG_ON(ret); 1121 } --- 716 unchanged lines hidden --- |