linux – ethernet smp_affinity vs / proc / interrupts vs / sys / class / net / ethX / device

前端之家收集整理的这篇文章主要介绍了linux – ethernet smp_affinity vs / proc / interrupts vs / sys / class / net / ethX / device前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的目标是配置我们的CentOS(“免费”RHEL)5.x服务器,用于自定义低延迟网络程序.我想尝试将以太网NIC中断处理绑定到程​​序运行的同一cpu(希望提高缓存利用率).此过程的第一步是确定NIC的IRQ.

以下是一台服务器上/ proc / interrupts的内容(请注意,为简洁起见,我删除cpu 2到14):

cpu0       cpu1       cpu15
  0:  600299726          0          0    IO-APIC-edge  timer
  1:          3          0          0    IO-APIC-edge  i8042
  8:          1          0          0    IO-APIC-edge  rtc
  9:          0          0          0   IO-APIC-level  acpi
 12:          4          0          0    IO-APIC-edge  i8042
 50:          0          0          0   IO-APIC-level  uhci_hcd:usb6,uhci_hcd:usb8
 58:       6644      25103          0   IO-APIC-level  ioc0
 66:          0          0          0   IO-APIC-level  ata_piix
 74:        221     533830          0   IO-APIC-level  ata_piix
 98:         35          0    2902361       PCI-MSI-X  eth1-0
106:         61         11       3841       PCI-MSI-X  eth1-1
114:         28          0      61452       PCI-MSI-X  eth1-2
122:         24       1586         22       PCI-MSI-X  eth1-3
130:       2912          0        337       PCI-MSI-X  eth1-4
138:         21          0         28       PCI-MSI-X  eth1-5
146:         21          0         56       PCI-MSI-X  eth1-6
154:         34          1          1       PCI-MSI-X  eth1-7
209:         23          0          0   IO-APIC-level  ehci_hcd:usb1
217:          0          0          0   IO-APIC-level  ehci_hcd:usb2,uhci_hcd:usb5,uhci_hcd:usb7
225:          0          0          0   IO-APIC-level  uhci_hcd:usb3
233:          0          0          0   IO-APIC-level  uhci_hcd:usb4
NMI:       7615       2989       2931
LOC:  600328144  600328099  600327086
ERR:          0
MIS:          0

为什么“eth1”的形式为“eth1-X”有多个条目?

此外,“/ sys / class / net / eth1 / device / irq”的内容为“90”​​.但是上面的中断列表中没有90.

所以让我说我只看“eth1-0”,它是IRQ 98./ proc / irq / 98 / smp_affinity的内容是:

00000000,00000000,000
  

  

This format displays each 32-bit word in hexadecimal (using ASCII characters "0" - "9" and "a" - "f"); words are filled with leading zeros,if required. For masks longer than one word,a comma separator is used between words. Words are displayed in big-endian order,which has the most significant bit first. The hex digits within a word are also in big-endian order.

The number of 32-bit words displayed is the minimum number needed to display all bits of the bitmask,based on the size of the bitmask.

Examples of the Mask Format:

06002

A mask with bits 0,1,2,4,8,16,32,and 64 set displays as:

06003

The first "1" is for bit 64,the second for bit 32,the third for bit 16,the fourth for bit 8,the fifth for bit 4,and the "7" is for bits 2,and 0.

这是一个数字列表,而不仅仅是一个数字.

那么如何设置eth1的smp_affinity呢?

我找到的在线示例和文档都没有提到这样的情况;他们总是在/ proc / interrupts中只有一个“ethX”条目;指示的中断与/ sys / class / net / ethX / device / irq匹配;并且/ proc / irq / N / smp_affinity中只有一个数字.

FWIW,我要补充一点,这个应用程序对延迟非常敏感.到了我们禁用C状态和处理器频率缩放的程度(因为这些功能会导致过多的延迟).微秒在这里有所作为.

编辑:我偶然发现了以下网页
http://www.kernel.org/doc/man-pages/online/pages/man7/cpuset.7.html
虽然它是关于cpuset的,但它有一个标题为“Mask Format”的部分,我假设它与我在/ proc / irq // smp_affinity文件中看到的相同.引用:

This format displays each 32-bit word in hexadecimal (using ASCII
characters “0” – “9” and “a” – “f”); words are filled with leading zeros,
if required. For masks longer than one word,a comma separator is used
between words. Words are displayed in big-endian order,which has the
most significant bit first. The hex digits within a word are also in
big-endian order.

The number of 32-bit words displayed is the minimum number needed to
display all bits of the bitmask,based on the size of the bitmask.

Examples of the Mask Format:

06002

A mask with bits 0,and 64 set displays as:

06003

The first “1” is for bit 64,
the fourth for bit 8,and the “7” is for bits 2,
and 0.

解决方法

Why are there multiple entries for “eth1” in the form of “eth1-X”?

因为有多个tx / rx队列.这些队列通常是(本地地址,端口,远程地址,端口)和其他一些东西的哈希.抑制多个队列可能会更容易假设您的流量来源很少,那么使您的应用程序更具确定性.或者你可以查找算法并避免短暂的端口,如果这更容易.

猜你在找的Linux相关文章