aboutsummaryrefslogtreecommitdiffstats
path: root/package/network
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2018-02-26 12:30:28 +0100
committerFelix Fietkau <nbd@nbd.name>2018-02-28 12:46:02 +0100
commit916e33fa1e14b97daf8c9bf07a1b36f9767db679 (patch)
tree462528e7fc08eb16a2fd942151b27fc89f35fe35 /package/network
parent810659a22c11ea0d2d94f3e09ddf7eb2d2bb1f1e (diff)
downloadupstream-916e33fa1e14b97daf8c9bf07a1b36f9767db679.tar.gz
upstream-916e33fa1e14b97daf8c9bf07a1b36f9767db679.tar.bz2
upstream-916e33fa1e14b97daf8c9bf07a1b36f9767db679.zip
netifd: update to the latest version, rewrite RPS/XPS handling
Remove RPS/XPS support from netifd core, move the logic to a hotplug script that uses a different policy which provides better performance and more fairness across flows Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'package/network')
-rw-r--r--package/network/config/netifd/Makefile6
-rw-r--r--package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune67
2 files changed, 70 insertions, 3 deletions
diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
index d62b60ad98..6e208ddd96 100644
--- a/package/network/config/netifd/Makefile
+++ b/package/network/config/netifd/Makefile
@@ -5,9 +5,9 @@ PKG_RELEASE:=4
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
-PKG_SOURCE_DATE:=2018-02-05
-PKG_SOURCE_VERSION:=1be329c66326c86d7a48ba71004fcef7691bbbf9
-PKG_MIRROR_HASH:=06c1c24ed56b4fe39b92b33719f8bd4f9a8fe3c6a25ce02a6a245e859f1237bf
+PKG_SOURCE_DATE:=2018-02-26
+PKG_SOURCE_VERSION:=8cdb17d2c58d5c3ecb57bdaf1981cd72b4948db1
+PKG_MIRROR_HASH:=5c0859b779c9665edd7c105b92b7022fa7544e3a704e0e05bb3ab11ba0c30384
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=GPL-2.0
diff --git a/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune b/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune
new file mode 100644
index 0000000000..ab9a90418e
--- /dev/null
+++ b/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune
@@ -0,0 +1,67 @@
+#!/bin/sh
+[ "$ACTION" = add ] || exit
+
+NPROCS="$(grep -c "^processor.*:" /proc/cpuinfo)"
+[ "$NPROCS" -gt 1 ] || exit
+
+PROC_MASK="$(( (1 << $NPROCS) - 1 ))"
+
+find_irq_cpu() {
+ local dev="$1"
+ local match="$(grep -m 1 "$dev\$" /proc/interrupts)"
+ local cpu=0
+
+ [ -n "$match" ] && {
+ set -- $match
+ shift
+ for cur in `seq 1 $NPROCS`; do
+ [ "$1" -gt 0 ] && {
+ cpu=$(($cur - 1))
+ break
+ }
+ shift
+ done
+ }
+
+ echo "$cpu"
+}
+
+set_hex_val() {
+ local file="$1"
+ local val="$2"
+ val="$(printf %x "$val")"
+ [ -n "$DEBUG" ] && echo "$file = $val"
+ echo "$val" > "$file"
+}
+
+default_ps="$(uci get "network.@globals[0].default_ps")"
+[ -n "$default_ps" -a "$default_ps" != 1 ] && exit 0
+
+exec 512>/var/lock/smp_tune.lock
+flock 512 || exit 1
+
+for dev in /sys/class/net/*; do
+ [ -d "$dev" ] || continue
+
+ # ignore virtual interfaces
+ [ -n "$(ls "${dev}/" | grep '^lower_')" ] && continue
+ [ -d "${dev}/device" ] || continue
+
+ device="$(readlink "${dev}/device")"
+ device="$(basename "$device")"
+ irq_cpu="$(find_irq_cpu "$device")"
+ irq_cpu_mask="$((1 << $irq_cpu))"
+
+ for q in ${dev}/queues/rx-*; do
+ set_hex_val "$q/rps_cpus" "$(($PROC_MASK & ~$irq_cpu_mask))"
+ done
+
+ ntxq="$(ls -d ${dev}/queues/tx-* | wc -l)"
+
+ idx=$(($irq_cpu + 1))
+ for q in ${dev}/queues/tx-*; do
+ set_hex_val "$q/xps_cpus" "$((1 << $idx))"
+ let "idx = idx + 1"
+ [ "$idx" -ge "$NPROCS" ] && idx=0
+ done
+done