-
- return ret;
-}
-
-int __devinit cpu_up(unsigned int cpu)
-{
- int err = 0;
-
- mutex_lock(&cpu_add_remove_lock);
- if (cpu_hotplug_disabled)
- err = -EBUSY;
- else
- err = _cpu_up(cpu);
-
- mutex_unlock(&cpu_add_remove_lock);
- return err;
-}
-
-#ifdef CONFIG_SUSPEND_SMP
-static cpumask_t frozen_cpus;
-
-int disable_nonboot_cpus(void)
-{
- int cpu, first_cpu, error;
-
- mutex_lock(&cpu_add_remove_lock);
- first_cpu = first_cpu(cpu_present_map);
- if (!cpu_online(first_cpu)) {
- error = _cpu_up(first_cpu);
- if (error) {
- printk(KERN_ERR "Could not bring CPU%d up.\n",
- first_cpu);
- goto out;
- }
- }
- error = set_cpus_allowed(current, cpumask_of_cpu(first_cpu));
- if (error) {
- printk(KERN_ERR "Could not run on CPU%d\n", first_cpu);
- goto out;
- }
- /* We take down all of the non-boot CPUs in one shot to avoid races
- * with the userspace trying to use the CPU hotplug at the same time
- */
- cpus_clear(frozen_cpus);
- printk("Disabling non-boot CPUs ...\n");
- for_each_online_cpu(cpu) {
- if (cpu == first_cpu)
- continue;
- error = _cpu_down(cpu);
- if (!error) {
- cpu_set(cpu, frozen_cpus);
- printk("CPU%d is down\n", cpu);
- } else {
- printk(KERN_ERR "Error taking CPU%d down: %d\n",
- cpu, error);
- break;
- }
- }
- if (!error) {
- BUG_ON(num_online_cpus() > 1);
- /* Make sure the CPUs won't be enabled by someone else */
- cpu_hotplug_disabled = 1;
- } else {
- printk(KERN_ERR "Non-boot CPUs are not disabled");
- }