scaling.rst 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. .. SPDX-License-Identifier: GPL-2.0
  2. =====================================
  3. Scaling in the Linux Networking Stack
  4. =====================================
  5. Introduction
  6. ============
  7. This document describes a set of complementary techniques in the Linux
  8. networking stack to increase parallelism and improve performance for
  9. multi-processor systems.
  10. The following technologies are described:
  11. - RSS: Receive Side Scaling
  12. - RPS: Receive Packet Steering
  13. - RFS: Receive Flow Steering
  14. - Accelerated Receive Flow Steering
  15. - XPS: Transmit Packet Steering
  16. RSS: Receive Side Scaling
  17. =========================
  18. Contemporary NICs support multiple receive and transmit descriptor queues
  19. (multi-queue). On reception, a NIC can send different packets to different
  20. queues to distribute processing among CPUs. The NIC distributes packets by
  21. applying a filter to each packet that assigns it to one of a small number
  22. of logical flows. Packets for each flow are steered to a separate receive
  23. queue, which in turn can be processed by separate CPUs. This mechanism is
  24. generally known as “Receive-side Scaling” (RSS). The goal of RSS and
  25. the other scaling techniques is to increase performance uniformly.
  26. Multi-queue distribution can also be used for traffic prioritization, but
  27. that is not the focus of these techniques.
  28. The filter used in RSS is typically a hash function over the network
  29. and/or transport layer headers-- for example, a 4-tuple hash over
  30. IP addresses and TCP ports of a packet. The most common hardware
  31. implementation of RSS uses a 128-entry indirection table where each entry
  32. stores a queue number. The receive queue for a packet is determined
  33. by masking out the low order seven bits of the computed hash for the
  34. packet (usually a Toeplitz hash), taking this number as a key into the
  35. indirection table and reading the corresponding value.
  36. Some NICs support symmetric RSS hashing where, if the IP (source address,
  37. destination address) and TCP/UDP (source port, destination port) tuples
  38. are swapped, the computed hash is the same. This is beneficial in some
  39. applications that monitor TCP/IP flows (IDS, firewalls, ...etc) and need
  40. both directions of the flow to land on the same Rx queue (and CPU). The
  41. "Symmetric-XOR" is a type of RSS algorithms that achieves this hash
  42. symmetry by XORing the input source and destination fields of the IP
  43. and/or L4 protocols. This, however, results in reduced input entropy and
  44. could potentially be exploited. Specifically, the algorithm XORs the input
  45. as follows::
  46. # (SRC_IP ^ DST_IP, SRC_IP ^ DST_IP, SRC_PORT ^ DST_PORT, SRC_PORT ^ DST_PORT)
  47. The result is then fed to the underlying RSS algorithm.
  48. Some advanced NICs allow steering packets to queues based on
  49. programmable filters. For example, webserver bound TCP port 80 packets
  50. can be directed to their own receive queue. Such “n-tuple” filters can
  51. be configured from ethtool (--config-ntuple).
  52. RSS Configuration
  53. -----------------
  54. The driver for a multi-queue capable NIC typically provides a kernel
  55. module parameter for specifying the number of hardware queues to
  56. configure. In the bnx2x driver, for instance, this parameter is called
  57. num_queues. A typical RSS configuration would be to have one receive queue
  58. for each CPU if the device supports enough queues, or otherwise at least
  59. one for each memory domain, where a memory domain is a set of CPUs that
  60. share a particular memory level (L1, L2, NUMA node, etc.).
  61. The indirection table of an RSS device, which resolves a queue by masked
  62. hash, is usually programmed by the driver at initialization. The
  63. default mapping is to distribute the queues evenly in the table, but the
  64. indirection table can be retrieved and modified at runtime using ethtool
  65. commands (--show-rxfh-indir and --set-rxfh-indir). Modifying the
  66. indirection table could be done to give different queues different
  67. relative weights.
  68. RSS IRQ Configuration
  69. ~~~~~~~~~~~~~~~~~~~~~
  70. Each receive queue has a separate IRQ associated with it. The NIC triggers
  71. this to notify a CPU when new packets arrive on the given queue. The
  72. signaling path for PCIe devices uses message signaled interrupts (MSI-X),
  73. that can route each interrupt to a particular CPU. The active mapping
  74. of queues to IRQs can be determined from /proc/interrupts. By default,
  75. an IRQ may be handled on any CPU. Because a non-negligible part of packet
  76. processing takes place in receive interrupt handling, it is advantageous
  77. to spread receive interrupts between CPUs. To manually adjust the IRQ
  78. affinity of each interrupt see Documentation/core-api/irq/irq-affinity.rst. Some systems
  79. will be running irqbalance, a daemon that dynamically optimizes IRQ
  80. assignments and as a result may override any manual settings.
  81. Suggested Configuration
  82. ~~~~~~~~~~~~~~~~~~~~~~~
  83. RSS should be enabled when latency is a concern or whenever receive
  84. interrupt processing forms a bottleneck. Spreading load between CPUs
  85. decreases queue length. For low latency networking, the optimal setting
  86. is to allocate as many queues as there are CPUs in the system (or the
  87. NIC maximum, if lower). The most efficient high-rate configuration
  88. is likely the one with the smallest number of receive queues where no
  89. receive queue overflows due to a saturated CPU, because in default
  90. mode with interrupt coalescing enabled, the aggregate number of
  91. interrupts (and thus work) grows with each additional queue.
  92. Per-cpu load can be observed using the mpstat utility, but note that on
  93. processors with hyperthreading (HT), each hyperthread is represented as
  94. a separate CPU. For interrupt handling, HT has shown no benefit in
  95. initial tests, so limit the number of queues to the number of CPU cores
  96. in the system.
  97. Dedicated RSS contexts
  98. ~~~~~~~~~~~~~~~~~~~~~~
  99. Modern NICs support creating multiple co-existing RSS configurations
  100. which are selected based on explicit matching rules. This can be very
  101. useful when application wants to constrain the set of queues receiving
  102. traffic for e.g. a particular destination port or IP address.
  103. The example below shows how to direct all traffic to TCP port 22
  104. to queues 0 and 1.
  105. To create an additional RSS context use::
  106. # ethtool -X eth0 hfunc toeplitz context new
  107. New RSS context is 1
  108. Kernel reports back the ID of the allocated context (the default, always
  109. present RSS context has ID of 0). The new context can be queried and
  110. modified using the same APIs as the default context::
  111. # ethtool -x eth0 context 1
  112. RX flow hash indirection table for eth0 with 13 RX ring(s):
  113. 0: 0 1 2 3 4 5 6 7
  114. 8: 8 9 10 11 12 0 1 2
  115. [...]
  116. # ethtool -X eth0 equal 2 context 1
  117. # ethtool -x eth0 context 1
  118. RX flow hash indirection table for eth0 with 13 RX ring(s):
  119. 0: 0 1 0 1 0 1 0 1
  120. 8: 0 1 0 1 0 1 0 1
  121. [...]
  122. To make use of the new context direct traffic to it using an n-tuple
  123. filter::
  124. # ethtool -N eth0 flow-type tcp6 dst-port 22 context 1
  125. Added rule with ID 1023
  126. When done, remove the context and the rule::
  127. # ethtool -N eth0 delete 1023
  128. # ethtool -X eth0 context 1 delete
  129. RPS: Receive Packet Steering
  130. ============================
  131. Receive Packet Steering (RPS) is logically a software implementation of
  132. RSS. Being in software, it is necessarily called later in the datapath.
  133. Whereas RSS selects the queue and hence CPU that will run the hardware
  134. interrupt handler, RPS selects the CPU to perform protocol processing
  135. above the interrupt handler. This is accomplished by placing the packet
  136. on the desired CPU’s backlog queue and waking up the CPU for processing.
  137. RPS has some advantages over RSS:
  138. 1) it can be used with any NIC
  139. 2) software filters can easily be added to hash over new protocols
  140. 3) it does not increase hardware device interrupt rate (although it does
  141. introduce inter-processor interrupts (IPIs))
  142. RPS is called during bottom half of the receive interrupt handler, when
  143. a driver sends a packet up the network stack with netif_rx() or
  144. netif_receive_skb(). These call the get_rps_cpu() function, which
  145. selects the queue that should process a packet.
  146. The first step in determining the target CPU for RPS is to calculate a
  147. flow hash over the packet’s addresses or ports (2-tuple or 4-tuple hash
  148. depending on the protocol). This serves as a consistent hash of the
  149. associated flow of the packet. The hash is either provided by hardware
  150. or will be computed in the stack. Capable hardware can pass the hash in
  151. the receive descriptor for the packet; this would usually be the same
  152. hash used for RSS (e.g. computed Toeplitz hash). The hash is saved in
  153. skb->hash and can be used elsewhere in the stack as a hash of the
  154. packet’s flow.
  155. Each receive hardware queue has an associated list of CPUs to which
  156. RPS may enqueue packets for processing. For each received packet,
  157. an index into the list is computed from the flow hash modulo the size
  158. of the list. The indexed CPU is the target for processing the packet,
  159. and the packet is queued to the tail of that CPU’s backlog queue. At
  160. the end of the bottom half routine, IPIs are sent to any CPUs for which
  161. packets have been queued to their backlog queue. The IPI wakes backlog
  162. processing on the remote CPU, and any queued packets are then processed
  163. up the networking stack.
  164. RPS Configuration
  165. -----------------
  166. RPS requires a kernel compiled with the CONFIG_RPS kconfig symbol (on
  167. by default for SMP). Even when compiled in, RPS remains disabled until
  168. explicitly configured. The list of CPUs to which RPS may forward traffic
  169. can be configured for each receive queue using a sysfs file entry::
  170. /sys/class/net/<dev>/queues/rx-<n>/rps_cpus
  171. This file implements a bitmap of CPUs. RPS is disabled when it is zero
  172. (the default), in which case packets are processed on the interrupting
  173. CPU. Documentation/core-api/irq/irq-affinity.rst explains how CPUs are assigned to
  174. the bitmap.
  175. Suggested Configuration
  176. ~~~~~~~~~~~~~~~~~~~~~~~
  177. For a single queue device, a typical RPS configuration would be to set
  178. the rps_cpus to the CPUs in the same memory domain of the interrupting
  179. CPU. If NUMA locality is not an issue, this could also be all CPUs in
  180. the system. At high interrupt rate, it might be wise to exclude the
  181. interrupting CPU from the map since that already performs much work.
  182. For a multi-queue system, if RSS is configured so that a hardware
  183. receive queue is mapped to each CPU, then RPS is probably redundant
  184. and unnecessary. If there are fewer hardware queues than CPUs, then
  185. RPS might be beneficial if the rps_cpus for each queue are the ones that
  186. share the same memory domain as the interrupting CPU for that queue.
  187. RPS Flow Limit
  188. --------------
  189. RPS scales kernel receive processing across CPUs without introducing
  190. reordering. The trade-off to sending all packets from the same flow
  191. to the same CPU is CPU load imbalance if flows vary in packet rate.
  192. In the extreme case a single flow dominates traffic. Especially on
  193. common server workloads with many concurrent connections, such
  194. behavior indicates a problem such as a misconfiguration or spoofed
  195. source Denial of Service attack.
  196. Flow Limit is an optional RPS feature that prioritizes small flows
  197. during CPU contention by dropping packets from large flows slightly
  198. ahead of those from small flows. It is active only when an RPS or RFS
  199. destination CPU approaches saturation. Once a CPU's input packet
  200. queue exceeds half the maximum queue length (as set by sysctl
  201. net.core.netdev_max_backlog), the kernel starts a per-flow packet
  202. count over the last 256 packets. If a flow exceeds a set ratio (by
  203. default, half) of these packets when a new packet arrives, then the
  204. new packet is dropped. Packets from other flows are still only
  205. dropped once the input packet queue reaches netdev_max_backlog.
  206. No packets are dropped when the input packet queue length is below
  207. the threshold, so flow limit does not sever connections outright:
  208. even large flows maintain connectivity.
  209. Interface
  210. ~~~~~~~~~
  211. Flow limit is compiled in by default (CONFIG_NET_FLOW_LIMIT), but not
  212. turned on. It is implemented for each CPU independently (to avoid lock
  213. and cache contention) and toggled per CPU by setting the relevant bit
  214. in sysctl net.core.flow_limit_cpu_bitmap. It exposes the same CPU
  215. bitmap interface as rps_cpus (see above) when called from procfs::
  216. /proc/sys/net/core/flow_limit_cpu_bitmap
  217. Per-flow rate is calculated by hashing each packet into a hashtable
  218. bucket and incrementing a per-bucket counter. The hash function is
  219. the same that selects a CPU in RPS, but as the number of buckets can
  220. be much larger than the number of CPUs, flow limit has finer-grained
  221. identification of large flows and fewer false positives. The default
  222. table has 4096 buckets. This value can be modified through sysctl::
  223. net.core.flow_limit_table_len
  224. The value is only consulted when a new table is allocated. Modifying
  225. it does not update active tables.
  226. Suggested Configuration
  227. ~~~~~~~~~~~~~~~~~~~~~~~
  228. Flow limit is useful on systems with many concurrent connections,
  229. where a single connection taking up 50% of a CPU indicates a problem.
  230. In such environments, enable the feature on all CPUs that handle
  231. network rx interrupts (as set in /proc/irq/N/smp_affinity).
  232. The feature depends on the input packet queue length to exceed
  233. the flow limit threshold (50%) + the flow history length (256).
  234. Setting net.core.netdev_max_backlog to either 1000 or 10000
  235. performed well in experiments.
  236. RFS: Receive Flow Steering
  237. ==========================
  238. While RPS steers packets solely based on hash, and thus generally
  239. provides good load distribution, it does not take into account
  240. application locality. This is accomplished by Receive Flow Steering
  241. (RFS). The goal of RFS is to increase datacache hitrate by steering
  242. kernel processing of packets to the CPU where the application thread
  243. consuming the packet is running. RFS relies on the same RPS mechanisms
  244. to enqueue packets onto the backlog of another CPU and to wake up that
  245. CPU.
  246. In RFS, packets are not forwarded directly by the value of their hash,
  247. but the hash is used as index into a flow lookup table. This table maps
  248. flows to the CPUs where those flows are being processed. The flow hash
  249. (see RPS section above) is used to calculate the index into this table.
  250. The CPU recorded in each entry is the one which last processed the flow.
  251. If an entry does not hold a valid CPU, then packets mapped to that entry
  252. are steered using plain RPS. Multiple table entries may point to the
  253. same CPU. Indeed, with many flows and few CPUs, it is very likely that
  254. a single application thread handles flows with many different flow hashes.
  255. rps_sock_flow_table is a global flow table that contains the *desired* CPU
  256. for flows: the CPU that is currently processing the flow in userspace.
  257. Each table value is a CPU index that is updated during calls to recvmsg
  258. and sendmsg (specifically, inet_recvmsg(), inet_sendmsg() and
  259. tcp_splice_read()).
  260. When the scheduler moves a thread to a new CPU while it has outstanding
  261. receive packets on the old CPU, packets may arrive out of order. To
  262. avoid this, RFS uses a second flow table to track outstanding packets
  263. for each flow: rps_dev_flow_table is a table specific to each hardware
  264. receive queue of each device. Each table value stores a CPU index and a
  265. counter. The CPU index represents the *current* CPU onto which packets
  266. for this flow are enqueued for further kernel processing. Ideally, kernel
  267. and userspace processing occur on the same CPU, and hence the CPU index
  268. in both tables is identical. This is likely false if the scheduler has
  269. recently migrated a userspace thread while the kernel still has packets
  270. enqueued for kernel processing on the old CPU.
  271. The counter in rps_dev_flow_table values records the length of the current
  272. CPU's backlog when a packet in this flow was last enqueued. Each backlog
  273. queue has a head counter that is incremented on dequeue. A tail counter
  274. is computed as head counter + queue length. In other words, the counter
  275. in rps_dev_flow[i] records the last element in flow i that has
  276. been enqueued onto the currently designated CPU for flow i (of course,
  277. entry i is actually selected by hash and multiple flows may hash to the
  278. same entry i).
  279. And now the trick for avoiding out of order packets: when selecting the
  280. CPU for packet processing (from get_rps_cpu()) the rps_sock_flow table
  281. and the rps_dev_flow table of the queue that the packet was received on
  282. are compared. If the desired CPU for the flow (found in the
  283. rps_sock_flow table) matches the current CPU (found in the rps_dev_flow
  284. table), the packet is enqueued onto that CPU’s backlog. If they differ,
  285. the current CPU is updated to match the desired CPU if one of the
  286. following is true:
  287. - The current CPU's queue head counter >= the recorded tail counter
  288. value in rps_dev_flow[i]
  289. - The current CPU is unset (>= nr_cpu_ids)
  290. - The current CPU is offline
  291. After this check, the packet is sent to the (possibly updated) current
  292. CPU. These rules aim to ensure that a flow only moves to a new CPU when
  293. there are no packets outstanding on the old CPU, as the outstanding
  294. packets could arrive later than those about to be processed on the new
  295. CPU.
  296. RFS Configuration
  297. -----------------
  298. RFS is only available if the kconfig symbol CONFIG_RPS is enabled (on
  299. by default for SMP). The functionality remains disabled until explicitly
  300. configured. The number of entries in the global flow table is set through::
  301. /proc/sys/net/core/rps_sock_flow_entries
  302. The number of entries in the per-queue flow table are set through::
  303. /sys/class/net/<dev>/queues/rx-<n>/rps_flow_cnt
  304. Suggested Configuration
  305. ~~~~~~~~~~~~~~~~~~~~~~~
  306. Both of these need to be set before RFS is enabled for a receive queue.
  307. Values for both are rounded up to the nearest power of two. The
  308. suggested flow count depends on the expected number of active connections
  309. at any given time, which may be significantly less than the number of open
  310. connections. We have found that a value of 32768 for rps_sock_flow_entries
  311. works fairly well on a moderately loaded server.
  312. For a single queue device, the rps_flow_cnt value for the single queue
  313. would normally be configured to the same value as rps_sock_flow_entries.
  314. For a multi-queue device, the rps_flow_cnt for each queue might be
  315. configured as rps_sock_flow_entries / N, where N is the number of
  316. queues. So for instance, if rps_sock_flow_entries is set to 32768 and there
  317. are 16 configured receive queues, rps_flow_cnt for each queue might be
  318. configured as 2048.
  319. Accelerated RFS
  320. ===============
  321. Accelerated RFS is to RFS what RSS is to RPS: a hardware-accelerated load
  322. balancing mechanism that uses soft state to steer flows based on where
  323. the application thread consuming the packets of each flow is running.
  324. Accelerated RFS should perform better than RFS since packets are sent
  325. directly to a CPU local to the thread consuming the data. The target CPU
  326. will either be the same CPU where the application runs, or at least a CPU
  327. which is local to the application thread’s CPU in the cache hierarchy.
  328. To enable accelerated RFS, the networking stack calls the
  329. ndo_rx_flow_steer driver function to communicate the desired hardware
  330. queue for packets matching a particular flow. The network stack
  331. automatically calls this function every time a flow entry in
  332. rps_dev_flow_table is updated. The driver in turn uses a device specific
  333. method to program the NIC to steer the packets.
  334. The hardware queue for a flow is derived from the CPU recorded in
  335. rps_dev_flow_table. The stack consults a CPU to hardware queue map which
  336. is maintained by the NIC driver. This is an auto-generated reverse map of
  337. the IRQ affinity table shown by /proc/interrupts. Drivers can use
  338. functions in the cpu_rmap (“CPU affinity reverse map”) kernel library
  339. to populate the map. For each CPU, the corresponding queue in the map is
  340. set to be one whose processing CPU is closest in cache locality.
  341. Accelerated RFS Configuration
  342. -----------------------------
  343. Accelerated RFS is only available if the kernel is compiled with
  344. CONFIG_RFS_ACCEL and support is provided by the NIC device and driver.
  345. It also requires that ntuple filtering is enabled via ethtool. The map
  346. of CPU to queues is automatically deduced from the IRQ affinities
  347. configured for each receive queue by the driver, so no additional
  348. configuration should be necessary.
  349. Suggested Configuration
  350. ~~~~~~~~~~~~~~~~~~~~~~~
  351. This technique should be enabled whenever one wants to use RFS and the
  352. NIC supports hardware acceleration.
  353. XPS: Transmit Packet Steering
  354. =============================
  355. Transmit Packet Steering is a mechanism for intelligently selecting
  356. which transmit queue to use when transmitting a packet on a multi-queue
  357. device. This can be accomplished by recording two kinds of maps, either
  358. a mapping of CPU to hardware queue(s) or a mapping of receive queue(s)
  359. to hardware transmit queue(s).
  360. 1. XPS using CPUs map
  361. The goal of this mapping is usually to assign queues
  362. exclusively to a subset of CPUs, where the transmit completions for
  363. these queues are processed on a CPU within this set. This choice
  364. provides two benefits. First, contention on the device queue lock is
  365. significantly reduced since fewer CPUs contend for the same queue
  366. (contention can be eliminated completely if each CPU has its own
  367. transmit queue). Secondly, cache miss rate on transmit completion is
  368. reduced, in particular for data cache lines that hold the sk_buff
  369. structures.
  370. 2. XPS using receive queues map
  371. This mapping is used to pick transmit queue based on the receive
  372. queue(s) map configuration set by the administrator. A set of receive
  373. queues can be mapped to a set of transmit queues (many:many), although
  374. the common use case is a 1:1 mapping. This will enable sending packets
  375. on the same queue associations for transmit and receive. This is useful for
  376. busy polling multi-threaded workloads where there are challenges in
  377. associating a given CPU to a given application thread. The application
  378. threads are not pinned to CPUs and each thread handles packets
  379. received on a single queue. The receive queue number is cached in the
  380. socket for the connection. In this model, sending the packets on the same
  381. transmit queue corresponding to the associated receive queue has benefits
  382. in keeping the CPU overhead low. Transmit completion work is locked into
  383. the same queue-association that a given application is polling on. This
  384. avoids the overhead of triggering an interrupt on another CPU. When the
  385. application cleans up the packets during the busy poll, transmit completion
  386. may be processed along with it in the same thread context and so result in
  387. reduced latency.
  388. XPS is configured per transmit queue by setting a bitmap of
  389. CPUs/receive-queues that may use that queue to transmit. The reverse
  390. mapping, from CPUs to transmit queues or from receive-queues to transmit
  391. queues, is computed and maintained for each network device. When
  392. transmitting the first packet in a flow, the function get_xps_queue() is
  393. called to select a queue. This function uses the ID of the receive queue
  394. for the socket connection for a match in the receive queue-to-transmit queue
  395. lookup table. Alternatively, this function can also use the ID of the
  396. running CPU as a key into the CPU-to-queue lookup table. If the
  397. ID matches a single queue, that is used for transmission. If multiple
  398. queues match, one is selected by using the flow hash to compute an index
  399. into the set. When selecting the transmit queue based on receive queue(s)
  400. map, the transmit device is not validated against the receive device as it
  401. requires expensive lookup operation in the datapath.
  402. The queue chosen for transmitting a particular flow is saved in the
  403. corresponding socket structure for the flow (e.g. a TCP connection).
  404. This transmit queue is used for subsequent packets sent on the flow to
  405. prevent out of order (ooo) packets. The choice also amortizes the cost
  406. of calling get_xps_queues() over all packets in the flow. To avoid
  407. ooo packets, the queue for a flow can subsequently only be changed if
  408. skb->ooo_okay is set for a packet in the flow. This flag indicates that
  409. there are no outstanding packets in the flow, so the transmit queue can
  410. change without the risk of generating out of order packets. The
  411. transport layer is responsible for setting ooo_okay appropriately. TCP,
  412. for instance, sets the flag when all data for a connection has been
  413. acknowledged.
  414. XPS Configuration
  415. -----------------
  416. XPS is only available if the kconfig symbol CONFIG_XPS is enabled (on by
  417. default for SMP). If compiled in, it is driver dependent whether, and
  418. how, XPS is configured at device init. The mapping of CPUs/receive-queues
  419. to transmit queue can be inspected and configured using sysfs:
  420. For selection based on CPUs map::
  421. /sys/class/net/<dev>/queues/tx-<n>/xps_cpus
  422. For selection based on receive-queues map::
  423. /sys/class/net/<dev>/queues/tx-<n>/xps_rxqs
  424. Suggested Configuration
  425. ~~~~~~~~~~~~~~~~~~~~~~~
  426. For a network device with a single transmission queue, XPS configuration
  427. has no effect, since there is no choice in this case. In a multi-queue
  428. system, XPS is preferably configured so that each CPU maps onto one queue.
  429. If there are as many queues as there are CPUs in the system, then each
  430. queue can also map onto one CPU, resulting in exclusive pairings that
  431. experience no contention. If there are fewer queues than CPUs, then the
  432. best CPUs to share a given queue are probably those that share the cache
  433. with the CPU that processes transmit completions for that queue
  434. (transmit interrupts).
  435. For transmit queue selection based on receive queue(s), XPS has to be
  436. explicitly configured mapping receive-queue(s) to transmit queue(s). If the
  437. user configuration for receive-queue map does not apply, then the transmit
  438. queue is selected based on the CPUs map.
  439. Per TX Queue rate limitation
  440. ============================
  441. These are rate-limitation mechanisms implemented by HW, where currently
  442. a max-rate attribute is supported, by setting a Mbps value to::
  443. /sys/class/net/<dev>/queues/tx-<n>/tx_maxrate
  444. A value of zero means disabled, and this is the default.
  445. Further Information
  446. ===================
  447. RPS and RFS were introduced in kernel 2.6.35. XPS was incorporated into
  448. 2.6.38. Original patches were submitted by Tom Herbert
  449. (therbert@google.com)
  450. Accelerated RFS was introduced in 2.6.35. Original patches were
  451. submitted by Ben Hutchings (bwh@kernel.org)
  452. Authors:
  453. - Tom Herbert (therbert@google.com)
  454. - Willem de Bruijn (willemb@google.com)