Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purpose of self-IPI on IA-32

What is the purpose of a processor sending an Inter Processor Interrupt to itself on the IA-32 architecture?

According to the Intel IA-32 Architecture Software Developer's Manual, Vol. 3, Ch. 10.1:

IPIs are used for software self-interrupts, interrupt forwarding, or preemptive scheduling.

But why would you use a self IPI when the processor can also interrupt itself with an INT instruction? This feature seems to be redundant.

like image 843
jmiller Avatar asked Nov 16 '12 12:11

jmiller


2 Answers

I think the big reason is consistency: If you are writing software for a multi core processor, and you want to send an interrupt out to all cores in the system, it would suck to have to do an IPI to every other core, then execute INT to interrupt the current core, and of course you will also have to setup the handlers for both interrupt sources etc... It is just much easier to send IPI to everyone.

Another scenario might be a multi core system where you are passing work or messages around to a "free" core to handle the load. The "free" core might be the current core, again you don't want to have a special case in software just because you are sending an interrupt to yourself.

like image 101
Chris Desjardins Avatar answered Sep 30 '22 18:09

Chris Desjardins


I guess you have already known the reason since 2 years have passed.

But here's my understanding:

IPI can be blocked when IRQ is disabled, it is kept by the IOAPIC, until the destined core re-enables IRQ with an sti instruction. However an int instruction always traps the CPU into a lower ring level, no matter whether IRQ is enabled or not.

So maybe self-IPI is needed when the kernel wants to do something, but not now when the IRQ is disabled. Thus, it sends itself an IPI, making such interrupt happens as soon as the IRQ on that core is re-enabled.

like image 42
liangpig1 Avatar answered Sep 30 '22 18:09

liangpig1