2 * Common SMP CPU bringup/teardown functions
6 #include <linux/init.h>
7 #include <linux/sched.h>
8 #include <linux/percpu.h>
12 #ifdef CONFIG_GENERIC_SMP_IDLE_THREAD
14 * For the hotplug case we keep the task structs around and reuse
17 static DEFINE_PER_CPU(struct task_struct
*, idle_threads
);
19 struct task_struct
* __cpuinit
idle_thread_get(unsigned int cpu
)
21 struct task_struct
*tsk
= per_cpu(idle_threads
, cpu
);
24 return ERR_PTR(-ENOMEM
);
29 void __init
idle_thread_set_boot_cpu(void)
31 per_cpu(idle_threads
, smp_processor_id()) = current
;
34 static inline void idle_init(unsigned int cpu
)
36 struct task_struct
*tsk
= per_cpu(idle_threads
, cpu
);
41 pr_err("SMP: fork_idle() failed for CPU %u\n", cpu
);
43 per_cpu(idle_threads
, cpu
) = tsk
;
48 * idle_thread_init - Initialize the idle thread for a cpu
49 * @cpu: The cpu for which the idle thread should be initialized
51 * Creates the thread if it does not exist.
53 void __init
idle_threads_init(void)
57 for_each_possible_cpu(cpu
) {
58 if (cpu
!= smp_processor_id())