1
2
3
4
|
ethtool
-K eth0 gro off
ethtool
-K eth1 gro off
ethtool
-K eth2 gro off
ethtool
-K eth3 gro off
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
service irqbalance stop
chkconfig irqbalance off
# 查看网卡中断号
grep
ethx
/proc/interrupts
# 分配到每颗颗CPU核上
cat
/proc/irq/
{84,85,86,87,88,89,90,91,92,93}
/smp_affinity
echo
1 >
/proc/irq/84/smp_affinity
echo
2 >
/proc/irq/85/smp_affinity
echo
4 >
/proc/irq/86/smp_affinity
echo
8 >
/proc/irq/87/smp_affinity
echo
10 >
/proc/irq/88/smp_affinity
echo
20 >
/proc/irq/89/smp_affinity
echo
40 >
/proc/irq/90/smp_affinity
echo
80 >
/proc/irq/91/smp_affinity
echo
100 >
/proc/irq/92/smp_affinity
echo
200 >
/proc/irq/93/smp_affinity
PS:smp_affinity的值可以用下面脚本算哈,此脚本来自:http:
//rfyiamcool
.blog.51cto.com
/1030776/1335700
#!/bin/bash
#
echo
"统计cpu的16进制"
[ $
# -ne 1 ] && echo ‘$1 is Cpu core number’ && exit 1
CCN=$1
echo
“Print eth0 affinity”
for
((i=0; i<${CCN}; i++))
do
echo
==============================
echo
"Cpu Core $i is affinity"
((affinity=(1<
echo
"obase=16;${affinity}"
|
bc
done
使用方法:sh 脚本名字 空格 cpu核数
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# Enable RPS (Receive Packet Steering)
rfc=4096
cc=$(
grep
-c processor
/proc/cpuinfo
)
rsfe=$(
echo
$cc*$rfc |
bc
)
sysctl -w net.core.rps_sock_flow_entries=$rsfe
for
fileRps
in
$(
ls
/sys/class/net/eth
*
/queues/rx-
*
/rps_cpus
)
do
echo
fff > $fileRps
done
for
fileRfc
in
$(
ls
/sys/class/net/eth
*
/queues/rx-
*
/rps_flow_cnt
)
do
echo
$rfc > $fileRfc
done
tail
/sys/class/net/eth
*
/queues/rx-
*/{rps_cpus,rps_flow_cnt}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
vi
/opt/sbin/change_irq
.sh
#!/bin/bash
ethtool
-K eth0 gro off
ethtool
-K eth1 gro off
ethtool
-K eth2 gro off
ethtool
-K eth3 gro off
service irqbalance stop
chkconfig irqbalance off
cat
/proc/irq/
{84,85,86,87,88,89,90,91,92,93}
/smp_affinity
echo
1 >
/proc/irq/84/smp_affinity
echo
2 >
/proc/irq/85/smp_affinity
echo
4 >
/proc/irq/86/smp_affinity
echo
8 >
/proc/irq/87/smp_affinity
echo
10 >
/proc/irq/88/smp_affinity
echo
20 >
/proc/irq/89/smp_affinity
echo
40 >
/proc/irq/90/smp_affinity
echo
80 >
/proc/irq/91/smp_affinity
echo
100 >
/proc/irq/92/smp_affinity
echo
200 >
/proc/irq/93/smp_affinity
# Enable RPS (Receive Packet Steering)
rfc=4096
cc=$(
grep
-c processor
/proc/cpuinfo
)
rsfe=$(
echo
$cc*$rfc |
bc
)
sysctl -w net.core.rps_sock_flow_entries=$rsfe
for
fileRps
in
$(
ls
/sys/class/net/eth
*
/queues/rx-
*
/rps_cpus
)
do
echo
fff > $fileRps
done
for
fileRfc
in
$(
ls
/sys/class/net/eth
*
/queues/rx-
*
/rps_flow_cnt
)
do
echo
$rfc > $fileRfc
done
tail
/sys/class/net/eth
*
/queues/rx-
*/{rps_cpus,rps_flow_cnt}
chmod
+x
/opt/sbin/change_irq
.sh
echo
"/opt/sbin/change_irq.sh"
>>
/etc/rc
.
local
PS:记得修改网卡中断号,别直接拿来用哦
|