Blame view

include/linux/node.h 3 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
7
8
9
10
11
12
13
  /*
   * include/linux/node.h - generic node definition
   *
   * This is mainly for topological representation. We define the 
   * basic 'struct node' here, which can be embedded in per-arch 
   * definitions of processors.
   *
   * Basic handling of the devices is done in drivers/base/node.c
   * and system devices are handled in drivers/base/sys.c. 
   *
   * Nodes are exported via driverfs in the class/node/devices/
   * directory. 
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
   */
  #ifndef _LINUX_NODE_H_
  #define _LINUX_NODE_H_
10fbcf4c6   Kay Sievers   convert 'memory' ...
17
  #include <linux/device.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
  #include <linux/cpumask.h>
39da08cb0   Lee Schermerhorn   hugetlb: offload ...
19
  #include <linux/workqueue.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20
21
  
  struct node {
10fbcf4c6   Kay Sievers   convert 'memory' ...
22
  	struct device	dev;
39da08cb0   Lee Schermerhorn   hugetlb: offload ...
23
24
25
26
  
  #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
  	struct work_struct	node_work;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
  };
c04fc586c   Gary Hade   mm: show node to ...
28
  struct memory_block;
8732794b1   Wen Congyang   numa: convert sta...
29
  extern struct node *node_devices[];
9a3052306   Lee Schermerhorn   hugetlb: add per ...
30
  typedef  void (*node_registration_func_t)(struct node *);
0fc44159b   Yasunori Goto   [PATCH] Register ...
31

9037a9934   Michal Hocko   mm, memory_hotplu...
32
33
34
35
36
37
38
39
  #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
  extern int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages);
  #else
  static inline int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages)
  {
  	return 0;
  }
  #endif
4b45099b7   Keiichiro Tokunaga   [PATCH] Driver co...
40
  extern void unregister_node(struct node *node);
36920e069   KAMEZAWA Hiroyuki   [PATCH] register_...
41
  #ifdef CONFIG_NUMA
9037a9934   Michal Hocko   mm, memory_hotplu...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  /* Core of the node registration - only memory hotplug should use this */
  extern int __register_one_node(int nid);
  
  /* Registers an online node */
  static inline int register_one_node(int nid)
  {
  	int error = 0;
  
  	if (node_online(nid)) {
  		struct pglist_data *pgdat = NODE_DATA(nid);
  
  		error = __register_one_node(nid);
  		if (error)
  			return error;
  		/* link memory sections under this node */
  		error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages);
  	}
  
  	return error;
  }
0fc44159b   Yasunori Goto   [PATCH] Register ...
62
  extern void unregister_one_node(int nid);
76b67ed9d   KAMEZAWA Hiroyuki   [PATCH] node hotp...
63
64
  extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
  extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
c04fc586c   Gary Hade   mm: show node to ...
65
66
  extern int register_mem_sect_under_node(struct memory_block *mem_blk,
  						int nid);
d33601644   Nathan Fontenot   memory hotplug: U...
67
68
  extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
  					   unsigned long phys_index);
9a3052306   Lee Schermerhorn   hugetlb: add per ...
69
70
71
72
73
  
  #ifdef CONFIG_HUGETLBFS
  extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
  					 node_registration_func_t unregister);
  #endif
76b67ed9d   KAMEZAWA Hiroyuki   [PATCH] node hotp...
74
  #else
9037a9934   Michal Hocko   mm, memory_hotplu...
75
76
77
78
  static inline int __register_one_node(int nid)
  {
  	return 0;
  }
36920e069   KAMEZAWA Hiroyuki   [PATCH] register_...
79
80
81
82
83
84
85
86
  static inline int register_one_node(int nid)
  {
  	return 0;
  }
  static inline int unregister_one_node(int nid)
  {
  	return 0;
  }
76b67ed9d   KAMEZAWA Hiroyuki   [PATCH] node hotp...
87
88
89
90
91
92
93
94
  static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
  {
  	return 0;
  }
  static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
  {
  	return 0;
  }
c04fc586c   Gary Hade   mm: show node to ...
95
96
97
98
99
  static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
  							int nid)
  {
  	return 0;
  }
d33601644   Nathan Fontenot   memory hotplug: U...
100
101
  static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
  						  unsigned long phys_index)
c04fc586c   Gary Hade   mm: show node to ...
102
103
104
  {
  	return 0;
  }
9a3052306   Lee Schermerhorn   hugetlb: add per ...
105
106
107
108
109
  
  static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
  						node_registration_func_t unreg)
  {
  }
76b67ed9d   KAMEZAWA Hiroyuki   [PATCH] node hotp...
110
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111

10fbcf4c6   Kay Sievers   convert 'memory' ...
112
  #define to_node(device) container_of(device, struct node, dev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
114
  
  #endif /* _LINUX_NODE_H_ */