Apr 08 2009

分配IRQ中断使用的cpu资源

Category: 技术ssmax @ 09:42:21

现在的服务器一般都是多核了,但是中断很多时候都是只用一个核,如果有些中断要求比较高,可以把它独立分配给一个cpu使用。

查看irq资源

cat /proc/interrupts

 

           CPU0       CPU1       CPU2       CPU3       
  0:        131          0          0       1914   IO-APIC-edge      timer
  1:          0          0          0          2   IO-APIC-edge      i8042
  6:          0          0          0          3   IO-APIC-edge      floppy
  8:          0          0          0          0   IO-APIC-edge      rtc
  9:          0          0          0          1   IO-APIC-fasteoi   acpi
 12:          0          0          0          4   IO-APIC-edge      i8042
 16:          0          0          0         88   IO-APIC-fasteoi   uhci_hcd:usb1
 18:          0          0          0          0   IO-APIC-fasteoi   uhci_hcd:usb2
 19:          0          0          0          0   IO-APIC-fasteoi   uhci_hcd:usb3
 20:          0          0          0    3632390   IO-APIC-fasteoi   eth0
 21:          0          0          0     286964   IO-APIC-fasteoi   eth1
 22:          0          0          0        122   IO-APIC-fasteoi   ehci_hcd:usb4, ide0
 23:          0          0          0      71154   IO-APIC-fasteoi   megaraid
 24:      22742   71684193          0  501949119   IO-APIC-fasteoi   wct4xxp
NMI:          0          0          0          0   Non-maskable interrupts
LOC:    2928977    1633788    6945258    8115638   Local timer interrupts
RES:       1507       2361       3804       3442   Rescheduling interrupts
CAL:        263        226        288        168   function call interrupts
TLB:       5488       4201       5293       3658   TLB shootdowns
TRM:          0          0          0          0   Thermal event interrupts
SPU:          0          0          0          0   Spurious interrupts
ERR:          0
MIS:          0

wct4xxp 就是E1卡TE410P,这个对中端要求比较高,所以分配到独立的cpu来处理,irq号是24

cat /proc/irq/24/smp_affinity
00000003

smp_affinity 文件默认是全部ffffffff,8个f就是16的8次方位,一般一台机就几只cpu,所以够了,echo 3 > /proc/irq/24/smp_affinity 就是分配第一第二只cpu给该irq。

 

smp_affinity 具体定义:

IRQ Affinity

Binding IRQ’s to a group of CPU’s is a new feature of the 2.4 kernel. While it was originally developed as part of Red Hat Content Accelerator, it is now a generic and independent kernel feature. Every IRQ source in Linux has an entry in /proc/irq directory. For example, the settings for IRQ 40 is stored in /proc/irq/40. IRQ affinity, or IRQ bindings, is configured though the smp_affinity setting in that directory. For example, the smp_affinity for IRQ 40 is in /proc/irq/40/smp_affinity. The value of the smp_affinity setting is a bitmask of all CPU’s that are permitted as a resource for the given IRQ. The default value for smp_affinity is the HEX value 0xffffffff. This means the processes for the IRQ are sent to all CPU’s. You are not allowed to turn off all CPU’s for an IRQ. If the IRQ controller does not support IRQ affinity, the value can not be changed from the default. If multiple CPU’s are defined, then the IRQ source uses the least busy CPU. This is called ‘lowest priority APIC routing.’ IRQ affinity is achieved by binding an IRQ to a specific CPU or group of CPU’s by echoing a HEX value to smp_affinity for the IRQ.

2 Responses to “分配IRQ中断使用的cpu资源”

  1. andre says:

    这个irq绑定到cpu组上有什么特别用到的地方么?

  2. ssmax says:

    irq要占用寄存器的嘛,所以分到某个cpu上面还是有用的,至于用在什么地方,基本都是一些特殊设备使用的,比如bios的timer很占用资源,irqbalance就会把它分配到全部cpu了。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.