numa.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Common code for 32 and 64-bit NUMA */
  2. #include <linux/topology.h>
  3. #include <linux/module.h>
  4. #include <linux/bootmem.h>
  5. #include <asm/numa.h>
  6. #include <asm/acpi.h>
  7. int __initdata numa_off;
  8. static __init int numa_setup(char *opt)
  9. {
  10. if (!opt)
  11. return -EINVAL;
  12. if (!strncmp(opt, "off", 3))
  13. numa_off = 1;
  14. #ifdef CONFIG_NUMA_EMU
  15. if (!strncmp(opt, "fake=", 5))
  16. numa_emu_cmdline(opt + 5);
  17. #endif
  18. #ifdef CONFIG_ACPI_NUMA
  19. if (!strncmp(opt, "noacpi", 6))
  20. acpi_numa = -1;
  21. #endif
  22. return 0;
  23. }
  24. early_param("numa", numa_setup);
  25. /*
  26. * Which logical CPUs are on which nodes
  27. */
  28. cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
  29. EXPORT_SYMBOL(node_to_cpumask_map);
  30. /*
  31. * Allocate node_to_cpumask_map based on number of available nodes
  32. * Requires node_possible_map to be valid.
  33. *
  34. * Note: node_to_cpumask() is not valid until after this is done.
  35. * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.)
  36. */
  37. void __init setup_node_to_cpumask_map(void)
  38. {
  39. unsigned int node, num = 0;
  40. /* setup nr_node_ids if not done yet */
  41. if (nr_node_ids == MAX_NUMNODES) {
  42. for_each_node_mask(node, node_possible_map)
  43. num = node;
  44. nr_node_ids = num + 1;
  45. }
  46. /* allocate the map */
  47. for (node = 0; node < nr_node_ids; node++)
  48. alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);
  49. /* cpumask_of_node() will now work */
  50. pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids);
  51. }
  52. #ifdef CONFIG_DEBUG_PER_CPU_MAPS
  53. /*
  54. * Returns a pointer to the bitmask of CPUs on Node 'node'.
  55. */
  56. const struct cpumask *cpumask_of_node(int node)
  57. {
  58. if (node >= nr_node_ids) {
  59. printk(KERN_WARNING
  60. "cpumask_of_node(%d): node > nr_node_ids(%d)\n",
  61. node, nr_node_ids);
  62. dump_stack();
  63. return cpu_none_mask;
  64. }
  65. if (node_to_cpumask_map[node] == NULL) {
  66. printk(KERN_WARNING
  67. "cpumask_of_node(%d): no node_to_cpumask_map!\n",
  68. node);
  69. dump_stack();
  70. return cpu_online_mask;
  71. }
  72. return node_to_cpumask_map[node];
  73. }
  74. EXPORT_SYMBOL(cpumask_of_node);
  75. #endif