1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _LINUX_NODE_H_
16#define _LINUX_NODE_H_
17
18#include <linux/device.h>
19#include <linux/cpumask.h>
20#include <linux/workqueue.h>
21
22struct node {
23 struct device dev;
24
25#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
26 struct work_struct node_work;
27#endif
28};
29
30struct memory_block;
31extern struct node *node_devices[];
32typedef void (*node_registration_func_t)(struct node *);
33
34#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
35extern int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages);
36#else
37static inline int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages)
38{
39 return 0;
40}
41#endif
42
43extern void unregister_node(struct node *node);
44#ifdef CONFIG_NUMA
45
46extern int __register_one_node(int nid);
47
48
49static inline int register_one_node(int nid)
50{
51 int error = 0;
52
53 if (node_online(nid)) {
54 struct pglist_data *pgdat = NODE_DATA(nid);
55
56 error = __register_one_node(nid);
57 if (error)
58 return error;
59
60 error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages);
61 }
62
63 return error;
64}
65
66extern void unregister_one_node(int nid);
67extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
68extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
69extern int register_mem_sect_under_node(struct memory_block *mem_blk,
70 int nid);
71extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
72 unsigned long phys_index);
73
74#ifdef CONFIG_HUGETLBFS
75extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
76 node_registration_func_t unregister);
77#endif
78#else
79static inline int __register_one_node(int nid)
80{
81 return 0;
82}
83static inline int register_one_node(int nid)
84{
85 return 0;
86}
87static inline int unregister_one_node(int nid)
88{
89 return 0;
90}
91static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
92{
93 return 0;
94}
95static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
96{
97 return 0;
98}
99static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
100 int nid)
101{
102 return 0;
103}
104static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
105 unsigned long phys_index)
106{
107 return 0;
108}
109
110static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
111 node_registration_func_t unreg)
112{
113}
114#endif
115
116#define to_node(device) container_of(device, struct node, dev)
117
118#endif
119