Skip to content

Instantly share code, notes, and snippets.

@netmarkjp
Last active February 24, 2016 08:21
Show Gist options
  • Save netmarkjp/4bfc10295ba5193e4039 to your computer and use it in GitHub Desktop.
Save netmarkjp/4bfc10295ba5193e4039 to your computer and use it in GitHub Desktop.
enable rps/rfs on centos6
#!/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:?}
@netmarkjp
Copy link
Author

much smart way to persist settings are...

set attibute in /etc/udev/rules.d/70-persistent-net.rules

ATTR{queues/rx-0/rps_cpus}="f", ATTR{queues/rx-0/rps_flow_cnt}="32768",

set value in /etc/sysctl.conf

net.core.rps_sock_flow_entries = 32768

and reboot system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment