numa_64.c 16 KB

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