转自: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 的同步?