6.多队列网卡识别
#lspci -vvv
ethernet controller的条目内容,如果有msi-x && enable+ && tabsize > 1,则该网卡是多队列网卡,如图4.4所示。
图4.4 lspci内容
message signaled interrupts(msi)是pci规范的一个实现,可以突破cpu 256条interrupt的限制,使每个设备具有多个中断线变成可能,多队列网卡驱动给每个queue申请了msi。msi-x是msi数组,enable+指使能,tabsize是数组大小。
# setting up irq affinity according to /proc/interrupts
# 2008-11-25 robert olsson
# 2009-02-19 updated by jesse brandeburg
#
# > dave miller:
# (to get consistent naming in /proc/interrups)
# i would suggest that people use something like:
# char buf[ifnamsiz+6];
#
# sprintf(buf, "%s-%s-%d",
# netdev->name,
# (rx_interrupt ? "rx" : "tx"),
# queue->index);
#
# assuming a device with two rx and tx queues.
# this script will assign:
#
# eth0-rx-0 cpu0
# eth0-rx-1 cpu1
# eth0-tx-0 cpu0
# eth0-tx-1 cpu1
#
set_affinity()
{
mask=$((1<<$vec))
printf "%s mask=%x for /proc/irq/%d/smp_affinity\n" $dev $mask $irq
printf "%x" $mask > /proc/irq/$irq/smp_affinity
#echo $dev mask=$mask for /proc/irq/$irq/smp_affinity
#echo $mask > /proc/irq/$irq/smp_affinity
}
if [ "$1" = "" ] ; then
echo "description:"
echo " this script attempts to bind each queue of a multi-queue nic"
echo " to the same numbered core, ie tx0|rx0 --> cpu0, tx1|rx1 --> cpu1"
echo "usage:"
echo " $0 eth0 [eth1 eth2 eth3]"
fi
# check for irqbalance running
irqbalance_on=`ps ax | grep -v grep | grep -q irqbalance; echo $?`
if [ "$irqbalance_on" == "0" ] ; then
echo " warning: irqbalance is running and will"
echo " likely override this script's affinitization."
echo " please stop the irqbalance service and/or execute"
echo " 'killall irqbalance'"
fi
#
# set up the desired devices.
#
for dev in $*
do
for dir in rx tx txrx
do
max=`grep $dev-$dir /proc/interrupts | wc -l`
if [ "$max" == "0" ] ; then
max=`egrep -i "$dev:.*$dir" /proc/interrupts | wc -l`
fi
if [ "$max" == "0" ] ; then
echo no $dir vectors found on $dev
continue
#exit 1
fi
for vec in `seq 0 1 $max`
do
irq=`cat /proc/interrupts | grep -i $dev-$dir-$vec"$" | cut -d: -f1 | sed "s/ //g"`
if [ -n "$irq" ]; then
set_affinity
else
irq=`cat /proc/interrupts | egrep -i $dev:v$vec-$dir"$" | cut -d: -f1 | sed "s/ //g"`
if [ -n "$irq" ]; then
set_affinity
fi
fi
done
done
done
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论