arch/x86/kernel/smpboot.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/smpboot.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/smpboot.c- Extension
.c- Size
- 39712 bytes
- Lines
- 1532
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/smp.hlinux/export.hlinux/sched.hlinux/sched/topology.hlinux/sched/hotplug.hlinux/sched/task_stack.hlinux/percpu.hlinux/memblock.hlinux/err.hlinux/nmi.hlinux/tboot.hlinux/gfp.hlinux/cpuidle.hlinux/kexec.hlinux/numa.hlinux/pgtable.hlinux/overflow.hlinux/stackprotector.hlinux/cpuhotplug.hlinux/mc146818rtc.hlinux/acpi.hasm/acpi.hasm/cacheinfo.hasm/cpuid/api.hasm/desc.hasm/nmi.hasm/irq.hasm/realmode.hasm/cpu.hasm/numa.hasm/tlbflush.h
Detected Declarations
struct mwait_cpu_deadfunction arch_update_cpu_topologyfunction smpboot_setup_warm_reset_vectorfunction smpboot_restore_warm_reset_vectorfunction ap_startingfunction ap_calibrate_delayfunction start_secondaryfunction topology_same_nodefunction topology_sanefunction match_smtfunction match_diefunction match_l2cfunction match_pkgfunction split_llc_setupfunction match_llcfunction x86_sched_itmt_flagsfunction x86_core_flagsfunction x86_cluster_flagsfunction build_sched_topologyfunction slit_cluster_symmetricfunction slit_cluster_packagefunction for_each_cpufunction slit_validatefunction slit_cluster_distancefunction arch_sched_node_distancefunction set_cpu_sibling_mapfunction for_each_cpufunction impress_friendsfunction cpu_init_udelayfunction smp_set_init_udelayfunction send_init_sequencefunction wakeup_secondary_cpu_via_initfunction announce_cpufunction common_cpu_upfunction do_boot_cpufunction native_kick_apfunction arch_cpuhp_kick_ap_alivefunction arch_cpuhp_cleanup_kick_cpufunction arch_cpuhp_cleanup_dead_cpufunction arch_cpuhp_sync_state_pollfunction arch_disable_smp_supportfunction disable_smpfunction smp_prepare_cpus_commonfunction for_each_possible_cpufunction smp_prepare_boot_cpufunction arch_cpuhp_init_parallel_bringupfunction native_smp_prepare_cpusfunction arch_thaw_secondary_cpus_begin
Annotated Snippet
struct mwait_cpu_dead {
unsigned int control;
unsigned int status;
};
#define CPUDEAD_MWAIT_WAIT 0xDEADBEEF
#define CPUDEAD_MWAIT_KEXEC_HLT 0x4A17DEAD
/*
* Cache line aligned data for mwait_play_dead(). Separate on purpose so
* that it's unlikely to be touched by other CPUs.
*/
static DEFINE_PER_CPU_ALIGNED(struct mwait_cpu_dead, mwait_cpu_dead);
/* Maximum number of SMT threads on any online core */
int __read_mostly __max_smt_threads = 1;
/* Flag to indicate if a complete sched domain rebuild is required */
bool x86_topology_update;
int arch_update_cpu_topology(void)
{
int retval = x86_topology_update;
x86_topology_update = false;
return retval;
}
static unsigned int smpboot_warm_reset_vector_count;
static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)
{
unsigned long flags;
spin_lock_irqsave(&rtc_lock, flags);
if (!smpboot_warm_reset_vector_count++) {
CMOS_WRITE(0xa, 0xf);
*((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_HIGH)) = start_eip >> 4;
*((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = start_eip & 0xf;
}
spin_unlock_irqrestore(&rtc_lock, flags);
}
static inline void smpboot_restore_warm_reset_vector(void)
{
unsigned long flags;
/*
* Paranoid: Set warm reset code and vector here back
* to default values.
*/
spin_lock_irqsave(&rtc_lock, flags);
if (!--smpboot_warm_reset_vector_count) {
CMOS_WRITE(0, 0xf);
*((volatile u32 *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 0;
}
spin_unlock_irqrestore(&rtc_lock, flags);
}
/* Run the next set of setup steps for the upcoming CPU */
static void ap_starting(void)
{
int cpuid = smp_processor_id();
/* Mop up eventual mwait_play_dead() wreckage */
this_cpu_write(mwait_cpu_dead.status, 0);
this_cpu_write(mwait_cpu_dead.control, 0);
/*
* If woken up by an INIT in an 82489DX configuration the alive
* synchronization guarantees that the CPU does not reach this
* point before an INIT_deassert IPI reaches the local APIC, so it
* is now safe to touch the local APIC.
*
* Set up this CPU, first the APIC, which is probably redundant on
* most boards.
*/
apic_ap_setup();
/* Save the processor parameters. */
identify_secondary_cpu(cpuid);
/*
* The topology information must be up to date before
* notify_cpu_starting().
*/
set_cpu_sibling_map(cpuid);
ap_init_aperfmperf();
Annotation
- Immediate include surface: `linux/init.h`, `linux/smp.h`, `linux/export.h`, `linux/sched.h`, `linux/sched/topology.h`, `linux/sched/hotplug.h`, `linux/sched/task_stack.h`, `linux/percpu.h`.
- Detected declarations: `struct mwait_cpu_dead`, `function arch_update_cpu_topology`, `function smpboot_setup_warm_reset_vector`, `function smpboot_restore_warm_reset_vector`, `function ap_starting`, `function ap_calibrate_delay`, `function start_secondary`, `function topology_same_node`, `function topology_sane`, `function match_smt`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.