aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cpuset.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/cpuset.h')
-rw-r--r--include/linux/cpuset.h71
1 files changed, 60 insertions, 11 deletions
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index a5740fc4d04b..f20eb8f16025 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -20,9 +20,9 @@ extern int number_of_cpusets; /* How many cpusets are defined in system? */
20 20
21extern int cpuset_init(void); 21extern int cpuset_init(void);
22extern void cpuset_init_smp(void); 22extern void cpuset_init_smp(void);
23extern void cpuset_update_active_cpus(void);
23extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); 24extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
24extern void cpuset_cpus_allowed_locked(struct task_struct *p, 25extern int cpuset_cpus_allowed_fallback(struct task_struct *p);
25 struct cpumask *mask);
26extern nodemask_t cpuset_mems_allowed(struct task_struct *p); 26extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
27#define cpuset_current_mems_allowed (current->mems_allowed) 27#define cpuset_current_mems_allowed (current->mems_allowed)
28void cpuset_init_current_mems_allowed(void); 28void cpuset_init_current_mems_allowed(void);
@@ -69,10 +69,8 @@ struct seq_file;
69extern void cpuset_task_status_allowed(struct seq_file *m, 69extern void cpuset_task_status_allowed(struct seq_file *m,
70 struct task_struct *task); 70 struct task_struct *task);
71 71
72extern void cpuset_lock(void);
73extern void cpuset_unlock(void);
74
75extern int cpuset_mem_spread_node(void); 72extern int cpuset_mem_spread_node(void);
73extern int cpuset_slab_spread_node(void);
76 74
77static inline int cpuset_do_page_mem_spread(void) 75static inline int cpuset_do_page_mem_spread(void)
78{ 76{
@@ -90,9 +88,44 @@ extern void rebuild_sched_domains(void);
90 88
91extern void cpuset_print_task_mems_allowed(struct task_struct *p); 89extern void cpuset_print_task_mems_allowed(struct task_struct *p);
92 90
91/*
92 * reading current mems_allowed and mempolicy in the fastpath must protected
93 * by get_mems_allowed()
94 */
95static inline void get_mems_allowed(void)
96{
97 current->mems_allowed_change_disable++;
98
99 /*
100 * ensure that reading mems_allowed and mempolicy happens after the
101 * update of ->mems_allowed_change_disable.
102 *
103 * the write-side task finds ->mems_allowed_change_disable is not 0,
104 * and knows the read-side task is reading mems_allowed or mempolicy,
105 * so it will clear old bits lazily.
106 */
107 smp_mb();
108}
109
110static inline void put_mems_allowed(void)
111{
112 /*
113 * ensure that reading mems_allowed and mempolicy before reducing
114 * mems_allowed_change_disable.
115 *
116 * the write-side task will know that the read-side task is still
117 * reading mems_allowed or mempolicy, don't clears old bits in the
118 * nodemask.
119 */
120 smp_mb();
121 --ACCESS_ONCE(current->mems_allowed_change_disable);
122}
123
93static inline void set_mems_allowed(nodemask_t nodemask) 124static inline void set_mems_allowed(nodemask_t nodemask)
94{ 125{
126 task_lock(current);
95 current->mems_allowed = nodemask; 127 current->mems_allowed = nodemask;
128 task_unlock(current);
96} 129}
97 130
98#else /* !CONFIG_CPUSETS */ 131#else /* !CONFIG_CPUSETS */
@@ -100,15 +133,21 @@ static inline void set_mems_allowed(nodemask_t nodemask)
100static inline int cpuset_init(void) { return 0; } 133static inline int cpuset_init(void) { return 0; }
101static inline void cpuset_init_smp(void) {} 134static inline void cpuset_init_smp(void) {}
102 135
136static inline void cpuset_update_active_cpus(void)
137{
138 partition_sched_domains(1, NULL, NULL);
139}
140
103static inline void cpuset_cpus_allowed(struct task_struct *p, 141static inline void cpuset_cpus_allowed(struct task_struct *p,
104 struct cpumask *mask) 142 struct cpumask *mask)
105{ 143{
106 cpumask_copy(mask, cpu_possible_mask); 144 cpumask_copy(mask, cpu_possible_mask);
107} 145}
108static inline void cpuset_cpus_allowed_locked(struct task_struct *p, 146
109 struct cpumask *mask) 147static inline int cpuset_cpus_allowed_fallback(struct task_struct *p)
110{ 148{
111 cpumask_copy(mask, cpu_possible_mask); 149 cpumask_copy(&p->cpus_allowed, cpu_possible_mask);
150 return cpumask_any(cpu_active_mask);
112} 151}
113 152
114static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) 153static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
@@ -157,14 +196,16 @@ static inline void cpuset_task_status_allowed(struct seq_file *m,
157{ 196{
158} 197}
159 198
160static inline void cpuset_lock(void) {}
161static inline void cpuset_unlock(void) {}
162
163static inline int cpuset_mem_spread_node(void) 199static inline int cpuset_mem_spread_node(void)
164{ 200{
165 return 0; 201 return 0;
166} 202}
167 203
204static inline int cpuset_slab_spread_node(void)
205{
206 return 0;
207}
208
168static inline int cpuset_do_page_mem_spread(void) 209static inline int cpuset_do_page_mem_spread(void)
169{ 210{
170 return 0; 211 return 0;
@@ -193,6 +234,14 @@ static inline void set_mems_allowed(nodemask_t nodemask)
193{ 234{
194} 235}
195 236
237static inline void get_mems_allowed(void)
238{
239}
240
241static inline void put_mems_allowed(void)
242{
243}
244
196#endif /* !CONFIG_CPUSETS */ 245#endif /* !CONFIG_CPUSETS */
197 246
198#endif /* _LINUX_CPUSET_H */ 247#endif /* _LINUX_CPUSET_H */