node.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. extern void unregister_node(struct node *node);
  29. #ifdef CONFIG_NUMA
  30. extern int register_one_node(int nid);
  31. extern void unregister_one_node(int nid);
  32. extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
  33. extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
  34. extern int register_mem_sect_under_node(struct memory_block *mem_blk,
  35. int nid);
  36. extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
  37. unsigned long phys_index);
  38. #ifdef CONFIG_HUGETLBFS
  39. extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
  40. node_registration_func_t unregister);
  41. #endif
  42. #else
  43. static inline int register_one_node(int nid)
  44. {
  45. return 0;
  46. }
  47. static inline int unregister_one_node(int nid)
  48. {
  49. return 0;
  50. }
  51. static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
  52. {
  53. return 0;
  54. }
  55. static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
  56. {
  57. return 0;
  58. }
  59. static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
  60. int nid)
  61. {
  62. return 0;
  63. }
  64. static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
  65. unsigned long phys_index)
  66. {
  67. return 0;
  68. }
  69. static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
  70. node_registration_func_t unreg)
  71. {
  72. }
  73. #endif
  74. #define to_node(device) container_of(device, struct node, dev)
  75. #endif /* _LINUX_NODE_H_ */