diff options
Diffstat (limited to 'kernel/cpu.c')
| -rw-r--r-- | kernel/cpu.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c index 6ba0f1ecb212..1c8ddd6ee940 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
| @@ -209,9 +209,12 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) | |||
| 209 | return -ENOMEM; | 209 | return -ENOMEM; |
| 210 | 210 | ||
| 211 | cpu_hotplug_begin(); | 211 | cpu_hotplug_begin(); |
| 212 | set_cpu_active(cpu, false); | ||
| 212 | err = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod, | 213 | err = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod, |
| 213 | hcpu, -1, &nr_calls); | 214 | hcpu, -1, &nr_calls); |
| 214 | if (err == NOTIFY_BAD) { | 215 | if (err == NOTIFY_BAD) { |
| 216 | set_cpu_active(cpu, true); | ||
| 217 | |||
| 215 | nr_calls--; | 218 | nr_calls--; |
| 216 | __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, | 219 | __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, |
| 217 | hcpu, nr_calls, NULL); | 220 | hcpu, nr_calls, NULL); |
| @@ -223,11 +226,11 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) | |||
| 223 | 226 | ||
| 224 | /* Ensure that we are not runnable on dying cpu */ | 227 | /* Ensure that we are not runnable on dying cpu */ |
| 225 | cpumask_copy(old_allowed, ¤t->cpus_allowed); | 228 | cpumask_copy(old_allowed, ¤t->cpus_allowed); |
| 226 | set_cpus_allowed_ptr(current, | 229 | set_cpus_allowed_ptr(current, cpu_active_mask); |
| 227 | cpumask_of(cpumask_any_but(cpu_online_mask, cpu))); | ||
| 228 | 230 | ||
| 229 | err = __stop_machine(take_cpu_down, &tcd_param, cpumask_of(cpu)); | 231 | err = __stop_machine(take_cpu_down, &tcd_param, cpumask_of(cpu)); |
| 230 | if (err) { | 232 | if (err) { |
| 233 | set_cpu_active(cpu, true); | ||
| 231 | /* CPU didn't die: tell everyone. Can't complain. */ | 234 | /* CPU didn't die: tell everyone. Can't complain. */ |
| 232 | if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, | 235 | if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, |
| 233 | hcpu) == NOTIFY_BAD) | 236 | hcpu) == NOTIFY_BAD) |
| @@ -278,23 +281,8 @@ int __ref cpu_down(unsigned int cpu) | |||
| 278 | goto out; | 281 | goto out; |
| 279 | } | 282 | } |
| 280 | 283 | ||
| 281 | set_cpu_active(cpu, false); | ||
| 282 | |||
| 283 | /* | ||
| 284 | * Make sure the all cpus did the reschedule and are not | ||
| 285 | * using stale version of the cpu_active_mask. | ||
| 286 | * This is not strictly necessary becuase stop_machine() | ||
| 287 | * that we run down the line already provides the required | ||
| 288 | * synchronization. But it's really a side effect and we do not | ||
| 289 | * want to depend on the innards of the stop_machine here. | ||
| 290 | */ | ||
| 291 | synchronize_sched(); | ||
| 292 | |||
| 293 | err = _cpu_down(cpu, 0); | 284 | err = _cpu_down(cpu, 0); |
| 294 | 285 | ||
| 295 | if (cpu_online(cpu)) | ||
| 296 | set_cpu_active(cpu, true); | ||
| 297 | |||
| 298 | out: | 286 | out: |
| 299 | cpu_maps_update_done(); | 287 | cpu_maps_update_done(); |
| 300 | stop_machine_destroy(); | 288 | stop_machine_destroy(); |
| @@ -383,19 +371,20 @@ int disable_nonboot_cpus(void) | |||
| 383 | return error; | 371 | return error; |
| 384 | cpu_maps_update_begin(); | 372 | cpu_maps_update_begin(); |
| 385 | first_cpu = cpumask_first(cpu_online_mask); | 373 | first_cpu = cpumask_first(cpu_online_mask); |
| 386 | /* We take down all of the non-boot CPUs in one shot to avoid races | 374 | /* |
| 375 | * We take down all of the non-boot CPUs in one shot to avoid races | ||
| 387 | * with the userspace trying to use the CPU hotplug at the same time | 376 | * with the userspace trying to use the CPU hotplug at the same time |
| 388 | */ | 377 | */ |
| 389 | cpumask_clear(frozen_cpus); | 378 | cpumask_clear(frozen_cpus); |
| 379 | |||
| 390 | printk("Disabling non-boot CPUs ...\n"); | 380 | printk("Disabling non-boot CPUs ...\n"); |
| 391 | for_each_online_cpu(cpu) { | 381 | for_each_online_cpu(cpu) { |
| 392 | if (cpu == first_cpu) | 382 | if (cpu == first_cpu) |
| 393 | continue; | 383 | continue; |
| 394 | error = _cpu_down(cpu, 1); | 384 | error = _cpu_down(cpu, 1); |
| 395 | if (!error) { | 385 | if (!error) |
| 396 | cpumask_set_cpu(cpu, frozen_cpus); | 386 | cpumask_set_cpu(cpu, frozen_cpus); |
| 397 | printk("CPU%d is down\n", cpu); | 387 | else { |
| 398 | } else { | ||
| 399 | printk(KERN_ERR "Error taking CPU%d down: %d\n", | 388 | printk(KERN_ERR "Error taking CPU%d down: %d\n", |
| 400 | cpu, error); | 389 | cpu, error); |
| 401 | break; | 390 | break; |
