⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smpboot.c

📁 h内核
💻 C
📖 第 1 页 / 共 2 页
字号:
	return 0;}struct pt_regs * __devinit idle_regs(struct pt_regs *regs){	return NULL;}struct create_idle {	struct task_struct *idle;	struct completion done;	int cpu;};voiddo_fork_idle(void *_c_idle){	struct create_idle *c_idle = _c_idle;	c_idle->idle = fork_idle(c_idle->cpu);	complete(&c_idle->done);}static int __devinitdo_boot_cpu (int sapicid, int cpu){	int timeout;	struct create_idle c_idle = {		.cpu	= cpu,		.done	= COMPLETION_INITIALIZER(c_idle.done),	};	DECLARE_WORK(work, do_fork_idle, &c_idle);	/*	 * We can't use kernel_thread since we must avoid to reschedule the child.	 */	if (!keventd_up() || current_is_keventd())		work.func(work.data);	else {		schedule_work(&work);		wait_for_completion(&c_idle.done);	}	if (IS_ERR(c_idle.idle))		panic("failed fork for CPU %d", cpu);	task_for_booting_cpu = c_idle.idle;	Dprintk("Sending wakeup vector %lu to AP 0x%x/0x%x.\n", ap_wakeup_vector, cpu, sapicid);	platform_send_ipi(cpu, ap_wakeup_vector, IA64_IPI_DM_INT, 0);	/*	 * Wait 10s total for the AP to start	 */	Dprintk("Waiting on callin_map ...");	for (timeout = 0; timeout < 100000; timeout++) {		if (cpu_isset(cpu, cpu_callin_map))			break;  /* It has booted */		udelay(100);	}	Dprintk("\n");	if (!cpu_isset(cpu, cpu_callin_map)) {		printk(KERN_ERR "Processor 0x%x/0x%x is stuck.\n", cpu, sapicid);		ia64_cpu_to_sapicid[cpu] = -1;		cpu_clear(cpu, cpu_online_map);  /* was set in smp_callin() */		return -EINVAL;	}	return 0;}static int __initdecay (char *str){	int ticks;	get_option (&str, &ticks);	cache_decay_ticks = ticks;	return 1;}__setup("decay=", decay);/* * # of ticks an idle task is considered cache-hot.  Highly application-dependent.  There * are apps out there which are known to suffer significantly with values >= 4. */unsigned long cache_decay_ticks = 10;	/* equal to MIN_TIMESLICE */static voidsmp_tune_scheduling (void){	printk(KERN_INFO "task migration cache decay timeout: %ld msecs.\n",	       (cache_decay_ticks + 1) * 1000 / HZ);}/* * Initialize the logical CPU number to SAPICID mapping */void __initsmp_build_cpu_map (void){	int sapicid, cpu, i;	int boot_cpu_id = hard_smp_processor_id();	for (cpu = 0; cpu < NR_CPUS; cpu++) {		ia64_cpu_to_sapicid[cpu] = -1;#ifdef CONFIG_HOTPLUG_CPU		cpu_set(cpu, cpu_possible_map);#endif	}	ia64_cpu_to_sapicid[0] = boot_cpu_id;	cpus_clear(cpu_present_map);	cpu_set(0, cpu_present_map);	cpu_set(0, cpu_possible_map);	for (cpu = 1, i = 0; i < smp_boot_data.cpu_count; i++) {		sapicid = smp_boot_data.cpu_phys_id[i];		if (sapicid == boot_cpu_id)			continue;		cpu_set(cpu, cpu_present_map);		cpu_set(cpu, cpu_possible_map);		ia64_cpu_to_sapicid[cpu] = sapicid;		cpu++;	}}#ifdef CONFIG_NUMA/* on which node is each logical CPU (one cacheline even for 64 CPUs) */u8 cpu_to_node_map[NR_CPUS] __cacheline_aligned;EXPORT_SYMBOL(cpu_to_node_map);/* which logical CPUs are on which nodes */cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;/* * Build cpu to node mapping and initialize the per node cpu masks. */void __initbuild_cpu_to_node_map (void){	int cpu, i, node;	for(node=0; node<MAX_NUMNODES; node++)		cpus_clear(node_to_cpu_mask[node]);	for(cpu = 0; cpu < NR_CPUS; ++cpu) {		/*		 * All Itanium NUMA platforms I know use ACPI, so maybe we		 * can drop this ifdef completely.                    [EF]		 */#ifdef CONFIG_ACPI_NUMA		node = -1;		for (i = 0; i < NR_CPUS; ++i)			if (cpu_physical_id(cpu) == node_cpuid[i].phys_id) {				node = node_cpuid[i].nid;				break;			}#else#		error Fixme: Dunno how to build CPU-to-node map.#endif		cpu_to_node_map[cpu] = (node >= 0) ? node : 0;		if (node >= 0)			cpu_set(cpu, node_to_cpu_mask[node]);	}}#endif /* CONFIG_NUMA *//* * Cycle through the APs sending Wakeup IPIs to boot each. */void __initsmp_prepare_cpus (unsigned int max_cpus){	int boot_cpu_id = hard_smp_processor_id();	/*	 * Initialize the per-CPU profiling counter/multiplier	 */	smp_setup_percpu_timer();	/*	 * We have the boot CPU online for sure.	 */	cpu_set(0, cpu_online_map);	cpu_set(0, cpu_callin_map);	local_cpu_data->loops_per_jiffy = loops_per_jiffy;	ia64_cpu_to_sapicid[0] = boot_cpu_id;	printk(KERN_INFO "Boot processor id 0x%x/0x%x\n", 0, boot_cpu_id);	current_thread_info()->cpu = 0;	smp_tune_scheduling();	/*	 * If SMP should be disabled, then really disable it!	 */	if (!max_cpus) {		printk(KERN_INFO "SMP mode deactivated.\n");		cpus_clear(cpu_online_map);		cpus_clear(cpu_present_map);		cpus_clear(cpu_possible_map);		cpu_set(0, cpu_online_map);		cpu_set(0, cpu_present_map);		cpu_set(0, cpu_possible_map);		return;	}}void __devinit smp_prepare_boot_cpu(void){	cpu_set(smp_processor_id(), cpu_online_map);	cpu_set(smp_processor_id(), cpu_callin_map);}#ifdef CONFIG_HOTPLUG_CPUextern void fixup_irqs(void);/* must be called with cpucontrol mutex held */static int __devinit cpu_enable(unsigned int cpu){	per_cpu(cpu_state,cpu) = CPU_UP_PREPARE;	wmb();	while (!cpu_online(cpu))		cpu_relax();	return 0;}int __cpu_disable(void){	int cpu = smp_processor_id();	/*	 * dont permit boot processor for now	 */	if (cpu == 0)		return -EBUSY;	fixup_irqs();	local_flush_tlb_all();	printk ("Disabled cpu %u\n", smp_processor_id());	return 0;}void __cpu_die(unsigned int cpu){	unsigned int i;	for (i = 0; i < 100; i++) {		/* They ack this in play_dead by setting CPU_DEAD */		if (per_cpu(cpu_state, cpu) == CPU_DEAD)		{			/*			 * TBD: Enable this when physical removal			 * or when we put the processor is put in			 * SAL_BOOT_RENDEZ mode			 * cpu_clear(cpu, cpu_callin_map);			 */			return;		}		msleep(100);	} 	printk(KERN_ERR "CPU %u didn't die...\n", cpu);}#else /* !CONFIG_HOTPLUG_CPU */static int __devinit cpu_enable(unsigned int cpu){	return 0;}int __cpu_disable(void){	return -ENOSYS;}void __cpu_die(unsigned int cpu){	/* We said "no" in __cpu_disable */	BUG();}#endif /* CONFIG_HOTPLUG_CPU */voidsmp_cpus_done (unsigned int dummy){	int cpu;	unsigned long bogosum = 0;	/*	 * Allow the user to impress friends.	 */	for (cpu = 0; cpu < NR_CPUS; cpu++)		if (cpu_online(cpu))			bogosum += cpu_data(cpu)->loops_per_jiffy;	printk(KERN_INFO "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",	       (int)num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100);}int __devinit__cpu_up (unsigned int cpu){	int ret;	int sapicid;	sapicid = ia64_cpu_to_sapicid[cpu];	if (sapicid == -1)		return -EINVAL;	/*	 * Already booted.. just enable and get outa idle lool	 */	if (cpu_isset(cpu, cpu_callin_map))	{		cpu_enable(cpu);		local_irq_enable();		while (!cpu_isset(cpu, cpu_online_map))			mb();		return 0;	}	/* Processor goes to start_secondary(), sets online flag */	ret = do_boot_cpu(sapicid, cpu);	if (ret < 0)		return ret;	return 0;}/* * Assume that CPU's have been discovered by some platform-dependent interface.  For * SoftSDV/Lion, that would be ACPI. * * Setup of the IPI irq handler is done in irq.c:init_IRQ_SMP(). */void __initinit_smp_config(void){	struct fptr {		unsigned long fp;		unsigned long gp;	} *ap_startup;	long sal_ret;	/* Tell SAL where to drop the AP's.  */	ap_startup = (struct fptr *) start_ap;	sal_ret = ia64_sal_set_vectors(SAL_VECTOR_OS_BOOT_RENDEZ,				       ia64_tpa(ap_startup->fp), ia64_tpa(ap_startup->gp), 0, 0, 0, 0);	if (sal_ret < 0)		printk(KERN_ERR "SMP: Can't set SAL AP Boot Rendezvous: %s\n",		       ia64_sal_strerror(sal_ret));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -