轉自:https://winddoing.github.io/post/60164.html
IPI (Interrupt-Procecesorr Interrupt): 處理中間的中斷
主要應用是一個處理器讓另一個處理器做特定的事情(function 和 sched)
+---------------------------+-+ |
在多核處理器中,每一個 CPU 核有一個 mailbox
(相當於郵箱),如果需要進行 IPI 通信時,其主要通過 IPI 的中斷實現。假設 CPU0 需要給 CPU1 發送一個 action
(action
I 的類型:SMP_CALL_FUNCTION
,SMP_RESCHEDULE_YOURSELF
等) 時,只需要 CPU0 向 CPU1 的 mailbox
中寫於 action
的 id(相當於信),此時 CPU1 將產生一個 IPI 中斷(表明收到信),mailbox
的中斷處理程序將讀取 mailbox
(相當於看信)中的 action
,判斷 action
的類型進行相應的處理。
MIPS 架構下的 IPI 通信
- 關閉中斷后還會發送 IPI
MIPS 接口
struct plat_smp_ops { |
IPI 通信就是多個處理器之間的
交流
。send_ipi_single
: 一對一聊天send_ipi_mask
: 群發,mask 表示群發的成員(CPU)
action 類型
/* Octeon - Tell another core to flush its icache */
/* Used by kexec crashdump to save all cpu's state */
file: arch/mips/include/asm/smp.h
- 不同的 action (活動) 何時將產生?
- 各自都有什么作用?
SMP_RESCHEDULE_YOURSELF
SMP_RESCHEDULE_YOURSELF
將直接調用scheduler_ipi
. 將任務插入目標 CPU 的運行隊列。
/* |
file: arch/mips/include/asm/smp.h
SMP_CALL_FUNCTION
SMP_CALL_FUNCTION
: 將特定的函數在目標 CPU 上運行
- 內核回調接口:
static inline void arch_send_call_function_single_ipi(int cpu) |
file: arch/mips/include/asm/smp.h
/* |
file: kernel/smp.c
刷新 TLB
多核進行 TLB 的同步?