builder icon indicating copy to clipboard operation
builder copied to clipboard

40-net-smp-affinity 热插拔脚本在 NanoPi R76S 上未生效

Open Xingsandesu opened this issue 3 months ago • 6 comments

问题描述

首先说一下本人的测试环境 都是1000M的家宽。换了2.5g光猫。ipv6上行千兆。下行算上冗余带宽最高能跑2000M。以下iperf3的测试是同一个地域两个ipv6直连wg组成的虚拟局域网。理论基准测速都能达到800M以上。

NanoPi R76S 上运行 OpenWrt 时,发现 CPU 亲和性配置问题影响网络性能。主要分为两个问题:


1. 网口 RPS/XPS CPU mask 无效

  • 网口 /etc/hotplug.d/net/40-net-smp-affinity 热插拔脚本在启动时可能没有生效。未能正确应用 CPU 亲和性。
  • 导致默认 RPS/XPS CPU mask 为 ff(全部核心),实际负载可能集中在小核(0-3 核),导致突发网络场景下速度不能立即跑满。

查看默认 CPU mask:

cat /sys/class/net/eth0/queues/rx-0/rps_cpus
cat /sys/class/net/eth1/queues/rx-0/rps_cpus

手动修改:

echo 30 > /sys/class/net/eth0/queues/rx-0/rps_cpus
echo c0 > /sys/class/net/eth1/queues/rx-0/rps_cpus

实际效果

  • 默认小核负载过高。
  • 手动绑定大核心后,突发网络性能明显提升。

2. 网卡 IRQ CPU affinity 无法修改

  • /proc/irq/95/smp_affinity 默认绑定在小核0。
  • /proc/irq/96/smp_affinity 默认绑定在小核0
  • 无法直接通过热插拔脚本修改,可能需要修改 DTS。

示例查看:

grep eth /proc/interrupts
cat /proc/irq/96/smp_affinity
cat /proc/irq/95/smp_affinity

grep eth /proc/interrupts 显示:

 95:  433858335          0          0          0          0          0          0          0   PCI-MSI 524288 Edge      eth1-0
 96:  591530831          0          0          0          0          0          0          0   PCI-MSI 151519232 Edge      eth0-0

影响

  • IRQ 默认绑定小核,导致小核在峰值突发流量下过载。
  • 系统整体 CPU 负载不均衡。

重现步骤

  1. 启动 NanoPi R76S 并运行 OpenWrt。
  2. 查看默认 RPS/XPS CPU mask 和 IRQ 亲和性。
  3. 测试网络速度和 CPU 核心负载。
  4. 手动修改 RPS CPU mask(验证效果)。
  5. 查看 IRQ CPU mask 是否可修改。

预期行为

  • 网口启动后,RPS/XPS 和 IRQ 亲和性应正确应用在大核心。
  • 避免小核心过载,突发网络速度能够立即跑满。
  • 系统 CPU 负载均衡。

优化前/优化后效果(只是设置了网卡rps_cpus亲和性。没有更改网卡 IRQ CPU affinity)

优化前(跑两个WG组网的节点的iperf3负载。小核心负载过高):

Image Image

优化后(手动绑定大核心,测试项目同上。但是增加了一个测试两个突发网速的测试):

Image Image Image

备注

  • /etc/hotplug.d/net/40-net-smp-affinity 已包含 R76S 相关设置,但启动时未生效。
  • 希望热插拔脚本改进,网口启动后能够自动绑定大核心。
  • 建议优化 DTS,让网卡硬中断优先运行在大核心。

网速测试命令

外网: wget -O /dev/null "https://speed.cloudflare.com/__down?during=download&bytes=1073741824" 国内网: wget -O /dev/null "$(curl -s "https://speedtest.wostore.cn/wo-speedup/app/speedtest/getSpeedPoint" | jq -r '.data.urls[0]')"

Xingsandesu avatar Sep 24 '25 12:09 Xingsandesu

不知道是不是这个的问题https://github.com/openwrt/openwrt/issues/5941

Xingsandesu avatar Sep 24 '25 12:09 Xingsandesu

貌似手动更改后一段时间又会默认改成ff

Image

Xingsandesu avatar Sep 24 '25 13:09 Xingsandesu

RK3576 是 GICv2 架构,改不了你说的这些东西。

sbwml avatar Sep 24 '25 13:09 sbwml

好的好的。打扰了

Xingsandesu avatar Sep 24 '25 13:09 Xingsandesu

好像第一点是openwrt的bug。断电后冷启动不会触发hotplug。但是开机后手动reboot之后可以触发hotplug。r76s默认不带rtc电池那么每一次都是冷启动?等我有时间再测试下

Image

Xingsandesu avatar Sep 24 '25 13:09 Xingsandesu

最新固件应该解决了1. 网口 RPS/XPS CPU mask 无效 的问题

sbwml avatar Nov 17 '25 12:11 sbwml