Last active
February 24, 2016 08:21
-
-
Save netmarkjp/4bfc10295ba5193e4039 to your computer and use it in GitHub Desktop.
enable rps/rfs on centos6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VAL_RPS_FLOW_CNT="32768" | |
VAL_RPS_SOCK_FLOW_ENTRIES="32768" | |
PROC_NUM=$(cat /proc/cpuinfo | grep -c ^processor) | |
VAL_RPS_CPUS=0 | |
if [ ${PROC_NUM:?} -eq 1 ] | |
then | |
echo "RPS/RFS disabled because of single cpu." | |
exit 0 | |
elif [ ${PROC_NUM:?} -le 3 ] | |
then | |
## 11(bit) = 3(0x3) | |
VAL_RPS_CPUS=3 | |
else | |
## 1111(bit) = f(0xf) | |
VAL_RPS_CPUS="f" | |
fi | |
## RPS | |
FILES=$(ls /sys/class/net/*/queues/rx-*/rps_cpus) | |
for FILE in ${FILES} | |
do | |
echo "${VAL_RPS_CPUS:?}" > "${FILE:?}" | |
done | |
## RFS | |
FILES=$(ls /sys/class/net/*/queues/rx-*/rps_flow_cnt) | |
for FILE in ${FILES} | |
do | |
echo "${VAL_RPS_FLOW_CNT:?}" > "${FILE:?}" | |
done | |
sysctl -q -w net.core.rps_sock_flow_entries=${VAL_RPS_SOCK_FLOW_ENTRIES:?} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
much smart way to persist settings are...
set attibute in /etc/udev/rules.d/70-persistent-net.rules
set value in /etc/sysctl.conf
and reboot system.