diff options
Diffstat (limited to 'include/linux/cpuset.h')
| -rw-r--r-- | include/linux/cpuset.h | 71 |
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 | ||
| 21 | extern int cpuset_init(void); | 21 | extern int cpuset_init(void); |
| 22 | extern void cpuset_init_smp(void); | 22 | extern void cpuset_init_smp(void); |
| 23 | extern void cpuset_update_active_cpus(void); | ||
| 23 | extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); | 24 | extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); |
| 24 | extern void cpuset_cpus_allowed_locked(struct task_struct *p, | 25 | extern int cpuset_cpus_allowed_fallback(struct task_struct *p); |
| 25 | struct cpumask *mask); | ||
| 26 | extern nodemask_t cpuset_mems_allowed(struct task_struct *p); | 26 | extern 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) |
| 28 | void cpuset_init_current_mems_allowed(void); | 28 | void cpuset_init_current_mems_allowed(void); |
| @@ -69,10 +69,8 @@ struct seq_file; | |||
| 69 | extern void cpuset_task_status_allowed(struct seq_file *m, | 69 | extern void cpuset_task_status_allowed(struct seq_file *m, |
| 70 | struct task_struct *task); | 70 | struct task_struct *task); |
| 71 | 71 | ||
| 72 | extern void cpuset_lock(void); | ||
| 73 | extern void cpuset_unlock(void); | ||
| 74 | |||
| 75 | extern int cpuset_mem_spread_node(void); | 72 | extern int cpuset_mem_spread_node(void); |
| 73 | extern int cpuset_slab_spread_node(void); | ||
| 76 | 74 | ||
| 77 | static inline int cpuset_do_page_mem_spread(void) | 75 | static inline int cpuset_do_page_mem_spread(void) |
| 78 | { | 76 | { |
| @@ -90,9 +88,44 @@ extern void rebuild_sched_domains(void); | |||
| 90 | 88 | ||
| 91 | extern void cpuset_print_task_mems_allowed(struct task_struct *p); | 89 | extern 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 | */ | ||
| 95 | static 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 | |||
| 110 | static 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 | |||
| 93 | static inline void set_mems_allowed(nodemask_t nodemask) | 124 | static 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) | |||
| 100 | static inline int cpuset_init(void) { return 0; } | 133 | static inline int cpuset_init(void) { return 0; } |
| 101 | static inline void cpuset_init_smp(void) {} | 134 | static inline void cpuset_init_smp(void) {} |
| 102 | 135 | ||
| 136 | static inline void cpuset_update_active_cpus(void) | ||
| 137 | { | ||
| 138 | partition_sched_domains(1, NULL, NULL); | ||
| 139 | } | ||
| 140 | |||
| 103 | static inline void cpuset_cpus_allowed(struct task_struct *p, | 141 | static 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 | } |
| 108 | static inline void cpuset_cpus_allowed_locked(struct task_struct *p, | 146 | |
| 109 | struct cpumask *mask) | 147 | static 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 | ||
| 114 | static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) | 153 | static 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 | ||
| 160 | static inline void cpuset_lock(void) {} | ||
| 161 | static inline void cpuset_unlock(void) {} | ||
| 162 | |||
| 163 | static inline int cpuset_mem_spread_node(void) | 199 | static inline int cpuset_mem_spread_node(void) |
| 164 | { | 200 | { |
| 165 | return 0; | 201 | return 0; |
| 166 | } | 202 | } |
| 167 | 203 | ||
| 204 | static inline int cpuset_slab_spread_node(void) | ||
| 205 | { | ||
| 206 | return 0; | ||
| 207 | } | ||
| 208 | |||
| 168 | static inline int cpuset_do_page_mem_spread(void) | 209 | static 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 | ||
| 237 | static inline void get_mems_allowed(void) | ||
| 238 | { | ||
| 239 | } | ||
| 240 | |||
| 241 | static 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 */ |
