node.h 2.2 KB

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