本文将mark下Linux RPS(Receive Packet Steering)相关notes。

Prerequisite

RSS(Receive Side Scaling)

What

Receive Packet Steering (RPS) is logically a software implementation of RSS.

Why

RPS has some advantages over RSS:

  1. it can be used with any NIC
  2. software filters can easily be added to hash over new protocols
  3. it does not increase hardware device interrupt rate (although it does IPIs)

在没有RSS功能的网卡中,RPS还是有价值的。

How

RPS其实就是一个软件对CPU负载重分发的机制。其使能的作用点在CPU开始处理软中断,即下面的地方:

1
2
netif_rx_internal
netif_receive_skb_internal

Whereas RSS selects the queue and hence CPU that will run the hardware interrupt handler, RPS selects the CPU to perform protocol processing above the interrupt handler. This is accomplished by placing the packet on the desired CPU backlog queue and waking up the CPU for processing.(RSS选择队列,从而选择了运行硬件中断处理程序的CPU;而RPS在中断处理程序之上选择CPU执行协议处理。这是通过将数据包放置在所需的CPU积压队列中并唤醒CPU进行处理来实现的。)


参考资料:

  1. Linux RPS/RFS 实现原理浅析
  2. Scaling in the Linux Networking Stack
  3. Linux网络栈的性能缩放
  4. Linux Network Scaling: Receiving Packets