是否可以更改发生哪些内核定时器中断?
问题描述:
在我的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?
答
概念的名称是IRQ SMP affinity。
有可能通过设置/proc/irq/<IRQ_NUMBER>/smp_affinity
亲和力掩码或/proc/irq/<IRQ_NUMBER>/smp_affinity_list
密切关系列表中设置的IRQ的smp_affinity。
亲和掩码是一个位字段,其中每个位代表一个核心,允许IRQ在对应于设置的位的核心上服务。
作为根应该销执行IRQ0到CPU0命令
echo 1 > /proc/irq/0/smp_affinity
。
条件是强制性的,因为设置IRQ的亲缘性受制于一系列先决条件,该列表包括:支持重定向表的中断控制器(如IO-APIC),亲和性掩码必须至少包含一个活动CPU, IRQ亲和力must not be managed by the kernel和该功能必须启用。
在我的虚拟化Debian 8系统中,我无法设置IRQ0的关联性,因为出现错误而导致失败。
我也无法追查确切的原因。
如果你愿意潜入Linux源代码,你可以从write_irq_affinity in proc.c
为什么你想要这样做? – tangrs
减少对核心3的干扰。 – merlin2011
这听起来像是[X-Y问题](http://xyproblem.info/)。你真的想达到什么目的? – tangrs