Linux chip-level porting and bottom-driven (based on 3.7.4 kernel) SMP multi-core startup and CPU hot-Plug Drive

Source: Internet
Author: User

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};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.