/* ** Yoink this CPU from the runnable list... ** */ static void halt_processor(void) { /* REVISIT : redirect I/O Interrupts to another CPU? */ /* REVISIT : does PM *know* this CPU isn't available? */ set_cpu_online(smp_processor_id(), false); local_irq_disable(); for (;;) ; }
void __init smp_prepare_boot_cpu(void) { int bootstrap_processor = per_cpu(cpu_data, 0).cpuid; /* Setup BSP mappings */ printk(KERN_INFO "SMP: bootstrap CPU ID is %d\n", bootstrap_processor); set_cpu_online(bootstrap_processor, true); set_cpu_present(bootstrap_processor, true); }
/* * Activate the first processor. */ void __init boot_cpu_init(void) { int cpu = smp_processor_id(); /* Mark the boot cpu "present", "online" etc for SMP and UP case */ set_cpu_online(cpu, true); set_cpu_active(cpu, true); set_cpu_present(cpu, true); set_cpu_possible(cpu, true); }
/* * This is the secondary CPU boot entry. We're using this CPUs * idle thread stack, but a set of temporary page tables. */ asmlinkage void __cpuinit secondary_start_kernel(void) { struct mm_struct *mm = &init_mm; unsigned int cpu = smp_processor_id(); printk("CPU%u: Booted secondary processor\n", cpu); /* * All kernel threads share the same mm context; grab a * reference and switch to it. */ atomic_inc(&mm->mm_count); current->active_mm = mm; cpumask_set_cpu(cpu, mm_cpumask(mm)); set_my_cpu_offset(per_cpu_offset(smp_processor_id())); /* * TTBR0 is only used for the identity mapping at this stage. Make it * point to zero page to avoid speculatively fetching new entries. */ cpu_set_reserved_ttbr0(); flush_tlb_all(); preempt_disable(); trace_hardirqs_off(); if (cpu_ops[cpu]->cpu_postboot) cpu_ops[cpu]->cpu_postboot(); /* * OK, now it's safe to let the boot CPU continue. Wait for * the CPU migration code to notice that the CPU is online * before we continue. */ set_cpu_online(cpu, true); complete(&cpu_running); smp_store_cpu_info(cpu); /* * Enable GIC and timers. */ notify_cpu_starting(cpu); local_dbg_enable(); local_irq_enable(); local_fiq_enable(); /* * OK, it's off to the idle thread for us */ cpu_startup_entry(CPUHP_ONLINE); }
static void __init boot_cpu_init(void) { int cpu = smp_processor_id(); /* Mark the boot cpu "present", "online" etc for SMP and UP case */ // cpu_online_bits, cpu_present_bits, cpu_possible_bits에 대해서 // 첫 번째 bit를 Mark 한다. set_cpu_online(cpu, true); set_cpu_present(cpu, true); set_cpu_possible(cpu, true); }
static void stop_this_cpu(void) { /* */ set_cpu_online(smp_processor_id(), false); max_xtp(); local_irq_disable(); cpu_halt(); }
/* * Activate a secondary processor. */ notrace static void __cpuinit start_secondary(void *unused) { /* * Don't put *anything* before cpu_init(), SMP booting is too * fragile that we want to limit the things done here to the * most necessary things. */ cpu_init(); x86_cpuinit.early_percpu_clock_init(); preempt_disable(); smp_callin(); enable_start_cpu0 = 0; /* otherwise gcc will move up smp_processor_id before the cpu_init */ barrier(); /* switch away from the initial page table */ #ifdef CONFIG_PAX_PER_CPU_PGD load_cr3(get_cpu_pgd(smp_processor_id(), kernel)); __flush_tlb_all(); #elif defined(CONFIG_X86_32) load_cr3(swapper_pg_dir); __flush_tlb_all(); #endif /* * Check TSC synchronization with the BP: */ check_tsc_sync_target(); /* * We need to hold vector_lock so there the set of online cpus * does not change while we are assigning vectors to cpus. Holding * this lock ensures we don't half assign or remove an irq from a cpu. */ lock_vector_lock(); set_cpu_online(smp_processor_id(), true); unlock_vector_lock(); per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; x86_platform.nmi_init(); /* enable local interrupts */ local_irq_enable(); /* to prevent fake stack check failure in clock setup */ boot_init_stack_canary(); x86_cpuinit.setup_percpu_clockev(); wmb(); cpu_startup_entry(CPUHP_ONLINE); }
void stop_this_cpu(void *dummy) { local_irq_disable(); /* * Remove this CPU: */ set_cpu_online(smp_processor_id(), false); disable_local_APIC(); for (;;) halt(); }
void __init smp_prepare_boot_cpu(void) { unsigned int cpu = smp_processor_id(); __cpu_number_map[0] = cpu; __cpu_logical_map[0] = cpu; set_cpu_online(cpu, true); set_cpu_possible(cpu, true); per_cpu(cpu_state, cpu) = CPU_ONLINE; }
void __devinit smp_prepare_boot_cpu(void) { BUG_ON(smp_processor_id() != boot_cpuid); set_cpu_online(boot_cpuid, true); cpu_set(boot_cpuid, per_cpu(cpu_sibling_map, boot_cpuid)); cpu_set(boot_cpuid, per_cpu(cpu_core_map, boot_cpuid)); #ifdef CONFIG_PPC64 paca[boot_cpuid].__current = current; #endif current_set[boot_cpuid] = task_thread_info(current); }
static void stop_self(void *v) { int cpu = smp_processor_id(); /* make sure we're not pinning something down */ load_cr3(swapper_pg_dir); /* should set up a minimal gdt */ set_cpu_online(cpu, false); HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL); BUG(); }
static void stop_self(void *v) { int cpu = smp_processor_id(); load_cr3(swapper_pg_dir); set_cpu_online(cpu, false); HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL); BUG(); }
/* * Activate a secondary processor. */ static void notrace start_secondary(void *unused) { /* * Don't put *anything* before cpu_init(), SMP booting is too * fragile that we want to limit the things done here to the * most necessary things. */ cpu_init(); x86_cpuinit.early_percpu_clock_init(); preempt_disable(); smp_callin(); enable_start_cpu0 = 0; #ifdef CONFIG_X86_32 /* switch away from the initial page table */ load_cr3(swapper_pg_dir); __flush_tlb_all(); #endif /* otherwise gcc will move up smp_processor_id before the cpu_init */ barrier(); /* * Check TSC synchronization with the BP: */ check_tsc_sync_target(); /* * Lock vector_lock and initialize the vectors on this cpu * before setting the cpu online. We must set it online with * vector_lock held to prevent a concurrent setup/teardown * from seeing a half valid vector space. */ lock_vector_lock(); setup_vector_irq(smp_processor_id()); set_cpu_online(smp_processor_id(), true); unlock_vector_lock(); cpu_set_state_online(smp_processor_id()); x86_platform.nmi_init(); /* enable local interrupts */ local_irq_enable(); /* to prevent fake stack check failure in clock setup */ boot_init_stack_canary(); x86_cpuinit.setup_percpu_clockev(); wmb(); cpu_startup_entry(CPUHP_ONLINE); }
void generic_mach_cpu_die(void) { unsigned int cpu; local_irq_disable(); cpu = smp_processor_id(); printk(KERN_DEBUG "CPU%d offline\n", cpu); __get_cpu_var(cpu_state) = CPU_DEAD; smp_wmb(); while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE) cpu_relax(); set_cpu_online(cpu, true); local_irq_enable(); }
static void ipi_cpu_stop(unsigned int cpu) { spin_lock(&stop_lock); printk(KERN_CRIT "CPU%u: stopping\n", cpu); dump_stack(); spin_unlock(&stop_lock); set_cpu_online(cpu, false); local_irq_disable(); while (1) SSYNC(); }
int generic_cpu_disable(void) { unsigned int cpu = smp_processor_id(); if (cpu == boot_cpuid) return -EBUSY; set_cpu_online(cpu, false); #ifdef CONFIG_PPC64 vdso_data->processorCount--; #endif migrate_irqs(); return 0; }
void machine_crash_nonpanic_core(void *unused) { struct pt_regs regs; crash_setup_regs(®s, NULL); printk(KERN_DEBUG "CPU %u will stop doing anything useful since another CPU has crashed\n", smp_processor_id()); crash_save_cpu(®s, smp_processor_id()); flush_cache_all(); set_cpu_online(smp_processor_id(), false); atomic_dec(&waiting_for_crash_ipi); while (1) cpu_relax(); }
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ void __devinit smp_prepare_boot_cpu(void) { bsp_phys_id = hard_smp_processor_id(); physid_set(bsp_phys_id, phys_cpu_present_map); set_cpu_online(0, true); /* BSP's cpu_id == 0 */ cpumask_set_cpu(0, &cpu_callout_map); cpumask_set_cpu(0, &cpu_callin_map); /* * Initialize the logical to physical CPU number mapping */ init_cpu_to_physid(); map_cpu_to_physid(0, bsp_phys_id); current_thread_info()->cpu = 0; }
void __init smp_prepare_boot_cpu(void) { int cpuid = hard_smp_processor_id(); if (cpuid >= NR_CPUS) { prom_printf("Serious problem, boot cpu id >= NR_CPUS\n"); prom_halt(); } if (cpuid != 0) printk("boot cpu id != 0, this could work but is untested\n"); current_thread_info()->cpu = cpuid; set_cpu_online(cpuid, true); set_cpu_possible(cpuid, true); }
static int pnv_smp_cpu_disable(void) { int cpu = smp_processor_id(); /* This is identical to pSeries... might consolidate by * moving migrate_irqs_away to a ppc_md with default to * the generic fixup_irqs. --BenH. */ set_cpu_online(cpu, false); vdso_data->processorCount--; if (cpu == boot_cpuid) boot_cpuid = cpumask_any(cpu_online_mask); xics_migrate_irqs_away(); return 0; }
void secondary_start_kernel(void) { struct mm_struct *mm = &init_mm; unsigned int cpu = smp_processor_id(); init_mmu(); #ifdef CONFIG_DEBUG_KERNEL if (boot_secondary_processors == 0) { pr_debug("%s: boot_secondary_processors:%d; Hanging cpu:%d\n", __func__, boot_secondary_processors, cpu); for (;;) __asm__ __volatile__ ("waiti " __stringify(LOCKLEVEL)); } pr_debug("%s: boot_secondary_processors:%d; Booting cpu:%d\n", __func__, boot_secondary_processors, cpu); #endif /* Init EXCSAVE1 */ secondary_trap_init(); /* All kernel threads share the same mm context. */ mmget(mm); mmgrab(mm); current->active_mm = mm; cpumask_set_cpu(cpu, mm_cpumask(mm)); enter_lazy_tlb(mm, current); preempt_disable(); trace_hardirqs_off(); calibrate_delay(); notify_cpu_starting(cpu); secondary_init_irq(); local_timer_setup(cpu); set_cpu_online(cpu, true); local_irq_enable(); complete(&cpu_running); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); }
int generic_cpu_disable(void) { unsigned int cpu = smp_processor_id(); if (cpu == boot_cpuid) return -EBUSY; set_cpu_online(cpu, false); #ifdef CONFIG_PPC64 vdso_data->processorCount--; #endif #if defined(CONFIG_PPC64) || defined(CONFIG_E500) fixup_irqs(cpu_online_mask); #endif return 0; }
static void __init smp_online(void) { int cpu_id = smp_processor_id(); notify_cpu_starting(cpu_id); local_irq_enable(); /* Get our bogomips. */ calibrate_delay(); /* Save our processor parameters */ smp_store_cpu_info(cpu_id); set_cpu_online(cpu_id, true); }
int __cpu_disable(void) { unsigned int cpu = smp_processor_id(); int ret; ret = op_cpu_disable(cpu); if (ret) return ret; set_cpu_online(cpu, false); migrate_irqs(); clear_tasks_mm_cpumask(cpu); return 0; }
/* * ipi_cpu_stop - handle IPI from smp_send_stop() */ static void ipi_cpu_stop(unsigned int cpu) { if (system_state == SYSTEM_BOOTING || system_state == SYSTEM_RUNNING) { raw_spin_lock(&stop_lock); pr_crit("CPU%u: stopping\n", cpu); dump_stack(); raw_spin_unlock(&stop_lock); } set_cpu_online(cpu, false); local_irq_disable(); while (1) cpu_relax(); }
static int pseries_cpu_disable(void) { int cpu = smp_processor_id(); set_cpu_online(cpu, false); vdso_data->processorCount--; /*fix boot_cpuid here*/ if (cpu == boot_cpuid) boot_cpuid = cpumask_any(cpu_online_mask); /* FIXME: abstract this to not be platform specific later on */ if (xive_enabled()) xive_smp_disable_cpu(); else xics_migrate_irqs_away(); return 0; }
static int octeon_cpu_disable(void) { unsigned int cpu = smp_processor_id(); if (cpu == 0) return -EBUSY; set_cpu_online(cpu, false); cpu_clear(cpu, cpu_callin_map); local_irq_disable(); octeon_fixup_irqs(); local_irq_enable(); flush_cache_all(); local_flush_tlb_all(); return 0; }
static int octeon_cpu_disable(void) { unsigned int cpu = smp_processor_id(); if (cpu == 0) return -EBUSY; if (!octeon_bootloader_entry_addr) return -ENOTSUPP; set_cpu_online(cpu, false); calculate_cpu_foreign_map(); octeon_fixup_irqs(); __flush_cache_all(); local_flush_tlb_all(); return 0; }
int __cpu_disable(void) { unsigned int cpu = smp_processor_id(); struct task_struct *p; int ret; ret = mp_ops->cpu_disable(cpu); if (ret) return ret; /* * Take this CPU offline. Once we clear this, we can't return, * and we must not schedule until we're ready to give up the cpu. */ set_cpu_online(cpu, false); /* * OK - migrate IRQs away from this CPU */ migrate_irqs(); /* * Stop the local timer for this CPU. */ local_timer_stop(cpu); /* * Flush user cache and TLB mappings, and then remove this CPU * from the vm mask set of all processes. */ flush_cache_all(); local_flush_tlb_all(); read_lock(&tasklist_lock); for_each_process(p) if (p->mm) cpumask_clear_cpu(cpu, mm_cpumask(p->mm)); read_unlock(&tasklist_lock); return 0; }
/*==========================================================================* * Name: stop_this_cpu * * Description: This routine halt CPU. * * Born on Date: 2002.02.05 * * Arguments: NONE * * Returns: void (cannot fail) * * Modification log: * Date Who Description * ---------- --- -------------------------------------------------------- * *==========================================================================*/ static void stop_this_cpu(void *dummy) { int cpu_id = smp_processor_id(); /* * Remove this CPU: */ set_cpu_online(cpu_id, false); /* * PSW IE = 1; * IMASK = 0; * goto SLEEP */ local_irq_disable(); outl(0, M32R_ICU_IMASK_PORTL); inl(M32R_ICU_IMASK_PORTL); /* dummy read */ local_irq_enable(); for ( ; ; ); }