Sre*_*yan 5 x86-64 interrupt smp linux-kernel interrupt-handling
我想知道 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
Run Code Online (Sandbox Code Playgroud)
然而,在最新的内核中,我在 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)
Run Code Online (Sandbox Code Playgroud)
有人可以确认文件中列出的所有向量是否都是 x86_64 的不同类型的 IPI。对于 ARM,我可以为所有 IPI 找到一个统一的处理程序 - handle_IPI()。switch case 用于找出哪个 IPI。
在 x86 上,任何中断向量都可以由 IPI 触发,因此没有(或没有)指定的中断向量。
上图描述了用于发送 IPI 的寄存器的格式,固定模式使用向量字段使目标 CPU 执行与该向量关联的中断服务例程。这就像int vector在目标中执行了一条指令。
因此理论上Linux可以直接调用任何其他CPU上的任何中断。
然而,内核模块通常需要在特定的CPU上运行某个功能;因此 Linux 有一组像smp_call_function_single这样的实用函数,可以让程序员的工作变得轻松。
这些函数是通过一种机制来实现的,该机制本身就值得一章,现在我不知道细节,但不难想象背后的基本思想:有一个要执行的全局函数队列和一个中断向量,一旦调用,使项目出列并执行它。
通过使用 IPI 调用该中断向量,Linux 可以使目标 CPU 执行给定的函数。
您找到的中断向量用于此目的。您可能想查看entry_64.S中的64 位对应项和guard 下的内容#ifdef CONFIG_SMP。
和只是用第二个参数定义标签的宏,用第一个参数(向量acpiinterrupt号acpiinterrupt3interrupt_entry)NOT 调用并调用第三个参数中命名的函数。
请注意,32 位模拟会与目标函数名称进行一些令人讨厌的前缀连接。
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)
Run Code Online (Sandbox Code Playgroud)
向量号在irq_vectors.h中定义,当然也在idt.c中用于IDT。
目标函数(中断处理程序)大部分(全部?我没有检查)在smp.c中定义,它们可能是最接近 ARMhandle_IPI处理程序的东西。
这些似乎是通过 IPI 调用的唯一向量。
| 归档时间: |
|
| 查看次数: |
2006 次 |
| 最近记录: |