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(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);
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);
32 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
34 return number_of_cpusets <= 1 ||
35 __cpuset_node_allowed_softwall(node, gfp_mask);
38 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
40 return number_of_cpusets <= 1 ||
41 __cpuset_node_allowed_hardwall(node, gfp_mask);
44 static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
46 return cpuset_node_allowed_softwall(zone_to_nid(z), gfp_mask);
49 static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
51 return cpuset_node_allowed_hardwall(zone_to_nid(z), gfp_mask);
54 extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
55 const struct task_struct *tsk2);
57 #define cpuset_memory_pressure_bump() \
59 if (cpuset_memory_pressure_enabled) \
60 __cpuset_memory_pressure_bump(); \
62 extern int cpuset_memory_pressure_enabled;
63 extern void __cpuset_memory_pressure_bump(void);
65 extern const struct file_operations proc_cpuset_operations;
67 extern void cpuset_task_status_allowed(struct seq_file *m,
68 struct task_struct *task);
70 extern int cpuset_mem_spread_node(void);
72 static inline int cpuset_do_page_mem_spread(void)
74 return current->flags & PF_SPREAD_PAGE;
77 static inline int cpuset_do_slab_mem_spread(void)
79 return current->flags & PF_SPREAD_SLAB;
82 extern int current_cpuset_is_being_rebound(void);
84 extern void rebuild_sched_domains(void);
86 extern void cpuset_print_task_mems_allowed(struct task_struct *p);
88 static inline void set_mems_allowed(nodemask_t nodemask)
90 current->mems_allowed = nodemask;
93 #else /* !CONFIG_CPUSETS */
95 static inline int cpuset_init(void) { return 0; }
96 static inline void cpuset_init_smp(void) {}
98 static inline void cpuset_cpus_allowed(struct task_struct *p,
101 cpumask_copy(mask, cpu_possible_mask);
104 static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
106 return node_possible_map;
109 #define cpuset_current_mems_allowed (node_states[N_HIGH_MEMORY])
110 static inline void cpuset_init_current_mems_allowed(void) {}
112 static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
117 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
122 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask)
127 static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask)
132 static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask)
137 static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
138 const struct task_struct *tsk2)
143 static inline void cpuset_memory_pressure_bump(void) {}
145 static inline void cpuset_task_status_allowed(struct seq_file *m,
146 struct task_struct *task)
150 static inline int cpuset_mem_spread_node(void)
155 static inline int cpuset_do_page_mem_spread(void)
160 static inline int cpuset_do_slab_mem_spread(void)
165 static inline int current_cpuset_is_being_rebound(void)
170 static inline void rebuild_sched_domains(void)
172 partition_sched_domains(1, NULL, NULL);
175 static inline void cpuset_print_task_mems_allowed(struct task_struct *p)
179 static inline void set_mems_allowed(nodemask_t nodemask)
183 #endif /* !CONFIG_CPUSETS */
185 #endif /* _LINUX_CPUSET_H */