aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r--kernel/cpu.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 10ba5f1004a5..e202a68d1cc1 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -216,7 +216,6 @@ static int __ref take_cpu_down(void *_param)
216static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) 216static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
217{ 217{
218 int err, nr_calls = 0; 218 int err, nr_calls = 0;
219 struct task_struct *p;
220 cpumask_t old_allowed, tmp; 219 cpumask_t old_allowed, tmp;
221 void *hcpu = (void *)(long)cpu; 220 void *hcpu = (void *)(long)cpu;
222 unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; 221 unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0;
@@ -249,21 +248,18 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
249 cpus_setall(tmp); 248 cpus_setall(tmp);
250 cpu_clear(cpu, tmp); 249 cpu_clear(cpu, tmp);
251 set_cpus_allowed_ptr(current, &tmp); 250 set_cpus_allowed_ptr(current, &tmp);
251 tmp = cpumask_of_cpu(cpu);
252 252
253 p = __stop_machine_run(take_cpu_down, &tcd_param, cpu); 253 err = __stop_machine(take_cpu_down, &tcd_param, &tmp);
254 254 if (err) {
255 if (IS_ERR(p) || cpu_online(cpu)) {
256 /* CPU didn't die: tell everyone. Can't complain. */ 255 /* CPU didn't die: tell everyone. Can't complain. */
257 if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, 256 if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod,
258 hcpu) == NOTIFY_BAD) 257 hcpu) == NOTIFY_BAD)
259 BUG(); 258 BUG();
260 259
261 if (IS_ERR(p)) { 260 goto out_allowed;
262 err = PTR_ERR(p);
263 goto out_allowed;
264 }
265 goto out_thread;
266 } 261 }
262 BUG_ON(cpu_online(cpu));
267 263
268 /* Wait for it to sleep (leaving idle task). */ 264 /* Wait for it to sleep (leaving idle task). */
269 while (!idle_cpu(cpu)) 265 while (!idle_cpu(cpu))
@@ -279,8 +275,6 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
279 275
280 check_for_tasks(cpu); 276 check_for_tasks(cpu);
281 277
282out_thread:
283 err = kthread_stop(p);
284out_allowed: 278out_allowed:
285 set_cpus_allowed_ptr(current, &old_allowed); 279 set_cpus_allowed_ptr(current, &old_allowed);
286out_release: 280out_release:
@@ -461,3 +455,28 @@ out:
461#endif /* CONFIG_PM_SLEEP_SMP */ 455#endif /* CONFIG_PM_SLEEP_SMP */
462 456
463#endif /* CONFIG_SMP */ 457#endif /* CONFIG_SMP */
458
459/*
460 * cpu_bit_bitmap[] is a special, "compressed" data structure that
461 * represents all NR_CPUS bits binary values of 1<<nr.
462 *
463 * It is used by cpumask_of_cpu() to get a constant address to a CPU
464 * mask value that has a single bit set only.
465 */
466
467/* cpu_bit_bitmap[0] is empty - so we can back into it */
468#define MASK_DECLARE_1(x) [x+1][0] = 1UL << (x)
469#define MASK_DECLARE_2(x) MASK_DECLARE_1(x), MASK_DECLARE_1(x+1)
470#define MASK_DECLARE_4(x) MASK_DECLARE_2(x), MASK_DECLARE_2(x+2)
471#define MASK_DECLARE_8(x) MASK_DECLARE_4(x), MASK_DECLARE_4(x+4)
472
473const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = {
474
475 MASK_DECLARE_8(0), MASK_DECLARE_8(8),
476 MASK_DECLARE_8(16), MASK_DECLARE_8(24),
477#if BITS_PER_LONG > 32
478 MASK_DECLARE_8(32), MASK_DECLARE_8(40),
479 MASK_DECLARE_8(48), MASK_DECLARE_8(56),
480#endif
481};
482EXPORT_SYMBOL_GPL(cpu_bit_bitmap);