arch/arm64/kernel/smp.c
Source file repositories/reference/linux-study-clean/arch/arm64/kernel/smp.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kernel/smp.c- Extension
.c- Size
- 31575 bytes
- Lines
- 1317
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/arm_sdei.hlinux/delay.hlinux/init.hlinux/spinlock.hlinux/sched/mm.hlinux/sched/hotplug.hlinux/sched/task_stack.hlinux/interrupt.hlinux/cache.hlinux/profile.hlinux/errno.hlinux/mm.hlinux/err.hlinux/cpu.hlinux/smp.hlinux/seq_file.hlinux/irq.hlinux/irqchip/arm-gic-v3.hlinux/percpu.hlinux/clockchips.hlinux/completion.hlinux/of.hlinux/irq_work.hlinux/kernel_stat.hlinux/kexec.hlinux/kgdb.hlinux/kvm_host.hlinux/nmi.hasm/alternative.hasm/atomic.hasm/cacheflush.h
Detected Declarations
struct ipi_descsfunction op_cpu_killfunction boot_secondaryfunction __cpu_upfunction init_gic_priority_maskingfunction secondary_start_kernelfunction op_cpu_disablefunction __cpu_disablefunction op_cpu_killfunction arch_cpuhp_cleanup_dead_cpufunction cpu_diefunction __cpu_try_diefunction cpu_die_earlyfunction hyp_mode_checkfunction smp_cpus_donefunction smp_prepare_boot_cpufunction is_mpidr_duplicatefunction smp_cpu_setupfunction arch_register_cpufunction arch_unregister_cpufunction acpi_map_gic_cpu_interfacefunction acpi_parse_gic_cpu_interfacefunction acpi_parse_and_init_cpusfunction of_parse_and_init_cpusfunction for_each_of_cpu_nodefunction smp_init_cpusfunction smp_prepare_cpusfunction mapfunction arch_show_interruptsfunction arch_send_call_function_ipi_maskfunction arch_send_call_function_single_ipifunction arch_irq_work_raisefunction local_cpu_stopfunction panic_smp_self_stopfunction ipi_cpu_crash_stopfunction arm64_send_ipifunction arm64_backtrace_ipifunction arch_trigger_cpumask_backtracefunction kgdb_roundup_cpusfunction for_each_online_cpufunction do_handle_IPIfunction ipi_handlerfunction smp_cross_callfunction ipi_should_be_nmifunction ipi_setupfunction ipi_teardownfunction ipi_setup_sgifunction ipi_setup_lpi
Annotated Snippet
struct ipi_descs {
struct irq_desc *descs[MAX_IPI];
};
static DEFINE_PER_CPU_READ_MOSTLY(struct ipi_descs, pcpu_ipi_desc);
#define get_ipi_desc(__cpu, __ipi) (per_cpu_ptr(&pcpu_ipi_desc, __cpu)->descs[__ipi])
static bool percpu_ipi_descs __ro_after_init;
static bool crash_stop;
static void ipi_setup(int cpu);
#ifdef CONFIG_HOTPLUG_CPU
static void ipi_teardown(int cpu);
static int op_cpu_kill(unsigned int cpu);
#else
static inline int op_cpu_kill(unsigned int cpu)
{
return -ENOSYS;
}
#endif
/*
* Boot a secondary CPU, and assign it the specified idle task.
* This also gives us the initial stack to use for this CPU.
*/
static int boot_secondary(unsigned int cpu, struct task_struct *idle)
{
const struct cpu_operations *ops = get_cpu_ops(cpu);
if (ops->cpu_boot)
return ops->cpu_boot(cpu);
return -EOPNOTSUPP;
}
static DECLARE_COMPLETION(cpu_running);
int __cpu_up(unsigned int cpu, struct task_struct *idle)
{
int ret;
long status;
/*
* We need to tell the secondary core where to find its stack and the
* page tables.
*/
secondary_data.task = idle;
update_cpu_boot_status(CPU_MMU_OFF);
/* Now bring the CPU into our world */
ret = boot_secondary(cpu, idle);
if (ret) {
if (ret != -EPERM)
pr_err("CPU%u: failed to boot: %d\n", cpu, ret);
return ret;
}
/*
* CPU was successfully started, wait for it to come online or
* time out.
*/
wait_for_completion_timeout(&cpu_running,
msecs_to_jiffies(5000));
if (cpu_online(cpu))
return 0;
pr_crit("CPU%u: failed to come online\n", cpu);
secondary_data.task = NULL;
status = READ_ONCE(secondary_data.status);
if (status == CPU_MMU_OFF)
status = READ_ONCE(__early_cpu_boot_status);
switch (status & CPU_BOOT_STATUS_MASK) {
default:
pr_err("CPU%u: failed in unknown state : 0x%lx\n",
cpu, status);
cpus_stuck_in_kernel++;
break;
case CPU_KILL_ME:
if (!op_cpu_kill(cpu)) {
pr_crit("CPU%u: died during early boot\n", cpu);
break;
}
pr_crit("CPU%u: may not have shut down cleanly\n", cpu);
fallthrough;
case CPU_STUCK_IN_KERNEL:
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/arm_sdei.h`, `linux/delay.h`, `linux/init.h`, `linux/spinlock.h`, `linux/sched/mm.h`, `linux/sched/hotplug.h`, `linux/sched/task_stack.h`.
- Detected declarations: `struct ipi_descs`, `function op_cpu_kill`, `function boot_secondary`, `function __cpu_up`, `function init_gic_priority_masking`, `function secondary_start_kernel`, `function op_cpu_disable`, `function __cpu_disable`, `function op_cpu_kill`, `function arch_cpuhp_cleanup_dead_cpu`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.