Skip to content

Instantly share code, notes, and snippets.

@csrutil
Created June 5, 2022 02:33
Show Gist options
  • Select an option

  • Save csrutil/6d40962139aeb5b432fbf72881daa5f8 to your computer and use it in GitHub Desktop.

Select an option

Save csrutil/6d40962139aeb5b432fbf72881daa5f8 to your computer and use it in GitHub Desktop.
#!/bin/sh
# https://ixnfo.com/en/configuring-rps-receive-packet-steering.html
# https://bitsum.com/tools/cpu-affinity-calculator/
get_device_irq() {
local device="$1"
local line=$(grep -m 1 "${device}\$" /proc/interrupts)
echo ${line} | sed 's/:.*//'
}
set_interface_core() {
local core_mask="$1"
local interface="$2"
local device="$3"
[ -z "${device}" ] && device="$interface"
local irq=$(get_device_irq "$device")
[ -z "$irq" ] && return 0
echo -n "${core_mask}" > /proc/irq/${irq}/smp_affinity
}
echo 3 > /sys/class/net/eth1/queues/tx-0/xps_cpus
set_interface_core 1 "eth1-0"
set_interface_core 2 "eth1-16"
#set_interface_core 4 "eth1-18"
#set_interface_core 8 "eth1-21"
echo 3 > /sys/class/net/eth1/queues/rx-0/rps_cpus
# set_interface_core 1 "eth1-0"
# set_interface_core 2 "eth1-16"
set_interface_core 4 "eth1-18"
set_interface_core 8 "eth1-21"
echo f > /sys/class/net/eth2/queues/rx-0/rps_cpus
set_interface_core 1 "eth2-0"
set_interface_core 2 "eth2-16"
set_interface_core 4 "eth2-18"
set_interface_core 8 "eth2-21"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment