mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	 ee74d13229
			
		
	
	
		ee74d13229
		
	
	
	
	
		
			
			While trying to initialize idle threads for all cpus, idle_threads_init() calls smp_processor_id() in a loop, which is unnecessary. The intent is to initialize idle threads for all non-boot cpus. So just use a variable to note the boot cpu and use it in the loop. Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Cc: suresh.b.siddha@intel.com Cc: venki@google.com Cc: nikunj@linux.vnet.ibm.com Link: http://lkml.kernel.org/r/20120524151055.2549.64309.stgit@srivatsabhat.in.ibm.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
		
			
				
	
	
		
			64 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * Common SMP CPU bringup/teardown functions
 | |
|  */
 | |
| #include <linux/err.h>
 | |
| #include <linux/smp.h>
 | |
| #include <linux/init.h>
 | |
| #include <linux/sched.h>
 | |
| #include <linux/percpu.h>
 | |
| 
 | |
| #include "smpboot.h"
 | |
| 
 | |
| #ifdef CONFIG_GENERIC_SMP_IDLE_THREAD
 | |
| /*
 | |
|  * For the hotplug case we keep the task structs around and reuse
 | |
|  * them.
 | |
|  */
 | |
| static DEFINE_PER_CPU(struct task_struct *, idle_threads);
 | |
| 
 | |
| struct task_struct * __cpuinit idle_thread_get(unsigned int cpu)
 | |
| {
 | |
| 	struct task_struct *tsk = per_cpu(idle_threads, cpu);
 | |
| 
 | |
| 	if (!tsk)
 | |
| 		return ERR_PTR(-ENOMEM);
 | |
| 	init_idle(tsk, cpu);
 | |
| 	return tsk;
 | |
| }
 | |
| 
 | |
| void __init idle_thread_set_boot_cpu(void)
 | |
| {
 | |
| 	per_cpu(idle_threads, smp_processor_id()) = current;
 | |
| }
 | |
| 
 | |
| static inline void idle_init(unsigned int cpu)
 | |
| {
 | |
| 	struct task_struct *tsk = per_cpu(idle_threads, cpu);
 | |
| 
 | |
| 	if (!tsk) {
 | |
| 		tsk = fork_idle(cpu);
 | |
| 		if (IS_ERR(tsk))
 | |
| 			pr_err("SMP: fork_idle() failed for CPU %u\n", cpu);
 | |
| 		else
 | |
| 			per_cpu(idle_threads, cpu) = tsk;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * idle_thread_init - Initialize the idle thread for a cpu
 | |
|  * @cpu:	The cpu for which the idle thread should be initialized
 | |
|  *
 | |
|  * Creates the thread if it does not exist.
 | |
|  */
 | |
| void __init idle_threads_init(void)
 | |
| {
 | |
| 	unsigned int cpu, boot_cpu;
 | |
| 
 | |
| 	boot_cpu = smp_processor_id();
 | |
| 
 | |
| 	for_each_possible_cpu(cpu) {
 | |
| 		if (cpu != boot_cpu)
 | |
| 			idle_init(cpu);
 | |
| 	}
 | |
| }
 | |
| #endif
 |