xps_flows: XPS flow steering when there is no socket
Subsystems (5)
v2 cover xps_flows: XPS flow steering when there is no socket
This patch set introduces transmit flow steering for socketless packets. The idea is that we record the transmit queues in a flow table that is indexed by skbuff hash. The flow table entries have two values: the queue_index and the head cnt of packets from the TX queue. We only allow a queue to change for a flow if the tail cnt in the TX queue advances beyond the recorded head cnt. That is the condition that should indicate that all outstanding packets for the flow have completed transmission so the queue can change.
Tracking the inflight queue is performed as part of DQL. Two fields are added to the dql structure: num_enqueue_ops and num_completed_ops. num_enqueue_ops incremented in dql_queued and num_completed_ops is incremented in dql_completed by the number of operations completed (a new argument to the function).
This patch set creates /sys/class/net/eth*/xps_dev_flow_table_cnt which number of entries in the XPS flow table.
Note that the functionality here is technically best effort (for instance we don't obtain a lock while processing a flow table entry). Under high load it is possible that OOO packets can still be generated due to XPS if two threads are hammering on the same flow table entry. The assumption of these patches is that OOO packets are not the end of the world and these should prevent OOO in most common use cases with XPS.
This is a followup to previous RFC version. Fixes from RFC are:
- Move counters to DQL
- Fixed typo
- Simplified get flow index funtion
- Fixed sysfs flow_table_cnt to properly use DEVICE_ATTR_RW
- Renamed the mechanism
V2:
- Added documentation in scaling.txt and sysfs documentation
- Call skb_tx_hash directly from get_xps_queue. This allows the socketless transmit flow steering to work properly if a flow is bouncing between non-XPS and XPS CPUS. (suggested by Alexander Duyck).
- Added a whold bunch of tested results provided by Rick Jones (Thanks Rick!)
Tested:
Manually forced all packets to go through the xps_flows path. Observed that some flows were deferred to change queues because packets were in flight witht the flow bucket.
Testing done by Rick Jones:
Here is a quick look at performance tests for the result of trying the prototype fix for the packet reordering problem with VMs sending over an XPS-configured NIC. In particular, the Emulex/Avago/Broadcom Skyhawk. The fix was applied to a 4.4 kernel.
Before: 3884 Mbit/s
After: 8897 Mbit/s
That was from a VM on a node with a Skyhawk and 2 E5-2640 processors to baremetal E5-2640 with a BE3. Physical MTU was 1500, the VM's vNIC's MTU was 1400. Systems were HPE ProLiants in OS Control Mode for power management, with the "performance" frequency governor loaded. An OpenStack Mitaka setup with Distributed Virtual Router.
We had some other NIC types in the setup as well. XPS was also enabled on the ConnectX3-Pro. It was not enabled on the 82599ES (a function of the kernel being used, which had it disabled from the first reports of XPS negatively affecting VM traffic at the beginning of the year)
Average Mbit/s From NIC type To Bare Metal BE3:
NIC Type,
CPU on VM Host Before After
------------------------------------------------
ConnectX-3 Pro,E5-2670v3 9224 9271 BE3, E5-2640 9016 9022 82599, E5-2640 9192 9003 BCM57840, E5-2640 9213 9153 Skyhawk, E5-2640 3884 8897
For completeness:
Average Mbit/s To NIC type from Bare Metal BE3:
NIC Type,
CPU on VM Host Before After
------------------------------------------------
ConnectX-3 Pro,E5-2670v3 9322 9144 BE3, E5-2640 9074 9017 82599, E5-2640 8670 8564 BCM57840, E5-2640 2468 * 7979 Skyhawk, E5-2640 8897 9269
* This is the Busted bnx2x NIC FW GRO implementation issue. It was not visible in the "After" because the system was setup to disable the NIC FW GRO by the time it booted on the fix kernel.
Average Transactions/s Between NIC type and Bare Metal BE3:
NIC Type,
CPU on VM Host Before After
------------------------------------------------
ConnectX-3 Pro,E5-2670v3 12421 12612
BE3, E5-2640 8178 8484 82599, E5-2640 8499 8549 BCM57840, E5-2640 8544 8560 Skyhawk, E5-2640 8537 8701
Tom Herbert (5):
net: Set SW hash in skb_set_hash_from_sk
dql: Add counters for number of queuing and completion operations
net: Add xps_dev_flow_table_cnt
xps_flows: XPS for packets that don't have a socket
xps: Documentation for transmit socketles flow steering
Documentation/ABI/testing/sysfs-class-net | 8 +++ Documentation/networking/scaling.txt | 26 ++++++++ include/linux/dynamic_queue_limits.h | 7 +- include/linux/netdevice.h | 26 +++++++- include/net/sock.h | 6 +- lib/dynamic_queue_limits.c | 3 +- net/Kconfig | 6 ++ net/core/dev.c | 87 +++++++++++++++++++------ net/core/net-sysfs.c | 103 ++++++++++++++++++++++++++++++ 9 files changed, 246 insertions(+), 26 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 1/5 net: Set SW hash in skb_set_hash_from_sk
Use the __skb_set_sw_hash to set the hash in an skbuff from the socket txhash.
--- include/net/sock.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
include/net/sock.h +2 -4
@@ -1920,10 +1920,8 @@ static inline void sock_poll_wait(struct file *filp,static inline void skb_set_hash_from_sk (struct sk_buff *skb,struct sock *sk) { -if (sk->sk_txhash) { - skb->l4_hash =1 ; - skb->hash = sk->sk_txhash; - } +if (sk->sk_txhash) +__skb_set_sw_hash (skb, sk->sk_txhash, true); }void skb_set_owner_w (struct sk_buff *skb,struct sock *sk);
Signature · 1 line
2.9.3
PATCH v2 2/5 dql: Add counters for number of queuing and completion operations
In reply to Tom HerbertAdd two new counters to struct dql that are num_enqueue_ops and num_completed_ops. num_enqueue_ops is incremented by one in each call to dql_queued. num_enqueue_ops is incremented in dql_completed which takes an argument indicating number of operations completed. These counters are only intended for statistics and do not impact the BQL algorithm.
We add a new sysfs entry in byte_queue_limits named inflight_pkts. This provides the number of packets in flight for the queue by dql->num_enqueue_ops - dql->num_completed_ops.
--- include/linux/dynamic_queue_limits.h | 7 ++++++- include/linux/netdevice.h | 2 +- lib/dynamic_queue_limits.c | 3 ++- net/core/net-sysfs.c | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-)
include/linux/dynamic_queue_limits.h +6 -1
@@ -43,6 +43,8 @@ struct dql {unsigned int adj_limit;/* limit + num_completed */ unsigned int last_obj_cnt;/* Count at last queuing */ +unsigned int num_enqueue_ops;/* Number of queue operations */ +/* Fields accessed only by completion path (dql_completed) */ unsigned int limit____cacheline_aligned_in_smp ;/* Current limit */
@@ -55,6 +57,8 @@ struct dql {unsigned int lowest_slack;/* Lowest slack found */ unsigned long slack_start_time;/* Time slacks seen */ +unsigned int num_completed_ops;/* Number of complete ops */ +/* Configuration */ unsigned int max_limit;/* Max limit */ unsigned int min_limit;/* Minimum limit */
@@ -83,6 +87,7 @@ static inline void dql_queued(struct dql *dql, unsigned int count)barrier (); dql->num_queued += count; + dql->num_enqueue_ops++; }/* Returns how many objects can be queued, < 0 indicates over limit. */
@@ -92,7 +97,7 @@ static inline int dql_avail(const struct dql *dql) }/* Record number of completed objects and recalculate the limit. */ -void dql_completed (struct dql *dql,unsigned int count); +void dql_completed (struct dql *dql,unsigned int count,unsigned int ops);/* Reset dql state */ void dql_reset (struct dql *dql);
include/linux/netdevice.h +1 -1
@@ -3015,7 +3015,7 @@ static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue,if (unlikely (!bytes))return ; -dql_completed (&dev_queue->dql, bytes); +dql_completed (&dev_queue->dql, bytes, pkts);/* * Without the memory barrier there is a small possiblity that
lib/dynamic_queue_limits.c +2 -1
@@ -14,7 +14,7 @@#define AFTER_EQ (A ,B ) ((int)((A) - (B)) >= 0)/* Records completed count and recalculates the queue limit */ -void dql_completed (struct dql *dql,unsigned int count) +void dql_completed (struct dql *dql,unsigned int count,unsigned int ops) {unsigned int inprogress, prev_inprogress, limit;unsigned int ovlimit, completed, num_queued;
@@ -108,6 +108,7 @@ void dql_completed(struct dql *dql, unsigned int count) dql->prev_ovlimit = ovlimit; dql->prev_last_obj_cnt = dql->last_obj_cnt; dql->num_completed = completed; + dql->num_completed_ops += ops; dql->prev_num_queued = num_queued; }EXPORT_SYMBOL (dql_completed);
net/core/net-sysfs.c +14 -0
@@ -1147,6 +1147,19 @@ static ssize_t bql_show_inflight(struct netdev_queue *queue,static struct netdev_queue_attribute bql_inflight_attribute =__ATTR (inflight,S_IRUGO , bql_show_inflight,NULL ); +static ssize_t bql_show_inflight_pkts (struct netdev_queue *queue, +struct netdev_queue_attribute *attr, +char *buf) +{ +struct dql *dql = &queue->dql; + +return sprintf (buf,"%u\n" , + dql->num_enqueue_ops - dql->num_completed_ops); +} + +static struct netdev_queue_attribute bql_inflight_pkts_attribute = +__ATTR (inflight_pkts,S_IRUGO , bql_show_inflight_pkts,NULL ); +#define BQL_ATTR (NAME ,FIELD ) \ static ssize_t bql_show_ ## NAME(struct netdev_queue *queue, \ struct netdev_queue_attribute *attr, \
@@ -1176,6 +1189,7 @@ static struct attribute *dql_attrs[] = { &bql_limit_min_attribute.attr, &bql_hold_time_attribute.attr, &bql_inflight_attribute.attr, + &bql_inflight_pkts_attribute.attr, NULL };
Signature · 1 line
2.9.3
PATCH v2 3/5 net: Add xps_dev_flow_table_cnt
In reply to Tom HerbertAdd infrastructure and definitions to create XFS flow tables. This creates the new sys entry /sys/class/net/eth*/xps_dev_flow_table_cnt
--- include/linux/netdevice.h | 24 +++++++++++++ net/core/net-sysfs.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+)
include/linux/netdevice.h +24 -0
@@ -736,6 +736,27 @@ struct xps_dev_maps { (nr_cpu_ids * sizeof(struct xps_map *)))#endif /* CONFIG_XPS */ +#ifdef CONFIG_XPS_FLOWS +struct xps_dev_flow { +union { +u64 v64; +struct { +int queue_index; +unsigned int queue_ptr; + }; + }; +}; + +struct xps_dev_flow_table { +unsigned int mask; +struct rcu_head rcu; +struct xps_dev_flow flows[0 ]; +}; +#define XPS_DEV_FLOW_TABLE_SIZE (_num) (sizeof(struct xps_dev_flow_table) + \ + ((_num) * sizeof(struct xps_dev_flow))) + +#endif /* CONFIG_XPS_FLOWS */ +#define TC_MAX_QUEUE 16#define TC_BITMASK 15/* HW offloaded queuing disciplines txq count and offset maps */
@@ -1825,6 +1846,9 @@ struct net_device {#ifdef CONFIG_XPS struct xps_dev_maps __rcu *xps_maps;#endif +#ifdef CONFIG_XPS_FLOWS +struct xps_dev_flow_table __rcu *xps_flow_table; +#endif #ifdef CONFIG_NET_CLS_ACT struct tcf_proto __rcu *egress_cl_list;#endif
net/core/net-sysfs.c +89 -0
101 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 4/5 xps_flows: XPS for packets that don't have a socket
In reply to Tom Herbertxps_flows maintains a per device flow table that is indexed by the skbuff hash. The table is only consulted when there is no queue saved in a transmit socket for an skbuff.
Each entry in the flow table contains a queue index and a queue pointer. The queue pointer is set when a queue is chosen using a flow table entry. This pointer is set to the head pointer in the transmit queue (which is maintained by BQL).
The new function get_xps_flows_index that looks up flows in the xps_flows table. The entry returned gives the last queue a matching flow used. The returned queue is compared against the normal XPS queue. If they are different, then we only switch if the tail pointer in the TX queue has advanced past the pointer saved in the entry. In this way OOO should be avoided when XPS wants to use a different queue.
--- net/Kconfig | 6 ++++ net/core/dev.c | 87 +++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 74 insertions(+), 19 deletions(-)
net/Kconfig +6 -0
@@ -255,6 +255,12 @@ config XPS depends on SMP default y +config XPS_FLOWS + bool + depends on XPS + depends on BQL + default y + config HWBM bool
net/core/dev.c +68 -19
118 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 5/5 xps: Documentation for transmit socketles flow steering
In reply to Tom Herbert--- Documentation/ABI/testing/sysfs-class-net | 8 ++++++++ Documentation/networking/scaling.txt | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
Documentation/ABI/testing/sysfs-class-net +8 -0
@@ -251,3 +251,11 @@ Contact: [email protected] Description: Indicates the unique physical switch identifier of a switch this port belongs to, as a string. + +What: /sys/class/net/<iface>/xps_dev_flow_table_cnt +Date: October 2016 +KernelVersion: 4.8 +Contact: [email protected] +Description: + Indicates the number of entries in the XPS socketless flow + table.
Documentation/networking/scaling.txt +26 -0
@@ -400,6 +400,26 @@ transport layer is responsible for setting ooo_okay appropriately. TCP, for instance, sets the flag when all data for a connection has been acknowledged. +XPS: Transmit Socketless Flow Steering +====================================== + +Not all flows have an associated socket in which the transmit queue and +ooo information can be saved. For instance, packets being transmitted over +OVS for VMs do not have a socket that is visible to the kernel. To allow +XPS to be effectively used a flow hash table is employed to save queue and +ooo information for such socketless flows. + +The idea is that transmit queues are saved for socketless flows in a +flow table that is indexed by skbuff hash. The flow table entries have +two values: the queue_index and the head cnt of packets from the TX +queue. When a packet is being sent without an associated socket the +hash table is consulted which returns the queue_index to use. The +returned queue is compared to the queue that would be selected by XPS. +If they are are different the XPS queue is selected only if the tail cnt +in the TX queue advances beyond the recorded head cnt. This checks if +sending the packet on the new queue could cause ooo packets for the +flow. + ==== XPS Configuration XPS is only available if the kconfig symbol CONFIG_XPS is enabled (on by
@@ -409,6 +429,12 @@ queue is configured using the sysfs file entry: /sys/class/net/<dev>/queues/tx-<n>/xps_cpus +Transmit socketless flow steering is enabled by setting the number of +entries in the XPS flow table. This is configured in the sysfs file +entry: + +/sys/class/net/<dev>/xps_dev_flow_table_cnt + == Suggested Configuration For a network device with a single transmission queue, XPS configuration
Signature · 1 line
2.9.3
Re: [PATCH v2 net-next 4/5] xps_flows: XPS for packets that don't have a socket
In reply to Tom HerbertQuoted 9 lines · Tom Herbert
xps_flowsmaintains a per device flow table that is indexed by the skbuff hash. The table is only consulted when there is no queue saved in a transmit socket for an skbuff.Each entry in the flow table contains a queue index and a queue pointer. The queue pointer is set when a queue is chosen using a flow table entry. This pointer is set to the head pointer in the transmit queue (which is maintained by BQL).
Quoted 6 lines
The new function
get_xps_flows_indexthat looks up flows in thexps_flowstable. The entry returned gives the last queue a matching flow used. The returned queue is compared against the normal XPS queue. If they are different, then we only switch if the tail pointer in the TX queue has advanced past the pointer saved in the entry. In this way OOO should be avoided when XPS wants to use a different queue.
There is something I do not understand with this.
If this OOO avoidance is tied to BQL, it means that packets sitting in a qdisc wont be part of the detection.
So packets of flow X could possibly be queued on multiple qdiscs.
Re: [PATCH v2 net-next 4/5] xps_flows: XPS for packets that don't have a socket
Quoted 17 lines · Eric Dumazet
Quoted 9 lines · Tom Herbert
xps_flowsmaintains a per device flow table that is indexed by the skbuff hash. The table is only consulted when there is no queue saved in a transmit socket for an skbuff.Each entry in the flow table contains a queue index and a queue pointer. The queue pointer is set when a queue is chosen using a flow table entry. This pointer is set to the head pointer in the transmit queue (which is maintained by BQL).
Quoted 6 lines
The new function
get_xps_flows_indexthat looks up flows in thexps_flowstable. The entry returned gives the last queue a matching flow used. The returned queue is compared against the normal XPS queue. If they are different, then we only switch if the tail pointer in the TX queue has advanced past the pointer saved in the entry. In this way OOO should be avoided when XPS wants to use a different queue.
Quoted 7 lines
There is something I do not understand with this.
If this OOO avoidance is tied to BQL, it means that packets sitting in a qdisc wont be part of the detection.
So packets of flow X could possibly be queued on multiple qdiscs.
Hi Eric,
I'm not sure I understand your concern. If packets for flow X can be queued on multiple qdiscs wouldn't that mean that flow will be subject to ooo transmission regardless of this patch? In other words here we're trying to keep packets for the flow in order as they are emitted from the qdiscs which we assume maintains ordering of packets in a flow.
Tom
Quoted 2 lines
Re: [PATCH v2 net-next 4/5] xps_flows: XPS for packets that don't have a socket
Quoted 25 lines · Tom Herbert
Quoted 17 lines · Eric Dumazet
Quoted 9 lines · Tom Herbert
xps_flowsmaintains a per device flow table that is indexed by the skbuff hash. The table is only consulted when there is no queue saved in a transmit socket for an skbuff.Each entry in the flow table contains a queue index and a queue pointer. The queue pointer is set when a queue is chosen using a flow table entry. This pointer is set to the head pointer in the transmit queue (which is maintained by BQL).
Quoted 6 lines
The new function
get_xps_flows_indexthat looks up flows in thexps_flowstable. The entry returned gives the last queue a matching flow used. The returned queue is compared against the normal XPS queue. If they are different, then we only switch if the tail pointer in the TX queue has advanced past the pointer saved in the entry. In this way OOO should be avoided when XPS wants to use a different queue.Quoted 7 lines
There is something I do not understand with this.
If this OOO avoidance is tied to BQL, it means that packets sitting in a qdisc wont be part of the detection.
So packets of flow X could possibly be queued on multiple qdiscs.
Quoted 8 lines
Hi Eric,
I'm not sure I understand your concern. If packets for flow X can be queued on multiple qdiscs wouldn't that mean that flow will be subject to ooo transmission regardless of this patch? In other words here we're trying to keep packets for the flow in order as they are emitted from the qdiscs which we assume maintains ordering of packets in a flow.
Well, then what this patch series is solving ?
You have a producer of packets running on 8 vcpus in a VM.
Packets are exiting the VM and need to be queued on a mq NIC in the hypervisor.
Flow X can be scheduled on any of these 8 vcpus, so XPS is currently selecting different TXQ.
Your patch aims to detect this and steer packets to one TXQ, but not using a static hash() % num_real_queues (as RSS would have done on a NIC at RX), but trying to please XPS (as : selecting a queue close to the CPU producing the packet. VM with one vcpu, and cpu bounded, would really be happy to not spread packets all over the queues)
Your mechanism relies on counters updated at the time packets are given to the NIC, not at the time packets are given to the txq (and eventually sit for a while in the qdisc right before BQL layer)
dev_queue_xmit() is not talking to the device directly...
All I am saying is that the producer/consumer counters you added are not at the right place.
You tried hard to not change the drivers, by adding something to existing BQL. But packets can sit in a qdisc for a while...
So you added 2 potential cache lines misses per outgoing packet, but with no guarantee that OOO are really avoided.
Re: [PATCH v2 net-next 4/5] xps_flows: XPS for packets that don't have a socket
Quoted 28 lines · Eric Dumazet
Quoted 27 lines · Tom Herbert
Quoted 17 lines · Eric Dumazet
Quoted 9 lines · Tom Herbert
xps_flowsmaintains a per device flow table that is indexed by the skbuff hash. The table is only consulted when there is no queue saved in a transmit socket for an skbuff.Each entry in the flow table contains a queue index and a queue pointer. The queue pointer is set when a queue is chosen using a flow table entry. This pointer is set to the head pointer in the transmit queue (which is maintained by BQL).
Quoted 6 lines
The new function
get_xps_flows_indexthat looks up flows in thexps_flowstable. The entry returned gives the last queue a matching flow used. The returned queue is compared against the normal XPS queue. If they are different, then we only switch if the tail pointer in the TX queue has advanced past the pointer saved in the entry. In this way OOO should be avoided when XPS wants to use a different queue.Quoted 7 lines
There is something I do not understand with this.
If this OOO avoidance is tied to BQL, it means that packets sitting in a qdisc wont be part of the detection.
So packets of flow X could possibly be queued on multiple qdiscs.
Hi Eric,
Quoted 9 lines
Quoted 6 lines
I'm not sure I understand your concern. If packets for flow X can be queued on multiple qdiscs wouldn't that mean that flow will be subject to ooo transmission regardless of this patch? In other words here we're trying to keep packets for the flow in order as they are emitted from the qdiscs which we assume maintains ordering of packets in a flow.
Well, then what this patch series is solving ?
It addresses the issue that Rick Jones pointed out was happening with XPS. When packets are sent for a flow that has no socket and XPS is enabled then each packet uses the XPS queue based on the running CPU. Since the thread sending on a flow can be rescheduled on different CPUs this is creating ooo packets. In this case the ooo is being caused by interaction with XPS.
Quoted 5 lines
You have a producer of packets running on 8 vcpus in a VM.
Packets are exiting the VM and need to be queued on a mq NIC in the hypervisor.
Quoted 9 lines
Flow X can be scheduled on any of these 8 vcpus, so XPS is currently selecting different TXQ.
Your patch aims to detect this and steer packets to one TXQ, but not using a static
hash()%num_real_queues(as RSS would have done on a NIC at RX), but trying to please XPS (as : selecting a queue close to the CPU producing the packet. VM with one vcpu, and cpu bounded, would really be happy to not spread packets all over the queues)
You're not describing this patch, you're describing how XPS works in the first place. This patch is done to make socketless packets work well with XPS. If all you want is a static hash() % num_real_queues then just disable XPS to get that.
Quoted 4 lines
Your mechanism relies on counters updated at the time packets are given to the NIC, not at the time packets are given to the txq (and eventually sit for a while in the qdisc right before BQL layer)
Quoted 9 lines
dev_queue_xmit()is not talking to the device directly...All I am saying is that the producer/consumer counters you added are not at the right place.
You tried hard to not change the drivers, by adding something to existing BQL. But packets can sit in a qdisc for a while...
But again, this patch is to prevent ooo being caused by an interaction with XPS. It does not address ooo being caused by qdiscs or VMs, but then I don't see that as being the issue reported by Rick.
Quoted 5 lines
So you added 2 potential cache lines misses per outgoing packet, but with no guarantee that OOO are really avoided.
Re: [PATCH v2 net-next 4/5] xps_flows: XPS for packets that don't have a socket
Quoted 7 lines · Tom Herbert
It addresses the issue that Rick Jones pointed out was happening with XPS. When packets are sent for a flow that has no socket and XPS is enabled then each packet uses the XPS queue based on the running CPU. Since the thread sending on a flow can be rescheduled on different CPUs this is creating ooo packets. In this case the ooo is being caused by interaction with XPS.
Nope, your patch does not address the problem properly.
I am not sure I want to spend more time explaining the issue.
Lets talk about this in Tokyo next week.
Re: [PATCH v2 net-next 4/5] xps_flows: XPS for packets that don't have a socket
Quoted 10 lines · Eric Dumazet
Quoted 7 lines · Tom Herbert
It addresses the issue that Rick Jones pointed out was happening with XPS. When packets are sent for a flow that has no socket and XPS is enabled then each packet uses the XPS queue based on the running CPU. Since the thread sending on a flow can be rescheduled on different CPUs this is creating ooo packets. In this case the ooo is being caused by interaction with XPS.
Quoted 6 lines
Nope, your patch does not address the problem properly.
I am not sure I want to spend more time explaining the issue.
Lets talk about this in Tokyo next week.
Just as a reminder, sorry to bother you, stating some obvious facts for both of us. We have public exchanges, so we also need to re-explain how things work.
Queue selection on xmit happens before we hit the qdisc and its delays.
So when you access txq->dql.num_completed_ops and txq->dql.num_enqueue_ops you can observe values that do not change for a while.
Say a thread runs on a VM, and sends 2 packets P1, P2 on the same flow (skb_get_hash() returns the same value for these 2 packets)
P1 is sent on behalf of CPU 1, we pickup queue txq1, and queue the packet on its qdisc . Transmit does not happen because of some constraints like rate limiting or scheduling constraints.
P2 is sent on behalf of CPU 2, we pickup queue txq2, notice that prior packet chose txq1. We check txq1->dql and decide it is fine to use txq2, since the dql params of txq1 were not changed yet.
( txq->dql.num_completed_ops == ent.queue_ptr )
Note that in RFS case, we have the guarantee that we observe 'live queues' since they are the per cpu backlog.
So input_queue_head_incr() and input_queue_tail_incr_save() are correctly doing the OOO prevention, because a queued packet immediately changes the state.
So really your patch works if you have no qdisc, or a non congested qdisc. (Think if P1 is dropped by a full pfifo or pfifo_fast : We really want to avoid steering P2, P3, ..., PN on this full pfifo while maybe other txq are idle). Strange attractors are back (check commit 9b462d02d6dd6 )
You could avoid (ab)using BQL with a different method, grabbing skb->destructor for the packets that are socketless
The hash table would simply track the sum of skb->truesize to allow flow migration. This would be self contained and not intrusive.
Re: [PATCH v2 net-next 4/5] xps_flows: XPS for packets that don't have a socket
In reply to Eric DumazetQuoted 9 lines · Eric Dumazet
Well, then what this patch series is solving ?
You have a producer of packets running on 8 vcpus in a VM.
Packets are exiting the VM and need to be queued on a mq NIC in the hypervisor.
Flow X can be scheduled on any of these 8 vcpus, so XPS is currently selecting different TXQ.
Just for completeness, in my testing, the VMs were single-vCPU.
rick jones
Re: [PATCH v2 net-next 4/5] xps_flows: XPS for packets that don't have a socket
In reply to Eric DumazetQuoted 48 lines · Eric Dumazet
Quoted 10 lines · Eric Dumazet
Quoted 7 lines · Tom Herbert
It addresses the issue that Rick Jones pointed out was happening with XPS. When packets are sent for a flow that has no socket and XPS is enabled then each packet uses the XPS queue based on the running CPU. Since the thread sending on a flow can be rescheduled on different CPUs this is creating ooo packets. In this case the ooo is being caused by interaction with XPS.
Quoted 6 lines
Nope, your patch does not address the problem properly.
I am not sure I want to spend more time explaining the issue.
Lets talk about this in Tokyo next week.
Just as a reminder, sorry to bother you, stating some obvious facts for both of us. We have public exchanges, so we also need to re-explain how things work.
Queue selection on xmit happens before we hit the qdisc and its delays.
So when you access
txq->dql.num_completed_opsandtxq->dql.num_enqueue_opsyou can observe values that do not change for a while.Say a thread runs on a VM, and sends 2 packets P1, P2 on the same flow (
skb_get_hash()returns the same value for these 2 packets)P1 is sent on behalf of CPU 1, we pickup queue txq1, and queue the packet on its qdisc . Transmit does not happen because of some constraints like rate limiting or scheduling constraints.
P2 is sent on behalf of CPU 2, we pickup queue txq2, notice that prior packet chose txq1. We check
txq1->dqland decide it is fine to use txq2, since the dql params of txq1 were not changed yet.(
txq->dql.num_completed_ops== ent.queue_ptr )Note that in RFS case, we have the guarantee that we observe 'live queues' since they are the per cpu backlog.
So
input_queue_head_incr()andinput_queue_tail_incr_save()are correctly doing the OOO prevention, because a queued packet immediately changes the state.
Quoted 6 lines
So really your patch works if you have no qdisc, or a non congested qdisc. (Think if P1 is dropped by a full pfifo or
pfifo_fast: We really want to avoid steering P2, P3, ..., PN on this full pfifo while maybe other txq are idle). Strange attractors are back (check commit9b462d02d6dd6)
Understood.
Quoted 6 lines
You could avoid (ab)using BQL with a different method, grabbing
skb->destructorfor the packets that are socketlessThe hash table would simply track the sum of
skb->truesizeto allow flow migration. This would be self contained and not intrusive.
Okay, will look that.