(1) 中斷的配置
[[email protected] ~]#/etc/init.d/irq_balancer status
Checking for service irqbalance running
--- /etc/init.d/irq_balancer 是linux下用于均分軟中斷的背景服務,在手工配置設定軟中斷前需要停止該服務。
[[email protected] ~]#cat /proc/interrupts
73: 105588723 84012028 2264178 1534228 1555321 1534136 1555345 1534132 PCI-MSI-edge eth0
---- 找到eth0對應中斷信号為73
[[email protected] ~]#cat /proc/irq/73/smp_affinity
ff
--- ff表示73号中斷可以配置設定到所有processor上。
echo 03 > /proc/irq/73/smp_affinity
--将eth0綁定到CPU0/CPU1
(2) 多隊列網卡
在支援多隊列網卡的系統,檢視/proc/interrupts可以看到同一個網卡支援多個中斷:
111: 0 1 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge eth2
112: 1 0 3426776 0 0 0 0 0 0 0 IR-PCI-MSI-edge eth2-TxRx-0
113: 1 0 0 708047 0 0 0 0 0 0 IR-PCI-MSI-edge eth2-TxRx-1
114: 1 0 0 0 601650 0 0 0 0 0 IR-PCI-MSI-edge eth2-TxRx-2
115: 1 0 0 0 0 755997 0 0 0 0 IR-PCI-MSI-edge eth2-TxRx-3
116: 1 0 0 0 0 0 573019 0 0 0 IR-PCI-MSI-edge eth2-TxRx-4
117: 1 0 0 0 0 0 0 964420 0 0 IR-PCI-MSI-edge eth2-TxRx-5
118: 1 0 0 0 0 0 0 0716379 0 IR-PCI-MSI-edge eth2-TxRx-6
119: 1 0 0 0 0 0 0 0 0 286875 IR-PCI-MSI-edge eth2-TxRx-7
111~119都是eth2網卡的中斷号,1個硬中斷,8個收發隊列中斷,這樣8個收發隊列可以通過smp_affinity配置到不同的cpu核上,讓不同核并發處理收發隊列資料。
(3) 軟體實作多隊列
2.6.35 以後的核心版本都支援google的RPS/RFS更新檔,需要手工開啟。
echo ff > /sys/class/net/eth0/queues/rx-0/rps_cpus
---配置單網卡配置設定到所有cpu核上。
echo 4096 > /sys/class/net/eth0/queues/rx-0/rps_flow_cnt
配置單個每個虛拟隊列支援的流數量,
echo 32768 > /proc/sys/net/core/rps_sock_flow_entries
---配置全局資料流表(rps_sock_flow_table)的總數 = 4096 * 8(8個processor)