numa_64.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. /*
  2. * Generic VM initialization for x86-64 NUMA setups.
  3. * Copyright 2002,2003 Andi Kleen, SuSE Labs.
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/mm.h>
  7. #include <linux/string.h>
  8. #include <linux/init.h>
  9. #include <linux/bootmem.h>
  10. #include <linux/mmzone.h>
  11. #include <linux/ctype.h>
  12. #include <linux/module.h>
  13. #include <linux/nodemask.h>
  14. #include <linux/sched.h>
  15. #include <asm/e820.h>
  16. #include <asm/proto.h>
  17. #include <asm/dma.h>
  18. #include <asm/numa.h>
  19. #include <asm/acpi.h>
  20. #include <asm/k8.h>
  21. #ifndef Dprintk
  22. #define Dprintk(x...)
  23. #endif
  24. struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
  25. EXPORT_SYMBOL(node_data);
  26. bootmem_data_t plat_node_bdata[MAX_NUMNODES];
  27. struct memnode memnode;
  28. int x86_cpu_to_node_map_init[NR_CPUS] = {
  29. [0 ... NR_CPUS-1] = NUMA_NO_NODE
  30. };
  31. void *x86_cpu_to_node_map_early_ptr;
  32. DEFINE_PER_CPU(int, x86_cpu_to_node_map) = NUMA_NO_NODE;
  33. EXPORT_PER_CPU_SYMBOL(x86_cpu_to_node_map);
  34. EXPORT_SYMBOL(x86_cpu_to_node_map_early_ptr);
  35. s16 apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = {
  36. [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
  37. };
  38. cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly;
  39. EXPORT_SYMBOL(node_to_cpumask_map);
  40. int numa_off __initdata;
  41. unsigned long __initdata nodemap_addr;
  42. unsigned long __initdata nodemap_size;
  43. /*
  44. * Given a shift value, try to populate memnodemap[]
  45. * Returns :
  46. * 1 if OK
  47. * 0 if memnodmap[] too small (of shift too small)
  48. * -1 if node overlap or lost ram (shift too big)
  49. */
  50. static int __init populate_memnodemap(const struct bootnode *nodes,
  51. int numnodes, int shift)
  52. {
  53. unsigned long addr, end;
  54. int i, res = -1;
  55. memset(memnodemap, 0xff, sizeof(s16)*memnodemapsize);
  56. for (i = 0; i < numnodes; i++) {
  57. addr = nodes[i].start;
  58. end = nodes[i].end;
  59. if (addr >= end)
  60. continue;
  61. if ((end >> shift) >= memnodemapsize)
  62. return 0;
  63. do {
  64. if (memnodemap[addr >> shift] != NUMA_NO_NODE)
  65. return -1;
  66. memnodemap[addr >> shift] = i;
  67. addr += (1UL << shift);
  68. } while (addr < end);
  69. res = 1;
  70. }
  71. return res;
  72. }
  73. static int __init allocate_cachealigned_memnodemap(void)
  74. {
  75. unsigned long pad, pad_addr;
  76. memnodemap = memnode.embedded_map;
  77. if (memnodemapsize <= ARRAY_SIZE(memnode.embedded_map))
  78. return 0;
  79. pad = L1_CACHE_BYTES - 1;
  80. pad_addr = 0x8000;
  81. nodemap_size = pad + sizeof(s16) * memnodemapsize;
  82. nodemap_addr = find_e820_area(pad_addr, end_pfn<<PAGE_SHIFT,
  83. nodemap_size);
  84. if (nodemap_addr == -1UL) {
  85. printk(KERN_ERR
  86. "NUMA: Unable to allocate Memory to Node hash map\n");
  87. nodemap_addr = nodemap_size = 0;
  88. return -1;
  89. }
  90. pad_addr = (nodemap_addr + pad) & ~pad;
  91. memnodemap = phys_to_virt(pad_addr);
  92. reserve_early(nodemap_addr, nodemap_addr + nodemap_size);
  93. printk(KERN_DEBUG "NUMA: Allocated memnodemap from %lx - %lx\n",
  94. nodemap_addr, nodemap_addr + nodemap_size);
  95. return 0;
  96. }
  97. /*
  98. * The LSB of all start and end addresses in the node map is the value of the
  99. * maximum possible shift.
  100. */
  101. static int __init extract_lsb_from_nodes(const struct bootnode *nodes,
  102. int numnodes)
  103. {
  104. int i, nodes_used = 0;
  105. unsigned long start, end;
  106. unsigned long bitfield = 0, memtop = 0;
  107. for (i = 0; i < numnodes; i++) {
  108. start = nodes[i].start;
  109. end = nodes[i].end;
  110. if (start >= end)
  111. continue;
  112. bitfield |= start;
  113. nodes_used++;
  114. if (end > memtop)
  115. memtop = end;
  116. }
  117. if (nodes_used <= 1)
  118. i = 63;
  119. else
  120. i = find_first_bit(&bitfield, sizeof(unsigned long)*8);
  121. memnodemapsize = (memtop >> i)+1;
  122. return i;
  123. }
  124. int __init compute_hash_shift(struct bootnode *nodes, int numnodes)
  125. {
  126. int shift;
  127. shift = extract_lsb_from_nodes(nodes, numnodes);
  128. if (allocate_cachealigned_memnodemap())
  129. return -1;
  130. printk(KERN_DEBUG "NUMA: Using %d for the hash shift.\n",
  131. shift);
  132. if (populate_memnodemap(nodes, numnodes, shift) != 1) {
  133. printk(KERN_INFO "Your memory is not aligned you need to "
  134. "rebuild your kernel with a bigger NODEMAPSIZE "
  135. "shift=%d\n", shift);
  136. return -1;
  137. }
  138. return shift;
  139. }
  140. int early_pfn_to_nid(unsigned long pfn)
  141. {
  142. return phys_to_nid(pfn << PAGE_SHIFT);
  143. }
  144. static void * __init early_node_mem(int nodeid, unsigned long start,
  145. unsigned long end, unsigned long size)
  146. {
  147. unsigned long mem = find_e820_area(start, end, size);
  148. void *ptr;
  149. if (mem != -1L)
  150. return __va(mem);
  151. ptr = __alloc_bootmem_nopanic(size,
  152. SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS));
  153. if (ptr == NULL) {
  154. printk(KERN_ERR "Cannot find %lu bytes in node %d\n",
  155. size, nodeid);
  156. return NULL;
  157. }
  158. return ptr;
  159. }
  160. /* Initialize bootmem allocator for a node */
  161. void __init setup_node_bootmem(int nodeid, unsigned long start,
  162. unsigned long end)
  163. {
  164. unsigned long start_pfn, end_pfn, bootmap_pages, bootmap_size;
  165. unsigned long bootmap_start, nodedata_phys;
  166. void *bootmap;
  167. const int pgdat_size = round_up(sizeof(pg_data_t), PAGE_SIZE);
  168. start = round_up(start, ZONE_ALIGN);
  169. printk(KERN_INFO "Bootmem setup node %d %016lx-%016lx\n", nodeid,
  170. start, end);
  171. start_pfn = start >> PAGE_SHIFT;
  172. end_pfn = end >> PAGE_SHIFT;
  173. node_data[nodeid] = early_node_mem(nodeid, start, end, pgdat_size);
  174. if (node_data[nodeid] == NULL)
  175. return;
  176. nodedata_phys = __pa(node_data[nodeid]);
  177. memset(NODE_DATA(nodeid), 0, sizeof(pg_data_t));
  178. NODE_DATA(nodeid)->bdata = &plat_node_bdata[nodeid];
  179. NODE_DATA(nodeid)->node_start_pfn = start_pfn;
  180. NODE_DATA(nodeid)->node_spanned_pages = end_pfn - start_pfn;
  181. /* Find a place for the bootmem map */
  182. bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
  183. bootmap_start = round_up(nodedata_phys + pgdat_size, PAGE_SIZE);
  184. bootmap = early_node_mem(nodeid, bootmap_start, end,
  185. bootmap_pages<<PAGE_SHIFT);
  186. if (bootmap == NULL) {
  187. if (nodedata_phys < start || nodedata_phys >= end)
  188. free_bootmem((unsigned long)node_data[nodeid],
  189. pgdat_size);
  190. node_data[nodeid] = NULL;
  191. return;
  192. }
  193. bootmap_start = __pa(bootmap);
  194. Dprintk("bootmap start %lu pages %lu\n", bootmap_start, bootmap_pages);
  195. bootmap_size = init_bootmem_node(NODE_DATA(nodeid),
  196. bootmap_start >> PAGE_SHIFT,
  197. start_pfn, end_pfn);
  198. free_bootmem_with_active_regions(nodeid, end);
  199. reserve_bootmem_node(NODE_DATA(nodeid), nodedata_phys, pgdat_size);
  200. reserve_bootmem_node(NODE_DATA(nodeid), bootmap_start,
  201. bootmap_pages<<PAGE_SHIFT);
  202. #ifdef CONFIG_ACPI_NUMA
  203. srat_reserve_add_area(nodeid);
  204. #endif
  205. node_set_online(nodeid);
  206. }
  207. /*
  208. * There are unfortunately some poorly designed mainboards around that
  209. * only connect memory to a single CPU. This breaks the 1:1 cpu->node
  210. * mapping. To avoid this fill in the mapping for all possible CPUs,
  211. * as the number of CPUs is not known yet. We round robin the existing
  212. * nodes.
  213. */
  214. void __init numa_init_array(void)
  215. {
  216. int rr, i;
  217. rr = first_node(node_online_map);
  218. for (i = 0; i < NR_CPUS; i++) {
  219. if (early_cpu_to_node(i) != NUMA_NO_NODE)
  220. continue;
  221. numa_set_node(i, rr);
  222. rr = next_node(rr, node_online_map);
  223. if (rr == MAX_NUMNODES)
  224. rr = first_node(node_online_map);
  225. }
  226. }
  227. #ifdef CONFIG_NUMA_EMU
  228. /* Numa emulation */
  229. char *cmdline __initdata;
  230. /*
  231. * Setups up nid to range from addr to addr + size. If the end
  232. * boundary is greater than max_addr, then max_addr is used instead.
  233. * The return value is 0 if there is additional memory left for
  234. * allocation past addr and -1 otherwise. addr is adjusted to be at
  235. * the end of the node.
  236. */
  237. static int __init setup_node_range(int nid, struct bootnode *nodes, u64 *addr,
  238. u64 size, u64 max_addr)
  239. {
  240. int ret = 0;
  241. nodes[nid].start = *addr;
  242. *addr += size;
  243. if (*addr >= max_addr) {
  244. *addr = max_addr;
  245. ret = -1;
  246. }
  247. nodes[nid].end = *addr;
  248. node_set(nid, node_possible_map);
  249. printk(KERN_INFO "Faking node %d at %016Lx-%016Lx (%LuMB)\n", nid,
  250. nodes[nid].start, nodes[nid].end,
  251. (nodes[nid].end - nodes[nid].start) >> 20);
  252. return ret;
  253. }
  254. /*
  255. * Splits num_nodes nodes up equally starting at node_start. The return value
  256. * is the number of nodes split up and addr is adjusted to be at the end of the
  257. * last node allocated.
  258. */
  259. static int __init split_nodes_equally(struct bootnode *nodes, u64 *addr,
  260. u64 max_addr, int node_start,
  261. int num_nodes)
  262. {
  263. unsigned int big;
  264. u64 size;
  265. int i;
  266. if (num_nodes <= 0)
  267. return -1;
  268. if (num_nodes > MAX_NUMNODES)
  269. num_nodes = MAX_NUMNODES;
  270. size = (max_addr - *addr - e820_hole_size(*addr, max_addr)) /
  271. num_nodes;
  272. /*
  273. * Calculate the number of big nodes that can be allocated as a result
  274. * of consolidating the leftovers.
  275. */
  276. big = ((size & ~FAKE_NODE_MIN_HASH_MASK) * num_nodes) /
  277. FAKE_NODE_MIN_SIZE;
  278. /* Round down to nearest FAKE_NODE_MIN_SIZE. */
  279. size &= FAKE_NODE_MIN_HASH_MASK;
  280. if (!size) {
  281. printk(KERN_ERR "Not enough memory for each node. "
  282. "NUMA emulation disabled.\n");
  283. return -1;
  284. }
  285. for (i = node_start; i < num_nodes + node_start; i++) {
  286. u64 end = *addr + size;
  287. if (i < big)
  288. end += FAKE_NODE_MIN_SIZE;
  289. /*
  290. * The final node can have the remaining system RAM. Other
  291. * nodes receive roughly the same amount of available pages.
  292. */
  293. if (i == num_nodes + node_start - 1)
  294. end = max_addr;
  295. else
  296. while (end - *addr - e820_hole_size(*addr, end) <
  297. size) {
  298. end += FAKE_NODE_MIN_SIZE;
  299. if (end > max_addr) {
  300. end = max_addr;
  301. break;
  302. }
  303. }
  304. if (setup_node_range(i, nodes, addr, end - *addr, max_addr) < 0)
  305. break;
  306. }
  307. return i - node_start + 1;
  308. }
  309. /*
  310. * Splits the remaining system RAM into chunks of size. The remaining memory is
  311. * always assigned to a final node and can be asymmetric. Returns the number of
  312. * nodes split.
  313. */
  314. static int __init split_nodes_by_size(struct bootnode *nodes, u64 *addr,
  315. u64 max_addr, int node_start, u64 size)
  316. {
  317. int i = node_start;
  318. size = (size << 20) & FAKE_NODE_MIN_HASH_MASK;
  319. while (!setup_node_range(i++, nodes, addr, size, max_addr))
  320. ;
  321. return i - node_start;
  322. }
  323. /*
  324. * Sets up the system RAM area from start_pfn to end_pfn according to the
  325. * numa=fake command-line option.
  326. */
  327. static int __init numa_emulation(unsigned long start_pfn, unsigned long end_pfn)
  328. {
  329. struct bootnode nodes[MAX_NUMNODES];
  330. u64 size, addr = start_pfn << PAGE_SHIFT;
  331. u64 max_addr = end_pfn << PAGE_SHIFT;
  332. int num_nodes = 0, num = 0, coeff_flag, coeff = -1, i;
  333. memset(&nodes, 0, sizeof(nodes));
  334. /*
  335. * If the numa=fake command-line is just a single number N, split the
  336. * system RAM into N fake nodes.
  337. */
  338. if (!strchr(cmdline, '*') && !strchr(cmdline, ',')) {
  339. long n = simple_strtol(cmdline, NULL, 0);
  340. num_nodes = split_nodes_equally(nodes, &addr, max_addr, 0, n);
  341. if (num_nodes < 0)
  342. return num_nodes;
  343. goto out;
  344. }
  345. /* Parse the command line. */
  346. for (coeff_flag = 0; ; cmdline++) {
  347. if (*cmdline && isdigit(*cmdline)) {
  348. num = num * 10 + *cmdline - '0';
  349. continue;
  350. }
  351. if (*cmdline == '*') {
  352. if (num > 0)
  353. coeff = num;
  354. coeff_flag = 1;
  355. }
  356. if (!*cmdline || *cmdline == ',') {
  357. if (!coeff_flag)
  358. coeff = 1;
  359. /*
  360. * Round down to the nearest FAKE_NODE_MIN_SIZE.
  361. * Command-line coefficients are in megabytes.
  362. */
  363. size = ((u64)num << 20) & FAKE_NODE_MIN_HASH_MASK;
  364. if (size)
  365. for (i = 0; i < coeff; i++, num_nodes++)
  366. if (setup_node_range(num_nodes, nodes,
  367. &addr, size, max_addr) < 0)
  368. goto done;
  369. if (!*cmdline)
  370. break;
  371. coeff_flag = 0;
  372. coeff = -1;
  373. }
  374. num = 0;
  375. }
  376. done:
  377. if (!num_nodes)
  378. return -1;
  379. /* Fill remainder of system RAM, if appropriate. */
  380. if (addr < max_addr) {
  381. if (coeff_flag && coeff < 0) {
  382. /* Split remaining nodes into num-sized chunks */
  383. num_nodes += split_nodes_by_size(nodes, &addr, max_addr,
  384. num_nodes, num);
  385. goto out;
  386. }
  387. switch (*(cmdline - 1)) {
  388. case '*':
  389. /* Split remaining nodes into coeff chunks */
  390. if (coeff <= 0)
  391. break;
  392. num_nodes += split_nodes_equally(nodes, &addr, max_addr,
  393. num_nodes, coeff);
  394. break;
  395. case ',':
  396. /* Do not allocate remaining system RAM */
  397. break;
  398. default:
  399. /* Give one final node */
  400. setup_node_range(num_nodes, nodes, &addr,
  401. max_addr - addr, max_addr);
  402. num_nodes++;
  403. }
  404. }
  405. out:
  406. memnode_shift = compute_hash_shift(nodes, num_nodes);
  407. if (memnode_shift < 0) {
  408. memnode_shift = 0;
  409. printk(KERN_ERR "No NUMA hash function found. NUMA emulation "
  410. "disabled.\n");
  411. return -1;
  412. }
  413. /*
  414. * We need to vacate all active ranges that may have been registered by
  415. * SRAT and set acpi_numa to -1 so that srat_disabled() always returns
  416. * true. NUMA emulation has succeeded so we will not scan ACPI nodes.
  417. */
  418. remove_all_active_ranges();
  419. #ifdef CONFIG_ACPI_NUMA
  420. acpi_numa = -1;
  421. #endif
  422. for_each_node_mask(i, node_possible_map) {
  423. e820_register_active_regions(i, nodes[i].start >> PAGE_SHIFT,
  424. nodes[i].end >> PAGE_SHIFT);
  425. setup_node_bootmem(i, nodes[i].start, nodes[i].end);
  426. }
  427. acpi_fake_nodes(nodes, num_nodes);
  428. numa_init_array();
  429. return 0;
  430. }
  431. #endif /* CONFIG_NUMA_EMU */
  432. void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
  433. {
  434. int i;
  435. nodes_clear(node_possible_map);
  436. #ifdef CONFIG_NUMA_EMU
  437. if (cmdline && !numa_emulation(start_pfn, end_pfn))
  438. return;
  439. nodes_clear(node_possible_map);
  440. #endif
  441. #ifdef CONFIG_ACPI_NUMA
  442. if (!numa_off && !acpi_scan_nodes(start_pfn << PAGE_SHIFT,
  443. end_pfn << PAGE_SHIFT))
  444. return;
  445. nodes_clear(node_possible_map);
  446. #endif
  447. #ifdef CONFIG_K8_NUMA
  448. if (!numa_off && !k8_scan_nodes(start_pfn<<PAGE_SHIFT,
  449. end_pfn<<PAGE_SHIFT))
  450. return;
  451. nodes_clear(node_possible_map);
  452. #endif
  453. printk(KERN_INFO "%s\n",
  454. numa_off ? "NUMA turned off" : "No NUMA configuration found");
  455. printk(KERN_INFO "Faking a node at %016lx-%016lx\n",
  456. start_pfn << PAGE_SHIFT,
  457. end_pfn << PAGE_SHIFT);
  458. /* setup dummy node covering all memory */
  459. memnode_shift = 63;
  460. memnodemap = memnode.embedded_map;
  461. memnodemap[0] = 0;
  462. nodes_clear(node_online_map);
  463. node_set_online(0);
  464. node_set(0, node_possible_map);
  465. for (i = 0; i < NR_CPUS; i++)
  466. numa_set_node(i, 0);
  467. /* cpumask_of_cpu() may not be available during early startup */
  468. memset(&node_to_cpumask_map[0], 0, sizeof(node_to_cpumask_map[0]));
  469. cpu_set(0, node_to_cpumask_map[0]);
  470. e820_register_active_regions(0, start_pfn, end_pfn);
  471. setup_node_bootmem(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
  472. }
  473. __cpuinit void numa_add_cpu(int cpu)
  474. {
  475. set_bit(cpu,
  476. (unsigned long *)&node_to_cpumask_map[early_cpu_to_node(cpu)]);
  477. }
  478. void __cpuinit numa_set_node(int cpu, int node)
  479. {
  480. int *cpu_to_node_map = x86_cpu_to_node_map_early_ptr;
  481. cpu_pda(cpu)->nodenumber = node;
  482. if(cpu_to_node_map)
  483. cpu_to_node_map[cpu] = node;
  484. else if(per_cpu_offset(cpu))
  485. per_cpu(x86_cpu_to_node_map, cpu) = node;
  486. else
  487. Dprintk(KERN_INFO "Setting node for non-present cpu %d\n", cpu);
  488. }
  489. unsigned long __init numa_free_all_bootmem(void)
  490. {
  491. unsigned long pages = 0;
  492. int i;
  493. for_each_online_node(i)
  494. pages += free_all_bootmem_node(NODE_DATA(i));
  495. return pages;
  496. }
  497. void __init paging_init(void)
  498. {
  499. unsigned long max_zone_pfns[MAX_NR_ZONES];
  500. memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
  501. max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
  502. max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
  503. max_zone_pfns[ZONE_NORMAL] = end_pfn;
  504. sparse_memory_present_with_active_regions(MAX_NUMNODES);
  505. sparse_init();
  506. free_area_init_nodes(max_zone_pfns);
  507. }
  508. static __init int numa_setup(char *opt)
  509. {
  510. if (!opt)
  511. return -EINVAL;
  512. if (!strncmp(opt, "off", 3))
  513. numa_off = 1;
  514. #ifdef CONFIG_NUMA_EMU
  515. if (!strncmp(opt, "fake=", 5))
  516. cmdline = opt + 5;
  517. #endif
  518. #ifdef CONFIG_ACPI_NUMA
  519. if (!strncmp(opt, "noacpi", 6))
  520. acpi_numa = -1;
  521. if (!strncmp(opt, "hotadd=", 7))
  522. hotadd_percent = simple_strtoul(opt+7, NULL, 10);
  523. #endif
  524. return 0;
  525. }
  526. early_param("numa", numa_setup);
  527. /*
  528. * Setup early cpu_to_node.
  529. *
  530. * Populate cpu_to_node[] only if x86_cpu_to_apicid[],
  531. * and apicid_to_node[] tables have valid entries for a CPU.
  532. * This means we skip cpu_to_node[] initialisation for NUMA
  533. * emulation and faking node case (when running a kernel compiled
  534. * for NUMA on a non NUMA box), which is OK as cpu_to_node[]
  535. * is already initialized in a round robin manner at numa_init_array,
  536. * prior to this call, and this initialization is good enough
  537. * for the fake NUMA cases.
  538. */
  539. void __init init_cpu_to_node(void)
  540. {
  541. int i;
  542. for (i = 0; i < NR_CPUS; i++) {
  543. u16 apicid = x86_cpu_to_apicid_init[i];
  544. if (apicid == BAD_APICID)
  545. continue;
  546. if (apicid_to_node[apicid] == NUMA_NO_NODE)
  547. continue;
  548. numa_set_node(i, apicid_to_node[apicid]);
  549. }
  550. }