Skip to content

Commit

Permalink
ipq806x: set wan and wifi cpu affinity
Browse files Browse the repository at this point in the history
At the moment by default all interrupts are assigned to core0.
Due to absence of implemented hardware NAT, balancing irq load between cpu cores provides noticeable performance gain - 10-30% depending on usage template.

With this script we are adjusting wan and wlan cpu affinity on different cores during boot.

After this change:
*ipq4019 (has 4 cores (core0-core3))
 - wan interrupt is assigned to core1
 - 2.4 ghz wifi - to core2
 - 5 ghz wifi - to core3

*ipq8064/5 (has 2 cores (core0 and core1))
 - wan interrupt is assigned to core1
 - 2.4ghz wifi - to core1

Signed-off-by: Pavel Kubelun <be.dissent@gmail.com>
  • Loading branch information
dissent1 committed Jul 30, 2017
1 parent 8aeba84 commit 8e1d91a
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions target/linux/ipq806x/base-files/etc/init.d/set_cpu_affinity
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh /etc/rc.common

START=99

set_irq_affinity() {
local name="$1"
local val="$2"

case "$name" in
wifi0)
local irq_wifi0=`grep -E -m1 'qcom-pcie-msi' /proc/interrupts | cut -d: -f1 | tail -n1 | tr -d ' '`
[ -n "$irq_wifi0" ] || echo "$name irq not found."
echo "$val" > "/proc/irq/$irq_wifi0/smp_affinity"
;;
wifi1)
local irq_wifi1=`grep -E -m2 'qcom-pcie-msi' /proc/interrupts | cut -d: -f1 | tail -n1 | tr -d ' '`
[ -n "$irq_wifi1" ] || echo "$name irq not found."
echo "$val" > "/proc/irq/$irq_wifi1/smp_affinity"
;;
*)
local irq=`grep -m 1 "$name" /proc/interrupts | cut -d: -f1 | sed 's, *,,'`
[ -n "$irq" ] || echo "$name irq not found."
echo "$val" > "/proc/irq/$irq/smp_affinity"
;;
esac
}

start() {

local board_name="cat /tmp/sysinfo/board_name"

This comment has been minimized.

Copy link
@hephooey

hephooey Aug 2, 2017

Should " be replaced by `?

This comment has been minimized.

Copy link
@dissent1

dissent1 Aug 3, 2017

Author Owner

Doesn't matter, I'll replace it with generic approach in a new version that has some fixes for ipq40xx :)


case "$board_name" in
fritz4040)
set_irq_affinity eth1 2
set_irq_affinity wifi0 4
set_irq_affinity wifi1 8
;;
ap148 |\
c2600 |\
db149 |\
d7800 |\
ea8500 |\
nbg6817 |\
r7500 |\
r7500v2 |\
r7800 |\
vr2600v)
set_irq_affinity eth0 2
set_irq_affinity wifi1 2
;;
*)
echo "Unsupported hardware. CPU affinity is not adjusted."
;;
esac
}

0 comments on commit 8e1d91a

Please sign in to comment.