保证不同的网卡中断均匀分散在不同的CPU核上,尽量保证各个中断不互相抢占CPU。
此处以使用网卡enp125s0f0为例提供绑核脚本。假设enp125s0f0的网卡队列数量为16,将该网卡的中断绑到0~15号核上,其他网卡同理绑到其他核上。
网卡队列的数量可以使用ethtool -l enp125s0f0命令查看。
1 2 3 4 5 6 7 8 9 10 11 | cpulist1=(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) intlist1=`cat /proc/interrupts | grep enp125s0f0 | awk -F ':' '{print $1}'` j=0 cpuNum=${#cpulist1[@]} for i in $intlist1 do echo "bind int $i to cpu ${cpulist1[j]}" echo ${cpulist1[j]} > /proc/irq/$i/smp_affinity_list ((j++)) ((j=j%cpuNum)) done |