Which processor would execute hardware interrupt in a muticore system

こ雲淡風輕ζ 提交于 2020-03-18 09:13:45

问题


In general hardware interrupts need to be processed immediately, at least so as to acknowledge it and do some first level of processing. As I understand this is not scheduled activity. Please correct me.

So the question is how to choose a processor that would actually execute this hardware interrupt handler?

One can answer this for Linux and/or BSD systems


回答1:


In general, this depends on the functionality offered by multi-core processor and OS. While using multi-core processors, you might need to configure the affinity of the interrupt as per your requirement.

In the case of linux, the /proc file system has provision to show/configure the affinity of interrupts.

1) The file smp_affinity for respective irq holds a bitmask which can be used for configuring the irq to be serviced by respective core in multi-core system :

/proc/irq/'irq_number'/smp_affinity

echo 2 > /proc/irq/12/smp_affinity  -> Configures the affinity of IRQ 12 to CPU 1
echo 4 > /proc/irq/14/smp_affinity  -> Configures the affinity of IRQ 14 to CPU 2

2) The file smp_affinity_list helps in configuring a range of CPU for a particular IRQ by avoiding the method of bitmask to configure the cores :

/proc/irq/'irq_number'/smp_affinity_list

cat /proc/irq/12/smp_affinity_list -> Configures the affinity of IRQ 12 to CPU cores 0 to 3

3) Also linux offers a interrupts load balancing daemon called irqbalance which can help in distribution of interrupts across processor cores to optimize performance. This daemon may be enabled by default in certain system and hence this should be disabled if you want the manually configure the affinity of interrupt else this might override the configured affinity after every reset.




回答2:


It truly depends upon the operating system implementation.

Some assign a all interrupts to a single processor, while others distribute the interrupt handling across some or all of the processors.

On NUMA systems, the operating system should attempt to assign interrupt handling to a "nearby" processor.

You'll have to read the source of the operating system (and version) you're interested in to figure out what it uses.



来源:https://stackoverflow.com/questions/41323565/which-processor-would-execute-hardware-interrupt-in-a-muticore-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!