In Linux, for multi-core arm chips, CPU0 will take the lead in Bootrom code, booting the bootloader and Linux kernel, while other cores bootrom typically place themselves in WFI or WFE states when they are on. and waits for the CPU0 to give its CPU nuclear interrupt (IPI) or event (generally through the SEV Instruction) awakened. A typical startup process is shown below:
Cpun that are awakened by CPU0 can be hot-swappable during operation. For example, you can uninstall CPU1 and migrate all tasks on CPU1 to another CPU by running the following command:
# echo 0 >/sys/devices/system/cpu/cpu1/online
Similarly, you can start CPU1 again by running the following command:
# echo 1 >/sys/devices/system/cpu/cpu1/online
After that, CPU1 will actively participate in the load balancing work between each CPU in the system to run the task.
CPU0 the actions of the other CPUs are encapsulated in the kernel as a smp_operations structure, and the members of the structure are as follows:
83struct Smp_operations {
84#ifdef CONFIG_SMP
85/*
* Setup the set of possible CPUs (via Set_cpu_possible)
87 */
*smp_init_cpus void (void);
89/*
Initialize cpu_possible map, and enable coherency
91 */
(*smp_prepare_cpus) (unsigned int max_cpus);
93
94/*
* Perform platform specific initialisation of the specified CPU.
96 */
*smp_secondary_init void (unsigned int cpu);
98/*
* Boot a secondary CPU, and assign it the specified idle task.
The * This also gives us the initial stack to use for this CPU.
101 */
102 Int (*smp_boot_secondary) (unsigned int cpu, struct task_struct *idle);
103#ifdef CONFIG_HOTPLUG_CPU
(*cpu_kill) (unsigned int CPU);
(*cpu_die) (unsigned int CPU);
The *cpu_disable int (unsigned int cpu);
107#endif
108#endif
109};