linux-kernel - Linux 中 x86 架构的 IPI 类型
问题描述
我想知道 Linux 中 x86_64 有哪些不同类型的 IPI。特别是,我想找出 IPI 中断的不同中断处理程序。
在 Daniel P. Bovet 的《Understanding the Linux Kernel, 3rd Edition》中,Marco Cesati https://www.oreilly.com/library/view/understanding-the-linux/0596005652/ch04s06.html 列出了三种 IPI:
CALL_FUNCTION_VECTOR
RESCHEDULE_VECTOR
INVALIDATE_TLB_VECTOR
但是在最新的内核中,我在 arch/x86/include/asm/entry_arch.h 中找到了以下注释。
* This file is designed to contain the BUILD_INTERRUPT specifications for
* all of the extra named interrupt vectors used by the architecture.
* Usually this is the Inter Process Interrupts (IPIs)
*/
/*
* The following vectors are part of the Linux architecture, there
* is no hardware IRQ pin equivalent for them, they are triggered
* through the ICC by us (IPIs)
有人可以确认文件中列出的所有这些向量是否是 x86_64 的不同类型的 IPI。对于 ARM,我可以为所有 IPI 找到一个统一的处理程序 - handle_IPI()。switch case 用于找出哪个 IPI。
解决方案
在 x86 上,任何中断向量都可以由 IPI 触发,因此没有(或没有)指定的中断向量。
上图描述了用于发送 IPI 的寄存器格式,Fixed模式使用Vector字段使目标 CPU 执行与该向量相关的中断服务程序。就像int vector
在目标中执行了一条指令。
因此,理论上,Linux 可以直接调用任何其他 CPU 上的任何中断。
然而,内核模块通常需要在特定的 CPU 上运行一个函数;所以 Linux 有一组实用函数,比如smp_call_function_single,这将使程序员的生活变得轻松。
这些函数是用一个值得一章的机制实现的,现在我不知道细节,但不难想象背后的基本思想:有一个要执行的全局函数队列和一个中断向量,一旦被调用,使一个项目出队并执行它。
通过使用 IPI 调用该中断向量,Linux 可以使目标 CPU 执行给定的功能。
您找到的中断向量用于此目的。您可能想在entry_64.S和 guard中查看它们的 64 位对应项#ifdef CONFIG_SMP
。and只是用第二个参数定义标签的宏,
用第一个参数(向量号) NOTted 调用并调用第三个参数中命名的函数。
请注意,32 位模拟会与目标函数名称进行一些讨厌的前缀连接。acpiinterrupt
acpiinterrupt3
interrupt_entry
apicinterrupt CALL_FUNCTION_SINGLE_VECTOR call_function_single_interrupt smp_call_function_single_interrupt
大致相当于定义函数:
;Metadata stuff (e.g. section placement)
call_function_single_interrupt: ;<-- first arg
push ~CALL_FUNCTION_SINGLE_VECTOR ;<-- second arg
call interrupt_entry
;other stuff (tracing, flags, etc)
call smp_call_function_single_interrupt ;<-- third arg
;other stuff (like above, plus returning)
向量编号在irq_vectors.h中定义,当然,在idt.c中也用于IDT。
目标函数(中断处理程序)主要(全部?我没有检查)在smp.c中定义,它们可能是最接近 ARMhandle_IPI
处理程序的东西。
这些似乎是通过 IPI 调用的唯一向量。
推荐阅读
- python - 我已经使用opencv进行云检测但出现错误
- apache-kafka - Kafka ConcurrentMessageListenerContainer 突然停止消费
- c# - canvasJs,将日期从控制器传递到视图
- elasticsearch - 我们可以将我们的数据库迁移到弹性搜索吗?
- mysql - ERROR 1822 (HY000): 添加外键约束失败。SQL 中的约束问题缺少索引
- ios - 在哪些情况下“MTLDevice newTextureWithDescriptor”会在 iOS 中失败?
- java - 如何将 NDEF 消息从 Android 发送到另一台非 Adroid 设备
- android - Searchview 与工具栏中的自定义标题重叠。如何预防?
- android - 通过底部页打开后不显示片段布局
- c++ - 四倍四过采样性能