diff options
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r-- | kernel/cpu.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c index 10ba5f1004a5..f17e9854c246 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -216,7 +216,6 @@ static int __ref take_cpu_down(void *_param) | |||
216 | static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) | 216 | static 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 | ||
282 | out_thread: | ||
283 | err = kthread_stop(p); | ||
284 | out_allowed: | 278 | out_allowed: |
285 | set_cpus_allowed_ptr(current, &old_allowed); | 279 | set_cpus_allowed_ptr(current, &old_allowed); |
286 | out_release: | 280 | out_release: |
@@ -355,6 +349,8 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen) | |||
355 | goto out_notify; | 349 | goto out_notify; |
356 | BUG_ON(!cpu_online(cpu)); | 350 | BUG_ON(!cpu_online(cpu)); |
357 | 351 | ||
352 | cpu_set(cpu, cpu_active_map); | ||
353 | |||
358 | /* Now call notifier in preparation. */ | 354 | /* Now call notifier in preparation. */ |
359 | raw_notifier_call_chain(&cpu_chain, CPU_ONLINE | mod, hcpu); | 355 | raw_notifier_call_chain(&cpu_chain, CPU_ONLINE | mod, hcpu); |
360 | 356 | ||
@@ -373,7 +369,7 @@ int __cpuinit cpu_up(unsigned int cpu) | |||
373 | if (!cpu_isset(cpu, cpu_possible_map)) { | 369 | if (!cpu_isset(cpu, cpu_possible_map)) { |
374 | printk(KERN_ERR "can't online cpu %d because it is not " | 370 | printk(KERN_ERR "can't online cpu %d because it is not " |
375 | "configured as may-hotadd at boot time\n", cpu); | 371 | "configured as may-hotadd at boot time\n", cpu); |
376 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) || defined(CONFIG_S390) | 372 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) |
377 | printk(KERN_ERR "please check additional_cpus= boot " | 373 | printk(KERN_ERR "please check additional_cpus= boot " |
378 | "parameter\n"); | 374 | "parameter\n"); |
379 | #endif | 375 | #endif |
@@ -389,9 +385,6 @@ int __cpuinit cpu_up(unsigned int cpu) | |||
389 | 385 | ||
390 | err = _cpu_up(cpu, 0); | 386 | err = _cpu_up(cpu, 0); |
391 | 387 | ||
392 | if (cpu_online(cpu)) | ||
393 | cpu_set(cpu, cpu_active_map); | ||
394 | |||
395 | out: | 388 | out: |
396 | cpu_maps_update_done(); | 389 | cpu_maps_update_done(); |
397 | return err; | 390 | return err; |
@@ -461,3 +454,28 @@ out: | |||
461 | #endif /* CONFIG_PM_SLEEP_SMP */ | 454 | #endif /* CONFIG_PM_SLEEP_SMP */ |
462 | 455 | ||
463 | #endif /* CONFIG_SMP */ | 456 | #endif /* CONFIG_SMP */ |
457 | |||
458 | /* | ||
459 | * cpu_bit_bitmap[] is a special, "compressed" data structure that | ||
460 | * represents all NR_CPUS bits binary values of 1<<nr. | ||
461 | * | ||
462 | * It is used by cpumask_of_cpu() to get a constant address to a CPU | ||
463 | * mask value that has a single bit set only. | ||
464 | */ | ||
465 | |||
466 | /* cpu_bit_bitmap[0] is empty - so we can back into it */ | ||
467 | #define MASK_DECLARE_1(x) [x+1][0] = 1UL << (x) | ||
468 | #define MASK_DECLARE_2(x) MASK_DECLARE_1(x), MASK_DECLARE_1(x+1) | ||
469 | #define MASK_DECLARE_4(x) MASK_DECLARE_2(x), MASK_DECLARE_2(x+2) | ||
470 | #define MASK_DECLARE_8(x) MASK_DECLARE_4(x), MASK_DECLARE_4(x+4) | ||
471 | |||
472 | const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = { | ||
473 | |||
474 | MASK_DECLARE_8(0), MASK_DECLARE_8(8), | ||
475 | MASK_DECLARE_8(16), MASK_DECLARE_8(24), | ||
476 | #if BITS_PER_LONG > 32 | ||
477 | MASK_DECLARE_8(32), MASK_DECLARE_8(40), | ||
478 | MASK_DECLARE_8(48), MASK_DECLARE_8(56), | ||
479 | #endif | ||
480 | }; | ||
481 | EXPORT_SYMBOL_GPL(cpu_bit_bitmap); | ||