]> git.proxmox.com Git - ovs.git/commitdiff
netdev-dpdk: Fix sw stats perf drop.
authorKevin Traynor <ktraynor@redhat.com>
Tue, 17 Dec 2019 15:07:37 +0000 (15:07 +0000)
committerIlya Maximets <i.maximets@ovn.org>
Wed, 18 Dec 2019 12:06:27 +0000 (13:06 +0100)
Accessing the sw stats in the vhost datapath of a PVP test
can incur a performance drop of ~2%.

Most of the time these stats will just be getting zero added
to them. By checking if there is a non-zero update first, we
can avoid accessing them when they won't be updated and avoid
the performance drop.

Fixes: 2f862c712e52 ("netdev-dpdk: Detailed packet drop statistics.")
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
lib/netdev-dpdk.c

index 663eef5b8d58a8f9cb2b8d883e15f65a4371a15b..f551284501aae903a04f3aff323cd2904c04a787 100644 (file)
@@ -2207,7 +2207,6 @@ netdev_dpdk_vhost_update_rx_counters(struct netdev_dpdk *dev,
                                      struct dp_packet **packets, int count,
                                      int qos_drops)
 {
-    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
     struct netdev_stats *stats = &dev->stats;
     struct dp_packet *packet;
     unsigned int packet_size;
@@ -2238,7 +2237,9 @@ netdev_dpdk_vhost_update_rx_counters(struct netdev_dpdk *dev,
         stats->rx_bytes += packet_size;
     }
 
-    sw_stats->rx_qos_drops += qos_drops;
+    if (OVS_UNLIKELY(qos_drops)) {
+        dev->sw_stats->rx_qos_drops += qos_drops;
+    }
 }
 
 /*
@@ -2402,7 +2403,6 @@ netdev_dpdk_vhost_update_tx_counters(struct netdev_dpdk *dev,
                                      int attempted,
                                      struct netdev_dpdk_sw_stats *sw_stats_add)
 {
-    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
     int dropped = sw_stats_add->tx_mtu_exceeded_drops +
                   sw_stats_add->tx_qos_drops +
                   sw_stats_add->tx_failure_drops;
@@ -2417,10 +2417,14 @@ netdev_dpdk_vhost_update_tx_counters(struct netdev_dpdk *dev,
         stats->tx_bytes += dp_packet_size(packets[i]);
     }
 
-    sw_stats->tx_retries            += sw_stats_add->tx_retries;
-    sw_stats->tx_failure_drops      += sw_stats_add->tx_failure_drops;
-    sw_stats->tx_mtu_exceeded_drops += sw_stats_add->tx_mtu_exceeded_drops;
-    sw_stats->tx_qos_drops          += sw_stats_add->tx_qos_drops;
+    if (OVS_UNLIKELY(dropped || sw_stats_add->tx_retries)) {
+        struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
+
+        sw_stats->tx_retries            += sw_stats_add->tx_retries;
+        sw_stats->tx_failure_drops      += sw_stats_add->tx_failure_drops;
+        sw_stats->tx_mtu_exceeded_drops += sw_stats_add->tx_mtu_exceeded_drops;
+        sw_stats->tx_qos_drops          += sw_stats_add->tx_qos_drops;
+    }
 }
 
 static void