博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
网卡绑定中断的脚本(深度实践KVM)
阅读量:4055 次
发布时间:2019-05-25

本文共 2258 字,大约阅读时间需要 7 分钟。

# 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(){	if [ $VEC -ge 32 ]	then		MASK_FILL=""		MASK_ZERO="00000000"		let "IDX = $VEC / 32"		for ((i=1; i<=$IDX;i++))		do			MASK_FILL="${MASK_FILL},${MASK_ZERO}"		done		let "VEC -= 32 * $IDX"		MASK_TMP=$((1<<$VEC))		MASK=`printf "%X%s" $MASK_TMP $MASK_FILL`	else		MASK_TMP=$((1<<$VEC))		MASK=`printf "%X" $MASK_TMP`	fi    printf "%s mask=%s for /proc/irq/%d/smp_affinity楼n" $DEV $MASK $IRQ    printf "%s" $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 runningIRQBALANCE_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     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  donedone

 

转载地址:http://vdqci.baihongyu.com/

你可能感兴趣的文章
如何用好碎片化时间,让思维更有效率?
查看>>
No.174 - LeetCode1305 - 合并两个搜索树
查看>>
No.175 - LeetCode1306
查看>>
No.176 - LeetCode1309
查看>>
No.182 - LeetCode1325 - C指针的魅力
查看>>
mysql:sql alter database修改数据库字符集
查看>>
mysql:sql truncate (清除表数据)
查看>>
yuv to rgb 转换失败呀。天呀。谁来帮帮我呀。
查看>>
yuv420 format
查看>>
yuv420 还原为RGB图像
查看>>
LED恒流驱动芯片
查看>>
驱动TFT要SDRAM做为显示缓存
查看>>
使用file查看可执行文件的平台性,x86 or arm ?
查看>>
qt 创建异形窗体
查看>>
简单Linux C线程池
查看>>
内存池
查看>>
gstreamer相关工具集合
查看>>
RS232 四入四出模块控制代码
查看>>
linux 驱动开发 头文件
查看>>
container_of()传入结构体中的成员,返回该结构体的首地址
查看>>