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_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); 32 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); 35 36 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask) 37 { 38 return number_of_cpusets <= 1 || 39 __cpuset_node_allowed_softwall(node, gfp_mask); 40 } 41 42 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask) 43 { 44 return number_of_cpusets <= 1 || 45 __cpuset_node_allowed_hardwall(node, gfp_mask); 46 } 47 48 static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask) 49 { 50 return cpuset_node_allowed_softwall(zone_to_nid(z), gfp_mask); 51 } 52 53 static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask) 54 { 55 return cpuset_node_allowed_hardwall(zone_to_nid(z), gfp_mask); 56 } 57 58 extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, 59 const struct task_struct *tsk2); 60 61 #define cpuset_memory_pressure_bump() \ 62 do { \ 63 if (cpuset_memory_pressure_enabled) \ 64 __cpuset_memory_pressure_bump(); \ 65 } while (0) 66 extern int cpuset_memory_pressure_enabled; 67 extern void __cpuset_memory_pressure_bump(void); 68 69 extern const struct file_operations proc_cpuset_operations; 70 struct seq_file; 71 extern void cpuset_task_status_allowed(struct seq_file *m, 72 struct task_struct *task); 73 74 extern void cpuset_lock(void); 75 extern void cpuset_unlock(void); 76 77 extern int cpuset_mem_spread_node(void); 78 79 static inline int cpuset_do_page_mem_spread(void) 80 { 81 return current->flags & PF_SPREAD_PAGE; 82 } 83 84 static inline int cpuset_do_slab_mem_spread(void) 85 { 86 return current->flags & PF_SPREAD_SLAB; 87 } 88 89 extern int current_cpuset_is_being_rebound(void); 90 91 extern void rebuild_sched_domains(void); 92 93 extern void cpuset_print_task_mems_allowed(struct task_struct *p); 94 95 #else /* !CONFIG_CPUSETS */ 96 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) {} 100 101 static inline void cpuset_cpus_allowed(struct task_struct *p, 102 struct cpumask *mask) 103 { 104 cpumask_copy(mask, cpu_possible_mask); 105 } 106 static inline void cpuset_cpus_allowed_locked(struct task_struct *p, 107 struct cpumask *mask) 108 { 109 cpumask_copy(mask, cpu_possible_mask); 110 } 111 112 static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) 113 { 114 return node_possible_map; 115 } 116 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) {} 120 121 static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask) 122 { 123 return 1; 124 } 125 126 static inline int cpuset_node_allowed_softwall(int node, gfp_t gfp_mask) 127 { 128 return 1; 129 } 130 131 static inline int cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask) 132 { 133 return 1; 134 } 135 136 static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask) 137 { 138 return 1; 139 } 140 141 static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask) 142 { 143 return 1; 144 } 145 146 static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, 147 const struct task_struct *tsk2) 148 { 149 return 1; 150 } 151 152 static inline void cpuset_memory_pressure_bump(void) {} 153 154 static inline void cpuset_task_status_allowed(struct seq_file *m, 155 struct task_struct *task) 156 { 157 } 158 159 static inline void cpuset_lock(void) {} 160 static inline void cpuset_unlock(void) {} 161 162 static inline int cpuset_mem_spread_node(void) 163 { 164 return 0; 165 } 166 167 static inline int cpuset_do_page_mem_spread(void) 168 { 169 return 0; 170 } 171 172 static inline int cpuset_do_slab_mem_spread(void) 173 { 174 return 0; 175 } 176 177 static inline int current_cpuset_is_being_rebound(void) 178 { 179 return 0; 180 } 181 182 static inline void rebuild_sched_domains(void) 183 { 184 partition_sched_domains(1, NULL, NULL); 185 } 186 187 static inline void cpuset_print_task_mems_allowed(struct task_struct *p) 188 { 189 } 190 191 #endif /* !CONFIG_CPUSETS */ 192 193 #endif /* _LINUX_CPUSET_H */ 194