node.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. * Per-node interfaces can be implemented using a struct device_interface.
  15. * See the following for how to do this:
  16. * - drivers/base/intf.c
  17. * - Documentation/driver-model/interface.txt
  18. */
  19. #ifndef _LINUX_NODE_H_
  20. #define _LINUX_NODE_H_
  21. #include <linux/sysdev.h>
  22. #include <linux/cpumask.h>
  23. #include <linux/workqueue.h>
  24. struct node {
  25. struct sys_device sysdev;
  26. #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
  27. struct work_struct node_work;
  28. #endif
  29. };
  30. struct memory_block;
  31. extern struct node node_devices[];
  32. typedef void (*node_registration_func_t)(struct node *);
  33. extern int register_node(struct node *, int, struct node *);
  34. extern void unregister_node(struct node *node);
  35. #ifdef CONFIG_NUMA
  36. extern int register_one_node(int nid);
  37. extern void unregister_one_node(int nid);
  38. extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
  39. extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
  40. extern int register_mem_sect_under_node(struct memory_block *mem_blk,
  41. int nid);
  42. extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk);
  43. #ifdef CONFIG_HUGETLBFS
  44. extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
  45. node_registration_func_t unregister);
  46. #endif
  47. #else
  48. static inline int register_one_node(int nid)
  49. {
  50. return 0;
  51. }
  52. static inline int unregister_one_node(int nid)
  53. {
  54. return 0;
  55. }
  56. static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
  57. {
  58. return 0;
  59. }
  60. static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
  61. {
  62. return 0;
  63. }
  64. static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
  65. int nid)
  66. {
  67. return 0;
  68. }
  69. static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk)
  70. {
  71. return 0;
  72. }
  73. static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
  74. node_registration_func_t unreg)
  75. {
  76. }
  77. #endif
  78. #define to_node(sys_device) container_of(sys_device, struct node, sysdev)
  79. #endif /* _LINUX_NODE_H_ */