Linux中针对x86架构的IPI种类

5
我想了解在Linux中x86_64有哪些不同类型的IPI可用。特别是,我想找出IPI中断的不同中断处理程序。
在Daniel P. Bovet和Marco Cesati的《理解Linux内核》第3版中,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)

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/x86/include/asm/entry_arch.h?h=v5.6.15

请问这个文件中列出的所有向量都是 x86_64 的不同种类的 IPI 吗?对于 ARM,我找到了一个统一的处理程序 - handle_IPI() 来处理所有的 IPI。使用 switch case 语句来确定哪个 IPI。

1个回答

8
在x86架构中,任何中断向量都可以被IPI触发,因此没有指定的中断向量。

The IPI delivery mode and vector field

上面的图像描述了发送IPI所使用的寄存器格式,Fixed模式使用Vector字段使目标CPU执行与该向量相关联的中断服务例程。就像在目标上执行了int vector指令。
因此,Linux理论上可以直接调用任何其他CPU上的任何中断。
但是,内核模块通常需要在特定的CPU上运行函数;因此,Linux有一组实用程序函数,如smp_call_function_single,这将使程序员的生活变得轻松。
这些函数是使用一种机制实现的,这个机制值得单独写一章,现在我不知道细节,但基本思想不难想象:拥有一个全局函数队列来执行和一个中断向量,一旦被调用,就会出队并执行其中的一个函数。
通过使用IPI调用该中断向量,Linux可以使目标CPU执行给定的函数。
您找到的中断向量用于此目的。您可能需要查看它们在entry_64.S#ifdef CONFIG_SMP保护下的64位对应项。
acpiinterruptacpiinterrupt3只是定义带有第二个参数标签的宏,使用第一个参数(向量号)NOTted调用interrupt_entry并调用第三个参数中命名的函数。
请注意,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)

向量号在irq_vectors.h中定义,并且当然也在idt.c中用于IDT。
目标函数(中断处理程序)大多数(全部?我没有检查)都在smp.c中定义,它们可能是最接近ARM的handle_IPI处理程序的东西。
这些似乎是唯一通过IPI调用的向量。

1
我知道我来晚了,但非常感谢。你的解释帮助我更好地理解了如何实现IPIs,并解决了我面临的问题。干杯! - Sreenath_Vijayan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接