Tuning Receive Steering Packet (RPS) for 32 Cores

I'm not sure if I used the correct commands to install RPS for a 32 core machine. This is what I used: echo 1f> / sys / class / net / eth0 / queues / rx-0 / rps_cpus

Should it be "echo 1f ..." or "echo f ..." or something else?

+3


source to share


4 answers


Pinterest engineers just say :

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

      

But there is also their conversation :



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

      

Can't see the actual difference from a kernel perspective, but you can try both

+2


source


Replay Performance Guide for Red Hat Enterprise Linux 7 :

The rps_cpus files use comma-delimited CPU bitmaps. Therefore, to enable the processor to process interrupts for the receive queue on the interface, set the value of their positions in the bitmap to 1. For For example, to process interrupts with CPUs 0, 1, 2 and 3, set a value from rps_cpus to 00001111 (1 + 2 + 4 + 8) or f (hexadecimal value for 15).

So, for a quad core processor ...

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

      



and for cpus s> 4 cores ...

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

      

where ff + is a regex to add extra f (s) for each set of extra 4 cores

0


source


You might want to try using a binary calculator and nproc:

echo "obase=16;2^$(nproc)-1" | bc > /sys/class/net/eth0/queues/rx-0/rps_cpus

      

This formula will tune RPS for any number of cores.

-1


source


I used this

# 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 "";

      

-2


source







All Articles