aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/networking
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-08-20 13:39:12 -0400
committerDavid S. Miller <davem@davemloft.net>2011-08-20 13:39:12 -0400
commit823dcd2506fa369aeb8cbd26da5663efe2fda9a9 (patch)
tree853b3e3c05f0b9ee1b5df8464db19b7acc57150c /Documentation/networking
parenteaa36660de7e174498618d69d7277d44a2f24c3d (diff)
parent98e77438aed3cd3343cbb86825127b1d9d2bea33 (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'Documentation/networking')
-rw-r--r--Documentation/networking/00-INDEX116
-rw-r--r--Documentation/networking/scaling.txt378
2 files changed, 494 insertions, 0 deletions
diff --git a/Documentation/networking/00-INDEX b/Documentation/networking/00-INDEX
index 4edd78dfb362..bbce1215434a 100644
--- a/Documentation/networking/00-INDEX
+++ b/Documentation/networking/00-INDEX
@@ -1,13 +1,21 @@
100-INDEX 100-INDEX
2 - this file 2 - this file
33c359.txt
4 - information on the 3Com TokenLink Velocity XL (3c5359) driver.
33c505.txt 53c505.txt
4 - information on the 3Com EtherLink Plus (3c505) driver. 6 - information on the 3Com EtherLink Plus (3c505) driver.
73c509.txt
8 - information on the 3Com Etherlink III Series Ethernet cards.
56pack.txt 96pack.txt
6 - info on the 6pack protocol, an alternative to KISS for AX.25 10 - info on the 6pack protocol, an alternative to KISS for AX.25
7DLINK.txt 11DLINK.txt
8 - info on the D-Link DE-600/DE-620 parallel port pocket adapters 12 - info on the D-Link DE-600/DE-620 parallel port pocket adapters
9PLIP.txt 13PLIP.txt
10 - PLIP: The Parallel Line Internet Protocol device driver 14 - PLIP: The Parallel Line Internet Protocol device driver
15README.ipw2100
16 - README for the Intel PRO/Wireless 2100 driver.
17README.ipw2200
18 - README for the Intel PRO/Wireless 2915ABG and 2200BG driver.
11README.sb1000 19README.sb1000
12 - info on General Instrument/NextLevel SURFboard1000 cable modem. 20 - info on General Instrument/NextLevel SURFboard1000 cable modem.
13alias.txt 21alias.txt
@@ -20,8 +28,12 @@ atm.txt
20 - info on where to get ATM programs and support for Linux. 28 - info on where to get ATM programs and support for Linux.
21ax25.txt 29ax25.txt
22 - info on using AX.25 and NET/ROM code for Linux 30 - info on using AX.25 and NET/ROM code for Linux
31batman-adv.txt
32 - B.A.T.M.A.N routing protocol on top of layer 2 Ethernet Frames.
23baycom.txt 33baycom.txt
24 - info on the driver for Baycom style amateur radio modems 34 - info on the driver for Baycom style amateur radio modems
35bonding.txt
36 - Linux Ethernet Bonding Driver HOWTO: link aggregation in Linux.
25bridge.txt 37bridge.txt
26 - where to get user space programs for ethernet bridging with Linux. 38 - where to get user space programs for ethernet bridging with Linux.
27can.txt 39can.txt
@@ -34,32 +46,60 @@ cxacru.txt
34 - Conexant AccessRunner USB ADSL Modem 46 - Conexant AccessRunner USB ADSL Modem
35cxacru-cf.py 47cxacru-cf.py
36 - Conexant AccessRunner USB ADSL Modem configuration file parser 48 - Conexant AccessRunner USB ADSL Modem configuration file parser
49cxgb.txt
50 - Release Notes for the Chelsio N210 Linux device driver.
51dccp.txt
52 - the Datagram Congestion Control Protocol (DCCP) (RFC 4340..42).
37de4x5.txt 53de4x5.txt
38 - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver 54 - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver
39decnet.txt 55decnet.txt
40 - info on using the DECnet networking layer in Linux. 56 - info on using the DECnet networking layer in Linux.
41depca.txt 57depca.txt
42 - the Digital DEPCA/EtherWORKS DE1?? and DE2?? LANCE Ethernet driver 58 - the Digital DEPCA/EtherWORKS DE1?? and DE2?? LANCE Ethernet driver
59dl2k.txt
60 - README for D-Link DL2000-based Gigabit Ethernet Adapters (dl2k.ko).
61dm9000.txt
62 - README for the Simtec DM9000 Network driver.
43dmfe.txt 63dmfe.txt
44 - info on the Davicom DM9102(A)/DM9132/DM9801 fast ethernet driver. 64 - info on the Davicom DM9102(A)/DM9132/DM9801 fast ethernet driver.
65dns_resolver.txt
66 - The DNS resolver module allows kernel servies to make DNS queries.
67driver.txt
68 - Softnet driver issues.
45e100.txt 69e100.txt
46 - info on Intel's EtherExpress PRO/100 line of 10/100 boards 70 - info on Intel's EtherExpress PRO/100 line of 10/100 boards
47e1000.txt 71e1000.txt
48 - info on Intel's E1000 line of gigabit ethernet boards 72 - info on Intel's E1000 line of gigabit ethernet boards
73e1000e.txt
74 - README for the Intel Gigabit Ethernet Driver (e1000e).
49eql.txt 75eql.txt
50 - serial IP load balancing 76 - serial IP load balancing
51ewrk3.txt 77ewrk3.txt
52 - the Digital EtherWORKS 3 DE203/4/5 Ethernet driver 78 - the Digital EtherWORKS 3 DE203/4/5 Ethernet driver
79fib_trie.txt
80 - Level Compressed Trie (LC-trie) notes: a structure for routing.
53filter.txt 81filter.txt
54 - Linux Socket Filtering 82 - Linux Socket Filtering
55fore200e.txt 83fore200e.txt
56 - FORE Systems PCA-200E/SBA-200E ATM NIC driver info. 84 - FORE Systems PCA-200E/SBA-200E ATM NIC driver info.
57framerelay.txt 85framerelay.txt
58 - info on using Frame Relay/Data Link Connection Identifier (DLCI). 86 - info on using Frame Relay/Data Link Connection Identifier (DLCI).
87gen_stats.txt
88 - Generic networking statistics for netlink users.
89generic_hdlc.txt
90 - The generic High Level Data Link Control (HDLC) layer.
59generic_netlink.txt 91generic_netlink.txt
60 - info on Generic Netlink 92 - info on Generic Netlink
93gianfar.txt
94 - Gianfar Ethernet Driver.
61ieee802154.txt 95ieee802154.txt
62 - Linux IEEE 802.15.4 implementation, API and drivers 96 - Linux IEEE 802.15.4 implementation, API and drivers
97ifenslave.c
98 - Configure network interfaces for parallel routing (bonding).
99igb.txt
100 - README for the Intel Gigabit Ethernet Driver (igb).
101igbvf.txt
102 - README for the Intel Gigabit Ethernet Driver (igbvf).
63ip-sysctl.txt 103ip-sysctl.txt
64 - /proc/sys/net/ipv4/* variables 104 - /proc/sys/net/ipv4/* variables
65ip_dynaddr.txt 105ip_dynaddr.txt
@@ -68,41 +108,117 @@ ipddp.txt
68 - AppleTalk-IP Decapsulation and AppleTalk-IP Encapsulation 108 - AppleTalk-IP Decapsulation and AppleTalk-IP Encapsulation
69iphase.txt 109iphase.txt
70 - Interphase PCI ATM (i)Chip IA Linux driver info. 110 - Interphase PCI ATM (i)Chip IA Linux driver info.
111ipv6.txt
112 - Options to the ipv6 kernel module.
113ipvs-sysctl.txt
114 - Per-inode explanation of the /proc/sys/net/ipv4/vs interface.
71irda.txt 115irda.txt
72 - where to get IrDA (infrared) utilities and info for Linux. 116 - where to get IrDA (infrared) utilities and info for Linux.
117ixgb.txt
118 - README for the Intel 10 Gigabit Ethernet Driver (ixgb).
119ixgbe.txt
120 - README for the Intel 10 Gigabit Ethernet Driver (ixgbe).
121ixgbevf.txt
122 - README for the Intel Virtual Function (VF) Driver (ixgbevf).
123l2tp.txt
124 - User guide to the L2TP tunnel protocol.
73lapb-module.txt 125lapb-module.txt
74 - programming information of the LAPB module. 126 - programming information of the LAPB module.
75ltpc.txt 127ltpc.txt
76 - the Apple or Farallon LocalTalk PC card driver 128 - the Apple or Farallon LocalTalk PC card driver
129mac80211-injection.txt
130 - HOWTO use packet injection with mac80211
77multicast.txt 131multicast.txt
78 - Behaviour of cards under Multicast 132 - Behaviour of cards under Multicast
133multiqueue.txt
134 - HOWTO for multiqueue network device support.
135netconsole.txt
136 - The network console module netconsole.ko: configuration and notes.
137netdev-features.txt
138 - Network interface features API description.
79netdevices.txt 139netdevices.txt
80 - info on network device driver functions exported to the kernel. 140 - info on network device driver functions exported to the kernel.
141netif-msg.txt
142 - Design of the network interface message level setting (NETIF_MSG_*).
143nfc.txt
144 - The Linux Near Field Communication (NFS) subsystem.
81olympic.txt 145olympic.txt
82 - IBM PCI Pit/Pit-Phy/Olympic Token Ring driver info. 146 - IBM PCI Pit/Pit-Phy/Olympic Token Ring driver info.
147operstates.txt
148 - Overview of network interface operational states.
149packet_mmap.txt
150 - User guide to memory mapped packet socket rings (PACKET_[RT]X_RING).
151phonet.txt
152 - The Phonet packet protocol used in Nokia cellular modems.
153phy.txt
154 - The PHY abstraction layer.
155pktgen.txt
156 - User guide to the kernel packet generator (pktgen.ko).
83policy-routing.txt 157policy-routing.txt
84 - IP policy-based routing 158 - IP policy-based routing
159ppp_generic.txt
160 - Information about the generic PPP driver.
161proc_net_tcp.txt
162 - Per inode overview of the /proc/net/tcp and /proc/net/tcp6 interfaces.
163radiotap-headers.txt
164 - Background on radiotap headers.
85ray_cs.txt 165ray_cs.txt
86 - Raylink Wireless LAN card driver info. 166 - Raylink Wireless LAN card driver info.
167rds.txt
168 - Background on the reliable, ordered datagram delivery method RDS.
169regulatory.txt
170 - Overview of the Linux wireless regulatory infrastructure.
171rxrpc.txt
172 - Guide to the RxRPC protocol.
173s2io.txt
174 - Release notes for Neterion Xframe I/II 10GbE driver.
175scaling.txt
176 - Explanation of network scaling techniques: RSS, RPS, RFS, aRFS, XPS.
177sctp.txt
178 - Notes on the Linux kernel implementation of the SCTP protocol.
179secid.txt
180 - Explanation of the secid member in flow structures.
87skfp.txt 181skfp.txt
88 - SysKonnect FDDI (SK-5xxx, Compaq Netelligent) driver info. 182 - SysKonnect FDDI (SK-5xxx, Compaq Netelligent) driver info.
89smc9.txt 183smc9.txt
90 - the driver for SMC's 9000 series of Ethernet cards 184 - the driver for SMC's 9000 series of Ethernet cards
91smctr.txt 185smctr.txt
92 - SMC TokenCard TokenRing Linux driver info. 186 - SMC TokenCard TokenRing Linux driver info.
187spider-net.txt
188 - README for the Spidernet Driver (as found in PS3 / Cell BE).
189stmmac.txt
190 - README for the STMicro Synopsys Ethernet driver.
191tc-actions-env-rules.txt
192 - rules for traffic control (tc) actions.
193timestamping.txt
194 - overview of network packet timestamping variants.
93tcp.txt 195tcp.txt
94 - short blurb on how TCP output takes place. 196 - short blurb on how TCP output takes place.
197tcp-thin.txt
198 - kernel tuning options for low rate 'thin' TCP streams.
95tlan.txt 199tlan.txt
96 - ThunderLAN (Compaq Netelligent 10/100, Olicom OC-2xxx) driver info. 200 - ThunderLAN (Compaq Netelligent 10/100, Olicom OC-2xxx) driver info.
97tms380tr.txt 201tms380tr.txt
98 - SysKonnect Token Ring ISA/PCI adapter driver info. 202 - SysKonnect Token Ring ISA/PCI adapter driver info.
203tproxy.txt
204 - Transparent proxy support user guide.
99tuntap.txt 205tuntap.txt
100 - TUN/TAP device driver, allowing user space Rx/Tx of packets. 206 - TUN/TAP device driver, allowing user space Rx/Tx of packets.
207udplite.txt
208 - UDP-Lite protocol (RFC 3828) introduction.
101vortex.txt 209vortex.txt
102 - info on using 3Com Vortex (3c590, 3c592, 3c595, 3c597) Ethernet cards. 210 - info on using 3Com Vortex (3c590, 3c592, 3c595, 3c597) Ethernet cards.
211vxge.txt
212 - README for the Neterion X3100 PCIe Server Adapter.
103x25.txt 213x25.txt
104 - general info on X.25 development. 214 - general info on X.25 development.
105x25-iface.txt 215x25-iface.txt
106 - description of the X.25 Packet Layer to LAPB device interface. 216 - description of the X.25 Packet Layer to LAPB device interface.
217xfrm_proc.txt
218 - description of the statistics package for XFRM.
219xfrm_sync.txt
220 - sync patches for XFRM enable migration of an SA between hosts.
221xfrm_sysctl.txt
222 - description of the XFRM configuration options.
107z8530drv.txt 223z8530drv.txt
108 - info about Linux driver for Z8530 based HDLC cards for AX.25 224 - info about Linux driver for Z8530 based HDLC cards for AX.25
diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
new file mode 100644
index 000000000000..58fd7414e6c0
--- /dev/null
+++ b/Documentation/networking/scaling.txt
@@ -0,0 +1,378 @@
1Scaling in the Linux Networking Stack
2
3
4Introduction
5============
6
7This document describes a set of complementary techniques in the Linux
8networking stack to increase parallelism and improve performance for
9multi-processor systems.
10
11The following technologies are described:
12
13 RSS: Receive Side Scaling
14 RPS: Receive Packet Steering
15 RFS: Receive Flow Steering
16 Accelerated Receive Flow Steering
17 XPS: Transmit Packet Steering
18
19
20RSS: Receive Side Scaling
21=========================
22
23Contemporary NICs support multiple receive and transmit descriptor queues
24(multi-queue). On reception, a NIC can send different packets to different
25queues to distribute processing among CPUs. The NIC distributes packets by
26applying a filter to each packet that assigns it to one of a small number
27of logical flows. Packets for each flow are steered to a separate receive
28queue, which in turn can be processed by separate CPUs. This mechanism is
29generally known as “Receive-side Scaling” (RSS). The goal of RSS and
30the other scaling techniques to increase performance uniformly.
31Multi-queue distribution can also be used for traffic prioritization, but
32that is not the focus of these techniques.
33
34The filter used in RSS is typically a hash function over the network
35and/or transport layer headers-- for example, a 4-tuple hash over
36IP addresses and TCP ports of a packet. The most common hardware
37implementation of RSS uses a 128-entry indirection table where each entry
38stores a queue number. The receive queue for a packet is determined
39by masking out the low order seven bits of the computed hash for the
40packet (usually a Toeplitz hash), taking this number as a key into the
41indirection table and reading the corresponding value.
42
43Some advanced NICs allow steering packets to queues based on
44programmable filters. For example, webserver bound TCP port 80 packets
45can be directed to their own receive queue. Such “n-tuple” filters can
46be configured from ethtool (--config-ntuple).
47
48==== RSS Configuration
49
50The driver for a multi-queue capable NIC typically provides a kernel
51module parameter for specifying the number of hardware queues to
52configure. In the bnx2x driver, for instance, this parameter is called
53num_queues. A typical RSS configuration would be to have one receive queue
54for each CPU if the device supports enough queues, or otherwise at least
55one for each memory domain, where a memory domain is a set of CPUs that
56share a particular memory level (L1, L2, NUMA node, etc.).
57
58The indirection table of an RSS device, which resolves a queue by masked
59hash, is usually programmed by the driver at initialization. The
60default mapping is to distribute the queues evenly in the table, but the
61indirection table can be retrieved and modified at runtime using ethtool
62commands (--show-rxfh-indir and --set-rxfh-indir). Modifying the
63indirection table could be done to give different queues different
64relative weights.
65
66== RSS IRQ Configuration
67
68Each receive queue has a separate IRQ associated with it. The NIC triggers
69this to notify a CPU when new packets arrive on the given queue. The
70signaling path for PCIe devices uses message signaled interrupts (MSI-X),
71that can route each interrupt to a particular CPU. The active mapping
72of queues to IRQs can be determined from /proc/interrupts. By default,
73an IRQ may be handled on any CPU. Because a non-negligible part of packet
74processing takes place in receive interrupt handling, it is advantageous
75to spread receive interrupts between CPUs. To manually adjust the IRQ
76affinity of each interrupt see Documentation/IRQ-affinity. Some systems
77will be running irqbalance, a daemon that dynamically optimizes IRQ
78assignments and as a result may override any manual settings.
79
80== Suggested Configuration
81
82RSS should be enabled when latency is a concern or whenever receive
83interrupt processing forms a bottleneck. Spreading load between CPUs
84decreases queue length. For low latency networking, the optimal setting
85is to allocate as many queues as there are CPUs in the system (or the
86NIC maximum, if lower). The most efficient high-rate configuration
87is likely the one with the smallest number of receive queues where no
88receive queue overflows due to a saturated CPU, because in default
89mode with interrupt coalescing enabled, the aggregate number of
90interrupts (and thus work) grows with each additional queue.
91
92Per-cpu load can be observed using the mpstat utility, but note that on
93processors with hyperthreading (HT), each hyperthread is represented as
94a separate CPU. For interrupt handling, HT has shown no benefit in
95initial tests, so limit the number of queues to the number of CPU cores
96in the system.
97
98
99RPS: Receive Packet Steering
100============================
101
102Receive Packet Steering (RPS) is logically a software implementation of
103RSS. Being in software, it is necessarily called later in the datapath.
104Whereas RSS selects the queue and hence CPU that will run the hardware
105interrupt handler, RPS selects the CPU to perform protocol processing
106above the interrupt handler. This is accomplished by placing the packet
107on the desired CPU’s backlog queue and waking up the CPU for processing.
108RPS has some advantages over RSS: 1) it can be used with any NIC,
1092) software filters can easily be added to hash over new protocols,
1103) it does not increase hardware device interrupt rate (although it does
111introduce inter-processor interrupts (IPIs)).
112
113RPS is called during bottom half of the receive interrupt handler, when
114a driver sends a packet up the network stack with netif_rx() or
115netif_receive_skb(). These call the get_rps_cpu() function, which
116selects the queue that should process a packet.
117
118The first step in determining the target CPU for RPS is to calculate a
119flow hash over the packet’s addresses or ports (2-tuple or 4-tuple hash
120depending on the protocol). This serves as a consistent hash of the
121associated flow of the packet. The hash is either provided by hardware
122or will be computed in the stack. Capable hardware can pass the hash in
123the receive descriptor for the packet; this would usually be the same
124hash used for RSS (e.g. computed Toeplitz hash). The hash is saved in
125skb->rx_hash and can be used elsewhere in the stack as a hash of the
126packet’s flow.
127
128Each receive hardware queue has an associated list of CPUs to which
129RPS may enqueue packets for processing. For each received packet,
130an index into the list is computed from the flow hash modulo the size
131of the list. The indexed CPU is the target for processing the packet,
132and the packet is queued to the tail of that CPU’s backlog queue. At
133the end of the bottom half routine, IPIs are sent to any CPUs for which
134packets have been queued to their backlog queue. The IPI wakes backlog
135processing on the remote CPU, and any queued packets are then processed
136up the networking stack.
137
138==== RPS Configuration
139
140RPS requires a kernel compiled with the CONFIG_RPS kconfig symbol (on
141by default for SMP). Even when compiled in, RPS remains disabled until
142explicitly configured. The list of CPUs to which RPS may forward traffic
143can be configured for each receive queue using a sysfs file entry:
144
145 /sys/class/net/<dev>/queues/rx-<n>/rps_cpus
146
147This file implements a bitmap of CPUs. RPS is disabled when it is zero
148(the default), in which case packets are processed on the interrupting
149CPU. Documentation/IRQ-affinity.txt explains how CPUs are assigned to
150the bitmap.
151
152== Suggested Configuration
153
154For a single queue device, a typical RPS configuration would be to set
155the rps_cpus to the CPUs in the same memory domain of the interrupting
156CPU. If NUMA locality is not an issue, this could also be all CPUs in
157the system. At high interrupt rate, it might be wise to exclude the
158interrupting CPU from the map since that already performs much work.
159
160For a multi-queue system, if RSS is configured so that a hardware
161receive queue is mapped to each CPU, then RPS is probably redundant
162and unnecessary. If there are fewer hardware queues than CPUs, then
163RPS might be beneficial if the rps_cpus for each queue are the ones that
164share the same memory domain as the interrupting CPU for that queue.
165
166
167RFS: Receive Flow Steering
168==========================
169
170While RPS steers packets solely based on hash, and thus generally
171provides good load distribution, it does not take into account
172application locality. This is accomplished by Receive Flow Steering
173(RFS). The goal of RFS is to increase datacache hitrate by steering
174kernel processing of packets to the CPU where the application thread
175consuming the packet is running. RFS relies on the same RPS mechanisms
176to enqueue packets onto the backlog of another CPU and to wake up that
177CPU.
178
179In RFS, packets are not forwarded directly by the value of their hash,
180but the hash is used as index into a flow lookup table. This table maps
181flows to the CPUs where those flows are being processed. The flow hash
182(see RPS section above) is used to calculate the index into this table.
183The CPU recorded in each entry is the one which last processed the flow.
184If an entry does not hold a valid CPU, then packets mapped to that entry
185are steered using plain RPS. Multiple table entries may point to the
186same CPU. Indeed, with many flows and few CPUs, it is very likely that
187a single application thread handles flows with many different flow hashes.
188
189rps_sock_table is a global flow table that contains the *desired* CPU for
190flows: the CPU that is currently processing the flow in userspace. Each
191table value is a CPU index that is updated during calls to recvmsg and
192sendmsg (specifically, inet_recvmsg(), inet_sendmsg(), inet_sendpage()
193and tcp_splice_read()).
194
195When the scheduler moves a thread to a new CPU while it has outstanding
196receive packets on the old CPU, packets may arrive out of order. To
197avoid this, RFS uses a second flow table to track outstanding packets
198for each flow: rps_dev_flow_table is a table specific to each hardware
199receive queue of each device. Each table value stores a CPU index and a
200counter. The CPU index represents the *current* CPU onto which packets
201for this flow are enqueued for further kernel processing. Ideally, kernel
202and userspace processing occur on the same CPU, and hence the CPU index
203in both tables is identical. This is likely false if the scheduler has
204recently migrated a userspace thread while the kernel still has packets
205enqueued for kernel processing on the old CPU.
206
207The counter in rps_dev_flow_table values records the length of the current
208CPU's backlog when a packet in this flow was last enqueued. Each backlog
209queue has a head counter that is incremented on dequeue. A tail counter
210is computed as head counter + queue length. In other words, the counter
211in rps_dev_flow_table[i] records the last element in flow i that has
212been enqueued onto the currently designated CPU for flow i (of course,
213entry i is actually selected by hash and multiple flows may hash to the
214same entry i).
215
216And now the trick for avoiding out of order packets: when selecting the
217CPU for packet processing (from get_rps_cpu()) the rps_sock_flow table
218and the rps_dev_flow table of the queue that the packet was received on
219are compared. If the desired CPU for the flow (found in the
220rps_sock_flow table) matches the current CPU (found in the rps_dev_flow
221table), the packet is enqueued onto that CPU’s backlog. If they differ,
222the current CPU is updated to match the desired CPU if one of the
223following is true:
224
225- The current CPU's queue head counter >= the recorded tail counter
226 value in rps_dev_flow[i]
227- The current CPU is unset (equal to NR_CPUS)
228- The current CPU is offline
229
230After this check, the packet is sent to the (possibly updated) current
231CPU. These rules aim to ensure that a flow only moves to a new CPU when
232there are no packets outstanding on the old CPU, as the outstanding
233packets could arrive later than those about to be processed on the new
234CPU.
235
236==== RFS Configuration
237
238RFS is only available if the kconfig symbol CONFIG_RFS is enabled (on
239by default for SMP). The functionality remains disabled until explicitly
240configured. The number of entries in the global flow table is set through:
241
242 /proc/sys/net/core/rps_sock_flow_entries
243
244The number of entries in the per-queue flow table are set through:
245
246 /sys/class/net/<dev>/queues/tx-<n>/rps_flow_cnt
247
248== Suggested Configuration
249
250Both of these need to be set before RFS is enabled for a receive queue.
251Values for both are rounded up to the nearest power of two. The
252suggested flow count depends on the expected number of active connections
253at any given time, which may be significantly less than the number of open
254connections. We have found that a value of 32768 for rps_sock_flow_entries
255works fairly well on a moderately loaded server.
256
257For a single queue device, the rps_flow_cnt value for the single queue
258would normally be configured to the same value as rps_sock_flow_entries.
259For a multi-queue device, the rps_flow_cnt for each queue might be
260configured as rps_sock_flow_entries / N, where N is the number of
261queues. So for instance, if rps_flow_entries is set to 32768 and there
262are 16 configured receive queues, rps_flow_cnt for each queue might be
263configured as 2048.
264
265
266Accelerated RFS
267===============
268
269Accelerated RFS is to RFS what RSS is to RPS: a hardware-accelerated load
270balancing mechanism that uses soft state to steer flows based on where
271the application thread consuming the packets of each flow is running.
272Accelerated RFS should perform better than RFS since packets are sent
273directly to a CPU local to the thread consuming the data. The target CPU
274will either be the same CPU where the application runs, or at least a CPU
275which is local to the application thread’s CPU in the cache hierarchy.
276
277To enable accelerated RFS, the networking stack calls the
278ndo_rx_flow_steer driver function to communicate the desired hardware
279queue for packets matching a particular flow. The network stack
280automatically calls this function every time a flow entry in
281rps_dev_flow_table is updated. The driver in turn uses a device specific
282method to program the NIC to steer the packets.
283
284The hardware queue for a flow is derived from the CPU recorded in
285rps_dev_flow_table. The stack consults a CPU to hardware queue map which
286is maintained by the NIC driver. This is an auto-generated reverse map of
287the IRQ affinity table shown by /proc/interrupts. Drivers can use
288functions in the cpu_rmap (“CPU affinity reverse map”) kernel library
289to populate the map. For each CPU, the corresponding queue in the map is
290set to be one whose processing CPU is closest in cache locality.
291
292==== Accelerated RFS Configuration
293
294Accelerated RFS is only available if the kernel is compiled with
295CONFIG_RFS_ACCEL and support is provided by the NIC device and driver.
296It also requires that ntuple filtering is enabled via ethtool. The map
297of CPU to queues is automatically deduced from the IRQ affinities
298configured for each receive queue by the driver, so no additional
299configuration should be necessary.
300
301== Suggested Configuration
302
303This technique should be enabled whenever one wants to use RFS and the
304NIC supports hardware acceleration.
305
306XPS: Transmit Packet Steering
307=============================
308
309Transmit Packet Steering is a mechanism for intelligently selecting
310which transmit queue to use when transmitting a packet on a multi-queue
311device. To accomplish this, a mapping from CPU to hardware queue(s) is
312recorded. The goal of this mapping is usually to assign queues
313exclusively to a subset of CPUs, where the transmit completions for
314these queues are processed on a CPU within this set. This choice
315provides two benefits. First, contention on the device queue lock is
316significantly reduced since fewer CPUs contend for the same queue
317(contention can be eliminated completely if each CPU has its own
318transmit queue). Secondly, cache miss rate on transmit completion is
319reduced, in particular for data cache lines that hold the sk_buff
320structures.
321
322XPS is configured per transmit queue by setting a bitmap of CPUs that
323may use that queue to transmit. The reverse mapping, from CPUs to
324transmit queues, is computed and maintained for each network device.
325When transmitting the first packet in a flow, the function
326get_xps_queue() is called to select a queue. This function uses the ID
327of the running CPU as a key into the CPU-to-queue lookup table. If the
328ID matches a single queue, that is used for transmission. If multiple
329queues match, one is selected by using the flow hash to compute an index
330into the set.
331
332The queue chosen for transmitting a particular flow is saved in the
333corresponding socket structure for the flow (e.g. a TCP connection).
334This transmit queue is used for subsequent packets sent on the flow to
335prevent out of order (ooo) packets. The choice also amortizes the cost
336of calling get_xps_queues() over all packets in the flow. To avoid
337ooo packets, the queue for a flow can subsequently only be changed if
338skb->ooo_okay is set for a packet in the flow. This flag indicates that
339there are no outstanding packets in the flow, so the transmit queue can
340change without the risk of generating out of order packets. The
341transport layer is responsible for setting ooo_okay appropriately. TCP,
342for instance, sets the flag when all data for a connection has been
343acknowledged.
344
345==== XPS Configuration
346
347XPS is only available if the kconfig symbol CONFIG_XPS is enabled (on by
348default for SMP). The functionality remains disabled until explicitly
349configured. To enable XPS, the bitmap of CPUs that may use a transmit
350queue is configured using the sysfs file entry:
351
352/sys/class/net/<dev>/queues/tx-<n>/xps_cpus
353
354== Suggested Configuration
355
356For a network device with a single transmission queue, XPS configuration
357has no effect, since there is no choice in this case. In a multi-queue
358system, XPS is preferably configured so that each CPU maps onto one queue.
359If there are as many queues as there are CPUs in the system, then each
360queue can also map onto one CPU, resulting in exclusive pairings that
361experience no contention. If there are fewer queues than CPUs, then the
362best CPUs to share a given queue are probably those that share the cache
363with the CPU that processes transmit completions for that queue
364(transmit interrupts).
365
366
367Further Information
368===================
369RPS and RFS were introduced in kernel 2.6.35. XPS was incorporated into
3702.6.38. Original patches were submitted by Tom Herbert
371(therbert@google.com)
372
373Accelerated RFS was introduced in 2.6.35. Original patches were
374submitted by Ben Hutchings (bhutchings@solarflare.com)
375
376Authors:
377Tom Herbert (therbert@google.com)
378Willem de Bruijn (willemb@google.com)