node.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * include/linux/node.h - generic node definition
  3. *
  4. * This is mainly for topological representation. We define the
  5. * basic 'struct node' here, which can be embedded in per-arch
  6. * definitions of processors.
  7. *
  8. * Basic handling of the devices is done in drivers/base/node.c
  9. * and system devices are handled in drivers/base/sys.c.
  10. *
  11. * Nodes are exported via driverfs in the class/node/devices/
  12. * directory.
  13. */
  14. #ifndef _LINUX_NODE_H_
  15. #define _LINUX_NODE_H_
  16. #include <linux/device.h>
  17. #include <linux/cpumask.h>
  18. #include <linux/workqueue.h>
  19. struct node {
  20. struct device dev;
  21. #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
  22. struct work_struct node_work;
  23. #endif
  24. };
  25. struct memory_block;
  26. extern struct node *node_devices[];
  27. typedef void (*node_registration_func_t)(struct node *);
  28. #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
  29. extern int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages);
  30. #else
  31. static inline int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages)
  32. {
  33. return 0;
  34. }
  35. #endif
  36. extern void unregister_node(struct node *node);
  37. #ifdef CONFIG_NUMA
  38. /* Core of the node registration - only memory hotplug should use this */
  39. extern int __register_one_node(int nid);
  40. /* Registers an online node */
  41. static inline int register_one_node(int nid)
  42. {
  43. int error = 0;
  44. if (node_online(nid)) {
  45. struct pglist_data *pgdat = NODE_DATA(nid);
  46. error = __register_one_node(nid);
  47. if (error)
  48. return error;
  49. /* link memory sections under this node */
  50. error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages);
  51. }
  52. return error;
  53. }
  54. extern void unregister_one_node(int nid);
  55. extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
  56. extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
  57. extern int register_mem_sect_under_node(struct memory_block *mem_blk,
  58. int nid);
  59. extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
  60. unsigned long phys_index);
  61. #ifdef CONFIG_HUGETLBFS
  62. extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
  63. node_registration_func_t unregister);
  64. #endif
  65. #else
  66. static inline int __register_one_node(int nid)
  67. {
  68. return 0;
  69. }
  70. static inline int register_one_node(int nid)
  71. {
  72. return 0;
  73. }
  74. static inline int unregister_one_node(int nid)
  75. {
  76. return 0;
  77. }
  78. static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
  79. {
  80. return 0;
  81. }
  82. static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
  83. {
  84. return 0;
  85. }
  86. static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
  87. int nid)
  88. {
  89. return 0;
  90. }
  91. static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
  92. unsigned long phys_index)
  93. {
  94. return 0;
  95. }
  96. static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
  97. node_registration_func_t unreg)
  98. {
  99. }
  100. #endif
  101. #define to_node(device) container_of(device, struct node, dev)
  102. #endif /* _LINUX_NODE_H_ */