IPI 通信(SMP)【转】

摘要:
在MIPS架构下的IPI通信被关闭和中断后,IPIMIPS接口结构平台也将被发送_ smp_Ops{void;void;…}IPI通信是多个处理器之间的通信。send_ ipi_Single:一对一聊天send_ ipi_Mask:Mask posting,Mask表示Mask posting/*Octeon Tellanothercore of Lushiticache*/*Usedbykexeccrashdumptosaveallcpu的状态*/file:arch/maps/include/asm/smp。h何时会产生不同的行动(活动)?他们各自的角色是什么?

转自:https://winddoing.github.io/post/60164.html

IPI (Interrupt-Procecesorr Interrupt): 处理中间的中断

主要应用是一个处理器让另一个处理器做特定的事情(function 和 sched)

 
              +---------------------------+-+
system boot | request_percpu_irq() +
| mailbox irq handle +
+--+-----------------------+--+
| |
| |
+--v--+ +---v-+
| CPU0| > CPU1|
+--+--+ +----++
| |
+----+----+ +-----+-----+
|mailbox0 | +-->mailbox1 |
+---------+ | +-----------+
|
+---------------+ |
system run A send IPI CPU1 |
write mailbox1 |
| |
| +-----v-----------------+---+
+------+----+ | 1. 读取mailbox中的action +
| Task A | | 2. 通过action判断IPI类型 +
| | | 3. 进行function和sched处理+
+-----------+ | +
+---------------------------+

在多核处理器中,每一个 CPU 核有一个 mailbox(相当于邮箱),如果需要进行 IPI 通信时,其主要通过 IPI 的中断实现。假设 CPU0 需要给 CPU1 发送一个 action(actionI 的类型:SMP_CALL_FUNCTION,SMP_RESCHEDULE_YOURSELF 等) 时,只需要 CPU0 向 CPU1 的 mailbox 中写于 action 的 id(相当于信),此时 CPU1 将产生一个 IPI 中断(表明收到信),mailbox 的中断处理程序将读取 mailbox(相当于看信)中的 action,判断 action 的类型进行相应的处理。

MIPS 架构下的 IPI 通信

  1. 关闭中断后还会发送 IPI

MIPS 接口

 
struct plat_smp_ops {
void (*send_ipi_single)(int cpu, unsigned int action);
void (*send_ipi_mask)(const struct cpumask *mask, unsigned int action);
...
}

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

  1. 不同的 action (活动) 何时将产生?
  2. 各自都有什么作用?

SMP_RESCHEDULE_YOURSELF

SMP_RESCHEDULE_YOURSELF 将直接调用 scheduler_ipi. 将任务插入目标 CPU 的运行队列。

 
/*
* this function sends a 'reschedule' IPI to another CPU.
* it goes straight through and wastes no time serializing
* anything. Worst case is that we lose a reschedule ...
*/
static inline void smp_send_reschedule(int cpu)
{
extern struct plat_smp_ops *mp_ops; /* private */

mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF);
}

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)
{
extern struct plat_smp_ops *mp_ops; /* private */

mp_ops->send_ipi_mask(&cpumask_of_cpu(cpu), SMP_CALL_FUNCTION);
}

static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
{
extern struct plat_smp_ops *mp_ops; /* private */

mp_ops->send_ipi_mask(mask, SMP_CALL_FUNCTION);
}

file: arch/mips/include/asm/smp.h

 
/*
* smp_call_function_single - Run a function on a specific CPU
* @func: The function to run. This must be fast and non-blocking.
* @info: An arbitrary pointer to pass to the function.
* @wait: If true, wait until function has completed on other CPUs.
*
* Returns 0 on success, else a negative status code.
*/

smp_call_function_single
->generic_exec_single
->arch_send_call_function_single_ipi

/**
* smp_call_function_many(): Run a function on a set of other CPUs.
* @mask: The set of cpus to run on (only runs on online subset).
* @func: The function to run. This must be fast and non-blocking.
* @info: An arbitrary pointer to pass to the function.
* @wait: If true, wait (atomically) until function has completed
* on other CPUs.
*
* If @wait is true, then returns once @func has returned.
*
* You must not call this function with disabled interrupts or from a
* hardware interrupt handler or from a bottom half handler. Preemption
* must be disabled when calling this function.
*/

smp_call_function_many
->arch_send_call_function_ipi_mask

file: kernel/smp.c

刷新 TLB

多核进行 TLB 的同步?

免责声明:文章转载自《IPI 通信(SMP)【转】》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇weblogic 的应用链接不上数据库报异常 Caused By: weblogic.common.ResourceException: Io exception: Connection reset 错误信息表示访问数据库异常,创建链接池失败ubuntu 常见安装软件错误下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

【Flutter 混合开发】与原生通信-BasicMessageChannel

Flutter 混合开发系列 包含如下: 嵌入原生View-Android 嵌入原生View-iOS 与原生通信-MethodChannel 与原生通信-BasicMessageChannel 与原生通信-EventChannel 添加 Flutter 到 Android Activity 添加 Flutter 到 Android Fragment...

操作系统笔记-1

第一章 操作系统引论 ★计算机操作系统是方便用户、管理和控制计算机软硬件资源的系统软件(或程序集合)。 1.OS的目标:有效性、方便性、可扩充性、开放性 2.OS的作用:1) OS作为用户与计算机硬件系统之间的接口;             ★(用户使用计算机的三种方式:命令、系统调用、图标窗口) 2)OS作为计算机系统资源的管理者;           ...

开网页自动进入路由器设置界面的解决办法(腾达路由器)

腾达路由器设置完毕后,开网页自动进入路由器设置界面,并且WAN口状态显示连接中 问题1:显示“连接中”怎么办? 原因1:路由器WAN口的上网方式选择错误。 解决方法:进到路由器设置页面,点击“高级设置”-“WAN口设置”选择正确的上网方式. 原因2:宽带的账号和密码输错了或者没有区分大小写 解决方法:输入正确的宽带帐号和密码,注意区分帐号密码大小写。 原...

通俗地讲,Netty 能做什么?

https://www.zhihu.com/question/24322387/answer/78947405 作者:郭无心链接:https://www.zhihu.com/question/24322387/answer/78947405来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 Netty是什么? 1)本质:J...

C++面试

https://blog.csdn.net/weixin_44363885/article/details/99567746 这一行是个 贼鸡巴重要的链接!!!   很好的总结 我直接复制到下面了: 社招:社招的同学,无论是1-3年经验,还是中途转行,都可参考。写简历必须有针对性,以后台开发为例,请去拉勾网 / 猎聘 / 智联招聘等网站,多看看后台开发的J...

专业术语常用名词缩写中英文对照

A:Actuator 执行器A:Amplifier 放大器A:Attendance员工考勤A:Attenuation衰减AA:Antenna amplifier 开线放大器AA:Architectural Acoustics建筑声学AC:Analogue Controller 模拟控制器ACD:Automatic Call Distribution 自动...