| 1 |
.. include:: ../../disclaimer-zh_CN.rst |
| 2 |
|
| 3 |
:Original: Documentation/core-api/irq/irq-affinity.rst |
| 4 |
|
| 5 |
:翻译: |
| 6 |
|
| 7 |
司延腾 Yanteng Si <[email protected]> |
| 8 |
|
| 9 |
.. _cn_irq-affinity.rst: |
| 10 |
|
| 11 |
============== |
| 12 |
SMP IRQ 亲和性 |
| 13 |
============== |
| 14 |
|
| 15 |
变更记录: |
| 16 |
- 作者:最初由Ingo Molnar <[email protected]>开始撰写 |
| 17 |
- 后期更新维护: Max Krasnyansky <[email protected]> |
| 18 |
|
| 19 |
|
| 20 |
/proc/irq/IRQ#/smp_affinity和/proc/irq/IRQ#/smp_affinity_list指定了哪些CPU能 |
| 21 |
够关联到一个给定的IRQ源,这两个文件包含了这些指定cpu的cpu位掩码(smp_affinity)和cpu列 |
| 22 |
表(smp_affinity_list)。它不允许关闭所有CPU, 同时如果IRQ控制器不支持中断请求亲和 |
| 23 |
(IRQ affinity),那么所有cpu的默认值将保持不变(即关联到所有CPU). |
| 24 |
|
| 25 |
/proc/irq/default_smp_affinity指明了适用于所有非激活IRQ的默认亲和性掩码。一旦IRQ被 |
| 26 |
分配/激活,它的亲和位掩码将被设置为默认掩码。然后可以如上所述改变它。默认掩码是0xffffffff。 |
| 27 |
|
| 28 |
下面是一个先将IRQ44(eth1)限制在CPU0-3上,然后限制在CPU4-7上的例子(这是一个8CPU的SMP box) |
| 29 |
|
| 30 |
:: |
| 31 |
|
| 32 |
[root@moon 44]# cd /proc/irq/44 |
| 33 |
[root@moon 44]# cat smp_affinity |
| 34 |
ffffffff |
| 35 |
|
| 36 |
[root@moon 44]# echo 0f > smp_affinity |
| 37 |
[root@moon 44]# cat smp_affinity |
| 38 |
0000000f |
| 39 |
[root@moon 44]# ping -f h |
| 40 |
PING hell (195.4.7.3): 56 data bytes |
| 41 |
... |
| 42 |
--- hell ping statistics --- |
| 43 |
6029 packets transmitted, 6027 packets received, 0% packet loss |
| 44 |
round-trip min/avg/max = 0.1/0.1/0.4 ms |
| 45 |
[root@moon 44]# cat /proc/interrupts | grep 'CPU\|44:' |
| 46 |
CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 |
| 47 |
44: 1068 1785 1785 1783 0 0 0 0 IO-APIC-level eth1 |
| 48 |
|
| 49 |
从上面一行可以看出,IRQ44只传递给前四个处理器(0-3)。 |
| 50 |
现在让我们把这个IRQ限制在CPU(4-7)。 |
| 51 |
|
| 52 |
:: |
| 53 |
|
| 54 |
[root@moon 44]# echo f0 > smp_affinity |
| 55 |
[root@moon 44]# cat smp_affinity |
| 56 |
000000f0 |
| 57 |
[root@moon 44]# ping -f h |
| 58 |
PING hell (195.4.7.3): 56 data bytes |
| 59 |
.. |
| 60 |
--- hell ping statistics --- |
| 61 |
2779 packets transmitted, 2777 packets received, 0% packet loss |
| 62 |
round-trip min/avg/max = 0.1/0.5/585.4 ms |
| 63 |
[root@moon 44]# cat /proc/interrupts | 'CPU\|44:' |
| 64 |
CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 |
| 65 |
44: 1068 1785 1785 1783 1784 1069 1070 1069 IO-APIC-level eth1 |
| 66 |
|
| 67 |
这次IRQ44只传递给最后四个处理器。 |
| 68 |
即CPU0-3的计数器没有变化。 |
| 69 |
|
| 70 |
下面是一个将相同的irq(44)限制在cpus 1024到1031的例子 |
| 71 |
|
| 72 |
:: |
| 73 |
|
| 74 |
[root@moon 44]# echo 1024-1031 > smp_affinity_list |
| 75 |
[root@moon 44]# cat smp_affinity_list |
| 76 |
1024-1031 |
| 77 |
|
| 78 |
需要注意的是,如果要用位掩码来做这件事,就需要32个为0的位掩码来追踪其相关的一个。 |