是否有可能改变发生哪些核心定时器中断?

时间:2017-08-02 22:50:44

标签: linux linux-kernel x86-64 interrupt

在我的Debian 8系统上,当我运行命令watch -n0.1 --no-title cat /proc/interrupts时,我得到下面的输出。

           CPU0       CPU1       CPU2       CPU3       CPU4       CPU5       CPU6       CPU7                                                                                                                                                                                       [0/1808]
  0:         46          0          0      10215          0          0          0          0   IO-APIC-edge      timer
  1:          1          0          0          2          0          0          0          0   IO-APIC-edge      i8042
  8:          0          0          0          1          0          0          0          0   IO-APIC-edge      rtc0
  9:          0          0          0          0          0          0          0          0   IO-APIC-fasteoi   acpi
 12:          0          0          0          4          0          0          0          0   IO-APIC-edge      i8042
 18:          0          0          0          0          8          0          0          0   IO-APIC-fasteoi   i801_smbus
 19:       7337          0          0          0          0          0          0          0   IO-APIC-fasteoi   ata_piix, ata_piix
 21:          0         66          0          0          0          0          0          0   IO-APIC-fasteoi   ehci_hcd:usb1
 23:          0          0         35          0          0          0          0          0   IO-APIC-fasteoi   ehci_hcd:usb2
 40:     208677          0          0          0          0          0          0          0  HPET_MSI-edge      hpet2
 41:          0       4501          0          0          0          0          0          0  HPET_MSI-edge      hpet3
 42:          0          0       2883          0          0          0          0          0  HPET_MSI-edge      hpet4
 43:          0          0          0       1224          0          0          0          0  HPET_MSI-edge      hpet5
 44:          0          0          0          0       1029          0          0          0  HPET_MSI-edge      hpet6
 45:          0          0          0          0          0          0          0          0   PCI-MSI-edge      aerdrv, PCIe PME
 46:          0          0          0          0          0          0          0          0   PCI-MSI-edge      PCIe PME
 47:          0          0          0          0          0          0          0          0   PCI-MSI-edge      PCIe PME
 48:          0          0          0          0          0          0          0          0   PCI-MSI-edge      PCIe PME
 49:          0          0          0          0          0       8570          0          0   PCI-MSI-edge      eth0-rx-0
 50:          0          0          0          0          0          0       1684          0   PCI-MSI-edge      eth0-tx-0
 51:          0          0          0          0          0          0          0          2   PCI-MSI-edge      eth0
NMI:          8          2          2          2          1          2          1         49   Non-maskable interrupts
LOC:         36         31         29         26         21       7611        886       1390   Local timer interrupts
SPU:          0          0          0          0          0          0          0          0   Spurious interrupts
PMI:          8          2          2          2          1          2          1         49   Performance monitoring interrupts
IWI:          0          0          0          1          1          0          1          0   IRQ work interrupts
RTR:          7          0          0          0          0          0          0          0   APIC ICR read retries
RES:        473       1027       1530        739       1532       3567       1529       1811   Rescheduling interrupts
CAL:        846       1012       1122       1047        984       1008       1064       1145   Function call interrupts
TLB:          2          7          5          3         12         15         10          6   TLB shootdowns
TRM:          0          0          0          0          0          0          0          0   Thermal event interrupts
THR:          0          0          0          0          0          0          0          0   Threshold APIC interrupts
MCE:          0          0          0          0          0          0          0          0   Machine check exceptions
MCP:          4          4          4          4          4          4          4          4   Machine check polls
THR:          0          0          0          0          0          0          0          0   Hypervisor callback interrupts
ERR:          0
MIS:          0

观察到定时器中断主要在CPU3上触发。

是否可以将定时器中断移至CPU0?

1 个答案:

答案 0 :(得分:4)

概念的名称是IRQ SMP affinity

可以通过在/proc/irq/<IRQ_NUMBER>/smp_affinity中设置关联掩码或在/proc/irq/<IRQ_NUMBER>/smp_affinity_list中设置关联列表来设置IRQ的 smp_affinity
亲和性掩码是位字段,其中每个位表示核心,允许IRQ在对应于位集的核心上提供。

命令

echo 1 > /proc/irq/0/smp_affinity

以root身份执行将IRQ0固定到CPU0 条件是强制性的,因为设置IRQ的亲和性受一组先决条件的约束,该列表包括:支持重定向表的中断控制器(如IO-APIC),关联掩码必须包含至少一个活动必须启用CPU,IRQ亲缘关系must not be managed by the kernel和功能。

在我的虚拟化Debian 8系统中,我无法设置IRQ0的亲和力,因 EIO 错误而失败。
我也无法找到确切的原因 如果您愿意深入了解Linux源代码,可以从write_irq_affinity in proc.c

开始