numa.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * apicid, cpu, node mappings
  27. */
  28. s16 __apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = {
  29. [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
  30. };
  31. cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
  32. EXPORT_SYMBOL(node_to_cpumask_map);
  33. /*
  34. * Allocate node_to_cpumask_map based on number of available nodes
  35. * Requires node_possible_map to be valid.
  36. *
  37. * Note: node_to_cpumask() is not valid until after this is done.
  38. * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.)
  39. */
  40. void __init setup_node_to_cpumask_map(void)
  41. {
  42. unsigned int node, num = 0;
  43. /* setup nr_node_ids if not done yet */
  44. if (nr_node_ids == MAX_NUMNODES) {
  45. for_each_node_mask(node, node_possible_map)
  46. num = node;
  47. nr_node_ids = num + 1;
  48. }
  49. /* allocate the map */
  50. for (node = 0; node < nr_node_ids; node++)
  51. alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);
  52. /* cpumask_of_node() will now work */
  53. pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids);
  54. }
  55. #ifdef CONFIG_DEBUG_PER_CPU_MAPS
  56. /*
  57. * Returns a pointer to the bitmask of CPUs on Node 'node'.
  58. */
  59. const struct cpumask *cpumask_of_node(int node)
  60. {
  61. if (node >= nr_node_ids) {
  62. printk(KERN_WARNING
  63. "cpumask_of_node(%d): node > nr_node_ids(%d)\n",
  64. node, nr_node_ids);
  65. dump_stack();
  66. return cpu_none_mask;
  67. }
  68. if (node_to_cpumask_map[node] == NULL) {
  69. printk(KERN_WARNING
  70. "cpumask_of_node(%d): no node_to_cpumask_map!\n",
  71. node);
  72. dump_stack();
  73. return cpu_online_mask;
  74. }
  75. return node_to_cpumask_map[node];
  76. }
  77. EXPORT_SYMBOL(cpumask_of_node);
  78. #endif