diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cpu.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c index 0575197deb4a..a4eb5227a19e 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/oom.h> | 13 | #include <linux/oom.h> |
| 14 | #include <linux/rcupdate.h> | 14 | #include <linux/rcupdate.h> |
| 15 | #include <linux/export.h> | 15 | #include <linux/export.h> |
| 16 | #include <linux/bug.h> | ||
| 16 | #include <linux/kthread.h> | 17 | #include <linux/kthread.h> |
| 17 | #include <linux/stop_machine.h> | 18 | #include <linux/stop_machine.h> |
| 18 | #include <linux/mutex.h> | 19 | #include <linux/mutex.h> |
| @@ -175,6 +176,18 @@ void __ref unregister_cpu_notifier(struct notifier_block *nb) | |||
| 175 | } | 176 | } |
| 176 | EXPORT_SYMBOL(unregister_cpu_notifier); | 177 | EXPORT_SYMBOL(unregister_cpu_notifier); |
| 177 | 178 | ||
| 179 | /** | ||
| 180 | * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU | ||
| 181 | * @cpu: a CPU id | ||
| 182 | * | ||
| 183 | * This function walks all processes, finds a valid mm struct for each one and | ||
| 184 | * then clears a corresponding bit in mm's cpumask. While this all sounds | ||
| 185 | * trivial, there are various non-obvious corner cases, which this function | ||
| 186 | * tries to solve in a safe manner. | ||
| 187 | * | ||
| 188 | * Also note that the function uses a somewhat relaxed locking scheme, so it may | ||
| 189 | * be called only for an already offlined CPU. | ||
| 190 | */ | ||
| 178 | void clear_tasks_mm_cpumask(int cpu) | 191 | void clear_tasks_mm_cpumask(int cpu) |
| 179 | { | 192 | { |
| 180 | struct task_struct *p; | 193 | struct task_struct *p; |
| @@ -186,10 +199,15 @@ void clear_tasks_mm_cpumask(int cpu) | |||
| 186 | * Thus, we may use rcu_read_lock() here, instead of grabbing | 199 | * Thus, we may use rcu_read_lock() here, instead of grabbing |
| 187 | * full-fledged tasklist_lock. | 200 | * full-fledged tasklist_lock. |
| 188 | */ | 201 | */ |
| 202 | WARN_ON(cpu_online(cpu)); | ||
| 189 | rcu_read_lock(); | 203 | rcu_read_lock(); |
| 190 | for_each_process(p) { | 204 | for_each_process(p) { |
| 191 | struct task_struct *t; | 205 | struct task_struct *t; |
| 192 | 206 | ||
| 207 | /* | ||
| 208 | * Main thread might exit, but other threads may still have | ||
| 209 | * a valid mm. Find one. | ||
| 210 | */ | ||
| 193 | t = find_lock_task_mm(p); | 211 | t = find_lock_task_mm(p); |
| 194 | if (!t) | 212 | if (!t) |
| 195 | continue; | 213 | continue; |
