Linux晶片級移植與底層驅動(基於3.7.4核心)SMP多核啟動以及CPU熱插拔驅動

來源:互聯網
上載者:User

在Linux系統中,對於多核的ARM晶片而言,Bootrom代碼中,CPU0會率先起來,引導Bootloader和Linux核心執行,而其他的核則在上電時Bootrom一般將自身置於WFI或者WFE狀態,並等待CPU0給其發CPU核間中斷(IPI)或事件(一般透過SEV指令)喚醒之。一個典型的啟動過程如下圖:

被CPU0喚醒的CPUn可以在運行過程中進行熱插拔。譬如運行如下命令即可卸載CPU1並且將CPU1上的任務全部遷移到其他CPU:

# echo 0 > /sys/devices/system/cpu/cpu1/online

同樣地,運行如下命令可以再次啟動CPU1:

# echo 1 > /sys/devices/system/cpu/cpu1/online

之後CPU1會主動參與系統中各個CPU之間要運行任務的負載平衡工作。

CPU0喚醒其他 CPU的動作在核心中被封裝為一個smp_operations的結構體,該結構體的成員如下:

83struct smp_operations {

84#ifdef CONFIG_SMP

85        /*

86         * Setup the set of possible CPUs (via set_cpu_possible)

87         */

88        void (*smp_init_cpus)(void);

89        /*

90         * Initialize cpu_possible map, and enable coherency

91         */

92        void (*smp_prepare_cpus)(unsigned int max_cpus);

93

94        /*

95         * Perform platform specific initialisation of the specified CPU.

96         */

97        void (*smp_secondary_init)(unsigned int cpu);

98        /*

99         * Boot a secondary CPU, and assign it the specified idle task.

100         * 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

104        int  (*cpu_kill)(unsigned int cpu);

105        void (*cpu_die)(unsigned int cpu);

106        int  (*cpu_disable)(unsigned int cpu);

107#endif

108#endif

109};

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.