arch/riscv/kernel/smpboot.c
Source file repositories/reference/linux-study-clean/arch/riscv/kernel/smpboot.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/kernel/smpboot.c- Extension
.c- Size
- 5663 bytes
- Lines
- 265
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/arch_topology.hlinux/module.hlinux/init.hlinux/kernel.hlinux/mm.hlinux/sched.hlinux/kernel_stat.hlinux/notifier.hlinux/cpu.hlinux/percpu.hlinux/delay.hlinux/err.hlinux/irq.hlinux/of.hlinux/sched/task_stack.hlinux/sched/mm.hasm/cacheflush.hasm/cpu_ops.hasm/irq.hasm/mmu_context.hasm/numa.hasm/tlbflush.hasm/sections.hasm/smp.huapi/asm/hwcap.hasm/vector.hhead.h
Detected Declarations
function smp_prepare_cpusfunction for_each_possible_cpufunction acpi_parse_rintcfunction acpi_parse_and_init_cpusfunction of_parse_and_init_cpusfunction for_each_of_cpu_nodefunction setup_smpfunction start_secondary_cpufunction arch_cpuhp_kick_ap_alivefunction __cpu_upfunction smp_cpus_done
Annotated Snippet
if (hart == cpuid_to_hartid_map(0)) {
BUG_ON(found_boot_cpu);
found_boot_cpu = 1;
early_map_cpu_to_node(0, of_node_to_nid(dn));
continue;
}
if (cpuid >= NR_CPUS) {
pr_warn("Invalid cpuid [%d] for hartid [%lu]\n",
cpuid, hart);
continue;
}
cpuid_to_hartid_map(cpuid) = hart;
early_map_cpu_to_node(cpuid, of_node_to_nid(dn));
cpuid++;
}
BUG_ON(!found_boot_cpu);
if (cpuid > nr_cpu_ids)
pr_warn("Total number of cpus [%d] is greater than nr_cpus option value [%d]\n",
cpuid, nr_cpu_ids);
}
void __init setup_smp(void)
{
int cpuid;
cpu_set_ops();
if (acpi_disabled)
of_parse_and_init_cpus();
else
acpi_parse_and_init_cpus();
for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++)
if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID)
set_cpu_possible(cpuid, true);
}
static int start_secondary_cpu(int cpu, struct task_struct *tidle)
{
if (cpu_ops->cpu_start)
return cpu_ops->cpu_start(cpu, tidle);
return -EOPNOTSUPP;
}
#ifdef CONFIG_HOTPLUG_PARALLEL
int arch_cpuhp_kick_ap_alive(unsigned int cpu, struct task_struct *tidle)
{
return start_secondary_cpu(cpu, tidle);
}
#else
int __cpu_up(unsigned int cpu, struct task_struct *tidle)
{
int ret = 0;
tidle->thread_info.cpu = cpu;
ret = start_secondary_cpu(cpu, tidle);
if (!ret) {
wait_for_completion_timeout(&cpu_running,
msecs_to_jiffies(1000));
if (!cpu_online(cpu)) {
pr_crit("CPU%u: failed to come online\n", cpu);
ret = -EIO;
}
} else {
pr_crit("CPU%u: failed to start\n", cpu);
}
return ret;
}
#endif
void __init smp_cpus_done(unsigned int max_cpus)
{
}
/*
* C entry point for a secondary processor.
*/
asmlinkage __visible void smp_callin(void)
{
struct mm_struct *mm = &init_mm;
unsigned int curr_cpuid = smp_processor_id();
if (has_vector()) {
/*
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/arch_topology.h`, `linux/module.h`, `linux/init.h`, `linux/kernel.h`, `linux/mm.h`, `linux/sched.h`, `linux/kernel_stat.h`.
- Detected declarations: `function smp_prepare_cpus`, `function for_each_possible_cpu`, `function acpi_parse_rintc`, `function acpi_parse_and_init_cpus`, `function of_parse_and_init_cpus`, `function for_each_of_cpu_node`, `function setup_smp`, `function start_secondary_cpu`, `function arch_cpuhp_kick_ap_alive`, `function __cpu_up`.
- Atlas domain: Architecture Layer / arch/riscv.
- Implementation status: source implementation candidate.
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.