diff options
Diffstat (limited to 'kernel/cpuset.c')
| -rw-r--r-- | kernel/cpuset.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 2a75e44e1a41..fe2f71f92ae0 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
| @@ -1554,7 +1554,7 @@ struct ctr_struct { | |||
| 1554 | * when reading out p->cpuset, as we don't really care if it changes | 1554 | * when reading out p->cpuset, as we don't really care if it changes |
| 1555 | * on the next cycle, and we are not going to try to dereference it. | 1555 | * on the next cycle, and we are not going to try to dereference it. |
| 1556 | */ | 1556 | */ |
| 1557 | static inline int pid_array_load(pid_t *pidarray, int npids, struct cpuset *cs) | 1557 | static int pid_array_load(pid_t *pidarray, int npids, struct cpuset *cs) |
| 1558 | { | 1558 | { |
| 1559 | int n = 0; | 1559 | int n = 0; |
| 1560 | struct task_struct *g, *p; | 1560 | struct task_struct *g, *p; |
| @@ -2150,6 +2150,33 @@ int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) | |||
| 2150 | } | 2150 | } |
| 2151 | 2151 | ||
| 2152 | /** | 2152 | /** |
| 2153 | * cpuset_lock - lock out any changes to cpuset structures | ||
| 2154 | * | ||
| 2155 | * The out of memory (oom) code needs to lock down cpusets | ||
| 2156 | * from being changed while it scans the tasklist looking for a | ||
| 2157 | * task in an overlapping cpuset. Expose callback_sem via this | ||
| 2158 | * cpuset_lock() routine, so the oom code can lock it, before | ||
| 2159 | * locking the task list. The tasklist_lock is a spinlock, so | ||
| 2160 | * must be taken inside callback_sem. | ||
| 2161 | */ | ||
| 2162 | |||
| 2163 | void cpuset_lock(void) | ||
| 2164 | { | ||
| 2165 | down(&callback_sem); | ||
| 2166 | } | ||
| 2167 | |||
| 2168 | /** | ||
| 2169 | * cpuset_unlock - release lock on cpuset changes | ||
| 2170 | * | ||
| 2171 | * Undo the lock taken in a previous cpuset_lock() call. | ||
| 2172 | */ | ||
| 2173 | |||
| 2174 | void cpuset_unlock(void) | ||
| 2175 | { | ||
| 2176 | up(&callback_sem); | ||
| 2177 | } | ||
| 2178 | |||
| 2179 | /** | ||
| 2153 | * cpuset_excl_nodes_overlap - Do we overlap @p's mem_exclusive ancestors? | 2180 | * cpuset_excl_nodes_overlap - Do we overlap @p's mem_exclusive ancestors? |
| 2154 | * @p: pointer to task_struct of some other task. | 2181 | * @p: pointer to task_struct of some other task. |
| 2155 | * | 2182 | * |
| @@ -2158,7 +2185,7 @@ int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) | |||
| 2158 | * determine if task @p's memory usage might impact the memory | 2185 | * determine if task @p's memory usage might impact the memory |
| 2159 | * available to the current task. | 2186 | * available to the current task. |
| 2160 | * | 2187 | * |
| 2161 | * Acquires callback_sem - not suitable for calling from a fast path. | 2188 | * Call while holding callback_sem. |
| 2162 | **/ | 2189 | **/ |
| 2163 | 2190 | ||
| 2164 | int cpuset_excl_nodes_overlap(const struct task_struct *p) | 2191 | int cpuset_excl_nodes_overlap(const struct task_struct *p) |
| @@ -2166,8 +2193,6 @@ int cpuset_excl_nodes_overlap(const struct task_struct *p) | |||
| 2166 | const struct cpuset *cs1, *cs2; /* my and p's cpuset ancestors */ | 2193 | const struct cpuset *cs1, *cs2; /* my and p's cpuset ancestors */ |
| 2167 | int overlap = 0; /* do cpusets overlap? */ | 2194 | int overlap = 0; /* do cpusets overlap? */ |
| 2168 | 2195 | ||
| 2169 | down(&callback_sem); | ||
| 2170 | |||
| 2171 | task_lock(current); | 2196 | task_lock(current); |
| 2172 | if (current->flags & PF_EXITING) { | 2197 | if (current->flags & PF_EXITING) { |
| 2173 | task_unlock(current); | 2198 | task_unlock(current); |
| @@ -2186,8 +2211,6 @@ int cpuset_excl_nodes_overlap(const struct task_struct *p) | |||
| 2186 | 2211 | ||
| 2187 | overlap = nodes_intersects(cs1->mems_allowed, cs2->mems_allowed); | 2212 | overlap = nodes_intersects(cs1->mems_allowed, cs2->mems_allowed); |
| 2188 | done: | 2213 | done: |
| 2189 | up(&callback_sem); | ||
| 2190 | |||
| 2191 | return overlap; | 2214 | return overlap; |
| 2192 | } | 2215 | } |
| 2193 | 2216 | ||
