linux IPI

来源:互联网 发布:淘宝店卖什么比较火 编辑:程序博客网 时间:2024/06/10 08:36
在SMP内部,芯片内部一个处理器常常要有目标地向系统中的其他处理器发出中断请求,这种中断被称为处理器间中断(IPI, Inter Processor Interrupt)。
powerpc 有4个IPI:
call_function_action
reschedule_action
call_function_single_action
debug_ipi_action

目前linux-2.6.34.12 内核用到了call_function_action,reschedule_action,call_function_single_action。linux-3之后的内核debug_ipi_action也用到了。
    
linux kerenl 的注释
call_function_action:Invoked by arch to handle an IPI for call function. Must be called with interrupts disabled.
call_function_single_action:Invoked by arch to handle an IPI for call function single. Must be called from the arch with interrupts disabled.
具体代码见 arch/powerpc/kernel/smp.c


“reschedule_action”中断。当前CPU可以发送该中断来指示目标CPU可能需要一次进程调度,至于目标CPU在处理完该中断以后是否进行进程调度,那得要看事先或者在处理中断的过程中是否把当前进程设置为需要调度。
 What are Rescheduling Interrupts?
With multi core machines, such as Intel Centrino Duos, the scheduler tries to spread processor activity across as many cores as possible. The general rule of thumb is that it is preferable to have as many processes running on all the cores in lower power (lower clock frequencies) rather than have one core really busy running at full speed while other cores are sleeping.
When the scheduler decides to offload work from one core to another sleeping core, a kernel IPI "message" is sent to a sleeping core to wake it up from a low power sleep to make it start running a process. These IPI events are reported by powertop as "Rescheduling Interrupts". The information is available by reading /proc/interrupts - the IPI events are reported as an interrupt.
Generally speaking wakeup events are caused by timer wakeups or interrupts from hardware and these causes processes to be woken up and get scheduled to run. The scheduler will generate IPIs when it deems it necessary to put these woken up processed onto a sleeping core, hence a system with lots of wakeups or interrupts may manifest many "Rescheduling Interrupts".
If powertop is reporting many hundreds or possibly thousands of "Rescheduling Interrupts" then there probably is a problem with a BIOS setting (misconfigured interrupt setup) or a misbehaving application (generating lots of wakeup from timer in threads).

“call_function_action”中断。这个中断被用来请求目标CPU执行一个指定的函数。之所以要通过IPI请其他CPU执行,是因为某个函数必须由目标CPU才能完成,而不能由别的CPU代替。比如某个处理器改变了内存中某个页面映射目录或页面映射表的内容,从而可能引起其他处理器的TLB与其不一致时,就向系统中正在使 用这个映射表的处理器发送这个中断,请它们自己执行代码,废弃各自TLB的内容。
call_function_single_action 类似的作用,不同是请求目前CPU是单个CPU。

debug_ipi_action:The complicated debugger ipi case with its muxed crash handling code is moved to debug_ipi_action which is now called from the demux code (instead of the multi-message action calling smp_message_recv).

参考文档:
https://help.ubuntu.com/community/ReschedulingInterrupts
http://blog.donews.com/badcoffee/archive/category//技术收藏转载

原创粉丝点击