1 #ifndef _LINUX_CPUSET_H
2 #define _LINUX_CPUSET_H
6 * Copyright (C) 2003 BULL SA
7 * Copyright (C) 2004-2006 Silicon Graphics, Inc.
11 #include <linux/sched.h>
12 #include <linux/cpumask.h>
13 #include <linux/nodemask.h>
14 #include <linux/cgroup.h>
19 extern int number_of_cpusets; /* How many cpusets are defined in system? */
21 extern int cpuset_init_early(void);
22 extern int cpuset_init(void);
23 extern void cpuset_init_smp(void);
24 extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
25 extern void cpuset_cpus_allowed_locked(struct task_struct *p,
26 struct cpumask *mask);
27 extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
28 #define cpuset_current_mems_allowed (current->mems_allowed)
29 void cpuset_init_current_mems_allowed(void);
30 void cpuset_update_task_memory_state(void);
31 int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
33 extern int __cpuset_node_allowed_softwall(int node, gfp_t gfp_mask);
34 extern int __cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask);
36 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
38 return number_of_cpusets <= 1 ||
39 __cpuset_node_allowed_softwall(node, gfp_mask);
42 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
44 return number_of_cpusets <= 1 ||
45 __cpuset_node_allowed_hardwall(node, gfp_mask);
48 static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
50 return cpuset_node_allowed_softwall(zone_to_nid(z), gfp_mask);
53 static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
55 return cpuset_node_allowed_hardwall(zone_to_nid(z), gfp_mask);
58 extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
59 const struct task_struct *tsk2);
61 #define cpuset_memory_pressure_bump() \
63 if (cpuset_memory_pressure_enabled) \
64 __cpuset_memory_pressure_bump(); \
66 extern int cpuset_memory_pressure_enabled;
67 extern void __cpuset_memory_pressure_bump(void);
69 extern const struct file_operations proc_cpuset_operations;
71 extern void cpuset_task_status_allowed(struct seq_file *m,
72 struct task_struct *task);
74 extern void cpuset_lock(void);
75 extern void cpuset_unlock(void);
77 extern int cpuset_mem_spread_node(void);
79 static inline int cpuset_do_page_mem_spread(void)
81 return current->flags & PF_SPREAD_PAGE;
84 static inline int cpuset_do_slab_mem_spread(void)
86 return current->flags & PF_SPREAD_SLAB;
89 extern int current_cpuset_is_being_rebound(void);
91 extern void rebuild_sched_domains(void);
93 extern void cpuset_print_task_mems_allowed(struct task_struct *p);
95 #else /* !CONFIG_CPUSETS */
97 static inline int cpuset_init_early(void) { return 0; }
98 static inline int cpuset_init(void) { return 0; }
99 static inline void cpuset_init_smp(void) {}
101 static inline void cpuset_cpus_allowed(struct task_struct *p,
102 struct cpumask *mask)
104 cpumask_copy(mask, cpu_possible_mask);
106 static inline void cpuset_cpus_allowed_locked(struct task_struct *p,
107 struct cpumask *mask)
109 cpumask_copy(mask, cpu_possible_mask);
112 static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
114 return node_possible_map;
117 #define cpuset_current_mems_allowed (node_states[N_HIGH_MEMORY])
118 static inline void cpuset_init_current_mems_allowed(void) {}
119 static inline void cpuset_update_task_memory_state(void) {}
121 static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
126 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
131 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
136 static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
141 static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
146 static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
147 const struct task_struct *tsk2)
152 static inline void cpuset_memory_pressure_bump(void) {}
154 static inline void cpuset_task_status_allowed(struct seq_file *m,
155 struct task_struct *task)
159 static inline void cpuset_lock(void) {}
160 static inline void cpuset_unlock(void) {}
162 static inline int cpuset_mem_spread_node(void)
167 static inline int cpuset_do_page_mem_spread(void)
172 static inline int cpuset_do_slab_mem_spread(void)
177 static inline int current_cpuset_is_being_rebound(void)
182 static inline void rebuild_sched_domains(void)
184 partition_sched_domains(1, NULL, NULL);
187 static inline void cpuset_print_task_mems_allowed(struct task_struct *p)
191 #endif /* !CONFIG_CPUSETS */
193 #endif /* _LINUX_CPUSET_H */