summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKevin Traynor <ktraynor@redhat.com>2017-11-23 19:41:55 +0000
committerIan Stokes <ian.stokes@intel.com>2017-12-08 21:42:54 +0000
commita130f1a89bd8ec1176ac8d35a98c284a5e3f5691 (patch)
treee08562c4525420c765fc65bc15104eb66eb9c57a /lib
parent255b7bda98974c9732c435c3d500d50e20bd728e (diff)
downloadopenvswitch-a130f1a89bd8ec1176ac8d35a98c284a5e3f5691.tar.gz
dpif-netdev: Add port/queue tiebreaker to rxq_cycle_sort.
rxq_cycle_sort is used to compare rx queues by their measured number of cycles. In the event that they are equal, 0 could be returned. However, it is observed that returning 0 results in a different sort order on Windows/Linux. This is ok in practice but it causes a unit test failure for "1007: PMD - pmd-cpu-mask/distribution of rx queues" when running on different OS's. In order to have a consistent sort result across multiple OS's, introduce a tiebreaker of port/queue. Fixes: 655856ef39b9 ("dpif-netdev: Change rxq_scheduling to use rxq processing cycles.") Reported-by: Alin Gabriel Serdean <aserdean@ovn.org> Tested-by: Alin Gabriel Serdean <aserdean@ovn.org> Co-authored-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/dpif-netdev.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index b1ef9a6a5..b5a1bfec3 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -3463,10 +3463,19 @@ rxq_cycle_sort(const void *a, const void *b)
dp_netdev_rxq_set_cycles(qa, RXQ_CYCLES_PROC_HIST, total_qa);
dp_netdev_rxq_set_cycles(qb, RXQ_CYCLES_PROC_HIST, total_qb);
- if (total_qa >= total_qb) {
- return -1;
+ if (total_qa != total_qb) {
+ return (total_qa < total_qb) ? 1 : -1;
+ } else {
+ /* Cycles are the same so tiebreak on port/queue id.
+ * Tiebreaking (as opposed to return 0) ensures consistent
+ * sort results across multiple OS's. */
+ if (qa->port->port_no != qb->port->port_no) {
+ return (qa->port->port_no > qb->port->port_no) ? 1 : -1;
+ } else {
+ return netdev_rxq_get_queue_id(qa->rx)
+ - netdev_rxq_get_queue_id(qb->rx);
+ }
}
- return 1;
}
/* Assign pmds to queues. If 'pinned' is true, assign pmds to pinned