sched: Kill the broken and deadlockable cpuset_lock/cpuset_cpus_allowed_locked code
[safe/jmp/linux-2.6] / include / linux / cpuset.h
1 #ifndef _LINUX_CPUSET_H
2 #define _LINUX_CPUSET_H
3 /*
4  *  cpuset interface
5  *
6  *  Copyright (C) 2003 BULL SA
7  *  Copyright (C) 2004-2006 Silicon Graphics, Inc.
8  *
9  */
10
11 #include <linux/sched.h>
12 #include <linux/cpumask.h>
13 #include <linux/nodemask.h>
14 #include <linux/cgroup.h>
15 #include <linux/mm.h>
16
17 #ifdef CONFIG_CPUSETS
18
19 extern int number_of_cpusets;   /* How many cpusets are defined in system? */
20
21 extern int cpuset_init(void);
22 extern void cpuset_init_smp(void);
23 extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
24 extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
25 #define cpuset_current_mems_allowed (current->mems_allowed)
26 void cpuset_init_current_mems_allowed(void);
27 int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
28
29 extern int __cpuset_node_allowed_softwall(int node, gfp_t gfp_mask);
30 extern int __cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask);
31
32 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
33 {
34         return number_of_cpusets <= 1 ||
35                 __cpuset_node_allowed_softwall(node, gfp_mask);
36 }
37
38 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
39 {
40         return number_of_cpusets <= 1 ||
41                 __cpuset_node_allowed_hardwall(node, gfp_mask);
42 }
43
44 static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
45 {
46         return cpuset_node_allowed_softwall(zone_to_nid(z), gfp_mask);
47 }
48
49 static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
50 {
51         return cpuset_node_allowed_hardwall(zone_to_nid(z), gfp_mask);
52 }
53
54 extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
55                                           const struct task_struct *tsk2);
56
57 #define cpuset_memory_pressure_bump()                           \
58         do {                                                    \
59                 if (cpuset_memory_pressure_enabled)             \
60                         __cpuset_memory_pressure_bump();        \
61         } while (0)
62 extern int cpuset_memory_pressure_enabled;
63 extern void __cpuset_memory_pressure_bump(void);
64
65 extern const struct file_operations proc_cpuset_operations;
66 struct seq_file;
67 extern void cpuset_task_status_allowed(struct seq_file *m,
68                                         struct task_struct *task);
69
70 extern int cpuset_mem_spread_node(void);
71
72 static inline int cpuset_do_page_mem_spread(void)
73 {
74         return current->flags & PF_SPREAD_PAGE;
75 }
76
77 static inline int cpuset_do_slab_mem_spread(void)
78 {
79         return current->flags & PF_SPREAD_SLAB;
80 }
81
82 extern int current_cpuset_is_being_rebound(void);
83
84 extern void rebuild_sched_domains(void);
85
86 extern void cpuset_print_task_mems_allowed(struct task_struct *p);
87
88 static inline void set_mems_allowed(nodemask_t nodemask)
89 {
90         current->mems_allowed = nodemask;
91 }
92
93 #else /* !CONFIG_CPUSETS */
94
95 static inline int cpuset_init(void) { return 0; }
96 static inline void cpuset_init_smp(void) {}
97
98 static inline void cpuset_cpus_allowed(struct task_struct *p,
99                                        struct cpumask *mask)
100 {
101         cpumask_copy(mask, cpu_possible_mask);
102 }
103
104 static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
105 {
106         return node_possible_map;
107 }
108
109 #define cpuset_current_mems_allowed (node_states[N_HIGH_MEMORY])
110 static inline void cpuset_init_current_mems_allowed(void) {}
111
112 static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
113 {
114         return 1;
115 }
116
117 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
118 {
119         return 1;
120 }
121
122 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
123 {
124         return 1;
125 }
126
127 static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
128 {
129         return 1;
130 }
131
132 static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
133 {
134         return 1;
135 }
136
137 static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
138                                                  const struct task_struct *tsk2)
139 {
140         return 1;
141 }
142
143 static inline void cpuset_memory_pressure_bump(void) {}
144
145 static inline void cpuset_task_status_allowed(struct seq_file *m,
146                                                 struct task_struct *task)
147 {
148 }
149
150 static inline int cpuset_mem_spread_node(void)
151 {
152         return 0;
153 }
154
155 static inline int cpuset_do_page_mem_spread(void)
156 {
157         return 0;
158 }
159
160 static inline int cpuset_do_slab_mem_spread(void)
161 {
162         return 0;
163 }
164
165 static inline int current_cpuset_is_being_rebound(void)
166 {
167         return 0;
168 }
169
170 static inline void rebuild_sched_domains(void)
171 {
172         partition_sched_domains(1, NULL, NULL);
173 }
174
175 static inline void cpuset_print_task_mems_allowed(struct task_struct *p)
176 {
177 }
178
179 static inline void set_mems_allowed(nodemask_t nodemask)
180 {
181 }
182
183 #endif /* !CONFIG_CPUSETS */
184
185 #endif /* _LINUX_CPUSET_H */