topology.c 627 B

123456789101112131415161718192021222324252627282930313233
  1. #include <linux/cpu.h>
  2. #include <linux/cpumask.h>
  3. #include <linux/init.h>
  4. #include <linux/node.h>
  5. #include <linux/nodemask.h>
  6. #include <linux/percpu.h>
  7. static DEFINE_PER_CPU(struct cpu, cpu_devices);
  8. static int __init topology_init(void)
  9. {
  10. int i, ret;
  11. #ifdef CONFIG_NUMA
  12. for_each_online_node(i)
  13. register_one_node(i);
  14. #endif /* CONFIG_NUMA */
  15. for_each_present_cpu(i) {
  16. struct cpu *c = &per_cpu(cpu_devices, i);
  17. c->hotpluggable = 1;
  18. ret = register_cpu(c, i);
  19. if (ret)
  20. printk(KERN_WARNING "topology_init: register_cpu %d "
  21. "failed (%d)\n", i, ret);
  22. }
  23. return 0;
  24. }
  25. subsys_initcall(topology_init);