为32个内核设置接收数据包控制(RPS)

时间:2015-06-03 11:15:05

标签: linux-kernel multiprocessing

我不确定是否使用了正确的命令来设置32核机器的RPS。这是我使用的:echo 1f> / SYS /类/净/ eth0的/队列/ RX-0 / rps_cpus

应该是" echo 1f ..."或者" echo f ..."或其他什么?

5 个答案:

答案 0 :(得分:5)

Pinterest工程师只是say

echo f > /sys/class/net/eth0/queues/rx-0/rps_cpus

但还有另一个their talk

echo ffff > /sys/class/net/eth0/queues/rx-0/rps_cpus

无法从内核的角度看到实际差异,但您可以尝试两者

答案 1 :(得分:0)

从<{>红帽企业Linux 7 的Performance Tuning Guide转载:

  

rps_cpus文件使用逗号分隔的CPU位图。因此,到   允许CPU处理接收队列的中断   接口,将位图中的位置值设置为1.对于   例如,要处理CPU 0,1,2和3的中断,请设置该值   rps_cpus到00001111(1 + 2 + 4 + 8)或f(十六进制值为   15)。

所以对于四核cpu ...

echo ff+ > /sys/class/net/eth0/queues/rx-0/rps_cpus

和cpus的&gt; 4核......

if trim.contains("0"){
        print("contaim 0")
        let button1 = UIButton(frame: CGRect(x: 0, y: 0, width: 60, height: 20))
        button1.setTitleColor(UIColor.blackColor(), forState: .Normal)
        button1.setTitle("No", forState: .Normal)
        button1.setImage(UIImage(named: "checkbox untick.png")!, forState: .Normal)
        button1.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
        myStackview.addSubview(button1)
    }
    if trim.contains("1") {
        print("contaim 1")

        let button2 = UIButton(frame: CGRect(x: 90, y: 0, width: 60, height: 20))
            button2.setTitleColor(UIColor.blackColor(), forState: .Normal)
            button2.setTitle("Less", forState: .Normal)
            button2.setImage(UIImage(named: "checkbox untick.png")!, forState: .Normal)
            button2.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
            myStackview.addSubview(button2)


    }
    if trim.contains("2"){
        print("contaim 2")

        let button3 = UIButton(frame: CGRect(x: 150, y: 0, width: 60, height: 20))
        button3.setTitleColor(UIColor.blackColor(), forState: .Normal)

        button3.setTitle("Half", forState: .Normal)
        button3.setImage(UIImage(named: "checkbox untick.png")!, forState: .Normal)
        button3.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
        myStackview.addSubview(button3)
    }
    if trim.contains("3"){
        print("contaim 3")
        let button4 = UIButton(frame: CGRect(x: 210, y: 0, width: 60, height: 20))

        button4.setTitleColor(UIColor.blackColor(), forState: .Normal)

        button4.setTitle("On", forState: .Normal)
        button4.setImage(UIImage(named: "checkbox untick.png")!, forState: .Normal)
        button4.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
        myStackview.addSubview(button4)
    }
    if trim.contains("4"){
        print("contaim 4")
        let button5 = UIButton(frame: CGRect(x: 270, y: 0, width: 60, height: 20))

        button5.setTitleColor(UIColor.blackColor(), forState: .Normal)

        button5.setTitle("With", forState: .Normal)
        button5.setImage(UIImage(named: "checkbox untick.png")!, forState: .Normal)
        button5.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
        myStackview.addSubview(button5)
    }
    if trim.contains("5"){
        print("contaim 5")
        let button6 = UIButton(frame: CGRect(x: 310, y: 0, width: 60, height: 20))

        button6.setTitleColor(UIColor.blackColor(), forState: .Normal)

        button6.setTitle("On Burger", forState: .Normal)
        button6.setImage(UIImage(named: "checkbox untick.png")!, forState: .Normal)
        button6.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
        myStackview.addSubview(button6)
    }
    if trim.contains("6"){
        print("contaim 6")
        let button7 = UIButton(frame: CGRect(x: 370, y: 0, width: 60, height: 20))

        button7.setTitleColor(UIColor.blackColor(), forState: .Normal)

        button7.setTitle("On Chips", forState: .Normal)
        button7.setImage(UIImage(named: "checkbox untick.png")!, forState: .Normal)
        button7.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
        myStackview.addSubview(button7)
    }

其中ff +为正则表达式,用于为每组额外的4个核心附加额外的f(s)

答案 2 :(得分:0)

我也见过 <flags>,<flags>,<flags> 表示法。我的机器拒绝接受。 除此之外,我还看到在重新启动后,这些值被重置为 0。我通过定义启用和启动将值更正为 ff 的服务来绕过它(这正是我想要的)。

答案 3 :(得分:-1)

您可能想尝试使用二进制计算器和nproc:

res.div(res.min(1), 0)

            wen       maxu       pir1       pir2       pir3       pir4
10     2.041111   2.799885   1.000000   1.032221   1.432887   1.174196
30     1.544264   2.417550   1.000000   1.043218   1.336503   1.003284
100    1.037501   1.843029   1.000000   1.066310   1.319942   1.191763
300    1.000000   2.373917   1.726667   2.009198   2.193276   2.424844
1000   1.000000   3.962928   3.764808   3.932539   4.099261   4.971527
3000   1.000000   6.250289   6.311701   6.740862   6.258989   7.791234
10000  1.000000   9.014925  10.110949  10.964482  10.347168  13.407998
30000  1.000000  10.410604  11.682759  13.113974  11.877862  16.000993

该公式将为任意数量的核心配置RPS。

答案 4 :(得分:-2)

我用过这个

# Input
NIC_NAME="em1";
if [[ "$1" != "" ]]; then
    NIC_NAME="$1";
fi

# Tuna Install 
#echo "`date '+%Y-%m-%d %H:%M:%S'` - Install numactl" ;
#yum install -y tuna ;

# Tuna Config
echo "`date '+%Y-%m-%d %H:%M:%S'` - Tuna Info: " ;
tuna --irqs=${NIC_NAME}-\* --cpus=0-3 --move --spread ;
tuna --irqs=${NIC_NAME}-txrx-\* --cpus=0-3 --move --spread ;
tuna --irqs=${NIC_NAME}-tx-\* --cpus=0-3 --move --spread ;
tuna --irqs=${NIC_NAME}-rx-\* --cpus=0-3 --move --spread ;
tuna --irqs=${NIC_NAME}-\* --show_irqs ;

# Install
#echo "`date '+%Y-%m-%d %H:%M:%S'` - Install numactl" ;
#yum install -y numactl ;
#echo "";

# Numa Info
echo "`date '+%Y-%m-%d %H:%M:%S'` - Numa Info: " ;
numactl --hardware | grep "^node . cpus" ;
echo "";

# Numa Mask
echo "`date '+%Y-%m-%d %H:%M:%S'` - Numa Mask: " ;
NUMA_COUNT=$(numactl --hardware | grep "^node . cpus\:" | wc -l);
NUMA_MASK=("");
i=0;
while [ $i -lt ${NUMA_COUNT} ]; do
    NUMA_MASK[$i]=$(numactl --hardware | grep "^node $i cpus\:" | awk -F':' '{ print $2}' | sed 's/ /\+2\^/g' | awk '{print "obase=16;0" $0}' | bc | rev | sed -e 's/\([0-F][0-F][0-F][0-F][0-F][0-F][0-F][0-F]\)/\1,/g' | rev);
    echo " NUMA_MASK[$i]: ${NUMA_MASK[$i]}";
    let i++;
done
echo "";

# Set RPS/XPS
echo "`date '+%Y-%m-%d %H:%M:%S'` - Set RPS/XPS: " ;
QUEUE_RX_COUNT=0;
QUEUE_TX_COUNT=0;
i=0;
while [ $i -lt 16 ]; do
    let NUMA_ID=(i % NUMA_COUNT);
    QUEUE_RX_RPS="/sys/class/net/${NIC_NAME}/queues/rx-$i/rps_cpus";
    QUEUE_TX_XPS="/sys/class/net/${NIC_NAME}/queues/tx-$i/xps_cpus";
    if [[ -e "${QUEUE_RX_RPS}" && "${NUMA_MASK[$NUMA_ID]}" != "" ]]; then
        echo ${NUMA_MASK[$NUMA_ID]} > "${QUEUE_RX_RPS}" ;
        NUMA_MASK_ID=$(cat "${QUEUE_RX_RPS}");
        echo " ${QUEUE_RX_RPS}: $NUMA_MASK_ID" ;
        let QUEUE_RX_COUNT++;
    fi;
    if [[ -e "${QUEUE_TX_XPS}" && "${NUMA_MASK[$NUMA_ID]}" != "" ]]; then
        echo ${NUMA_MASK[$NUMA_ID]} > "${QUEUE_TX_XPS}" ;
        NUMA_MASK_ID=$(cat "${QUEUE_TX_XPS}");
        echo " ${QUEUE_TX_XPS}: $NUMA_MASK_ID" ;
        let QUEUE_TX_COUNT++;
    fi;
    let i++;
done
echo "";

# Set Sock Rps Flow
echo "`date '+%Y-%m-%d %H:%M:%S'` - Set Sock Rps Flow: " ;
SOCK_RX_FLOW_ENTRIES="/proc/sys/net/core/rps_sock_flow_entries" ;
SOCK_RX_FLOW_COUNT=32768 ;
echo "${SOCK_RX_FLOW_COUNT}" > ${SOCK_RX_FLOW_ENTRIES} ;
SOCK_RX_FLOW_COUNT=$(cat ${SOCK_RX_FLOW_ENTRIES}) ;
echo " ${SOCK_RX_FLOW_ENTRIES}: ${SOCK_RX_FLOW_COUNT}" ;
echo "";

# Set Queue Rps Flow
echo "`date '+%Y-%m-%d %H:%M:%S'` - Set Queue Rps Flow: " ;
let SET_QUEUE_RX_FLOW_COUNT=(SOCK_RX_FLOW_COUNT / QUEUE_RX_COUNT);
i=0;
while [ $i -lt 16 ]; do
    QUEUE_RX_FLOW="/sys/class/net/${NIC_NAME}/queues/rx-$i/rps_flow_cnt";
    if [[ -e "${QUEUE_RX_FLOW}" && ${SET_QUEUE_RX_FLOW_COUNT} -gt 0 ]]; then
        echo ${SET_QUEUE_RX_FLOW_COUNT} > "${QUEUE_RX_FLOW}" ;
        GET_QUEUE_RX_FLOW_COUNT=$(cat "${QUEUE_RX_FLOW}");
        echo " ${QUEUE_RX_FLOW}: ${GET_QUEUE_RX_FLOW_COUNT}" ;
    fi;
    let i++;
done
echo "";