[ovs-dev] netdev-dpdk: Fix sw stats perf drop.
diff mbox series

Message ID 20191217150737.24039-1-ktraynor@redhat.com
State Accepted
Delegated to: Ilya Maximets
Headers show
Series
  • [ovs-dev] netdev-dpdk: Fix sw stats perf drop.
Related show

Commit Message

Kevin Traynor Dec. 17, 2019, 3:07 p.m. UTC
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>
---
 lib/netdev-dpdk.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Eelco Chaudron Dec. 18, 2019, 8:07 a.m. UTC | #1
On 17 Dec 2019, at 16:07, Kevin Traynor wrote:

> 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>
> ---

LGTM,

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Ilya Maximets Dec. 18, 2019, 12:11 p.m. UTC | #2
On 17.12.2019 16:07, Kevin Traynor wrote:
> 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>
> ---

We actually have similar checks for physical ports, so it's sane
to have them for vhost too.

Thanks Kevin and Eelco! Applied to master.

Best regards, Ilya Maximets.

Patch
diff mbox series

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 89c73a29b..238f29a2a 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2175,5 +2175,4 @@  netdev_dpdk_vhost_update_rx_counters(struct netdev_dpdk *dev,
                                      int qos_drops)
 {
-    struct netdev_dpdk_sw_stats *sw_stats = dev->sw_stats;
     struct netdev_stats *stats = &dev->stats;
     struct dp_packet *packet;
@@ -2206,5 +2205,7 @@  netdev_dpdk_vhost_update_rx_counters(struct netdev_dpdk *dev,
     }
 
-    sw_stats->rx_qos_drops += qos_drops;
+    if (OVS_UNLIKELY(qos_drops)) {
+        dev->sw_stats->rx_qos_drops += qos_drops;
+    }
 }
 
@@ -2370,5 +2371,4 @@  netdev_dpdk_vhost_update_tx_counters(struct netdev_dpdk *dev,
                                      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 +
@@ -2385,8 +2385,12 @@  netdev_dpdk_vhost_update_tx_counters(struct netdev_dpdk *dev,
     }
 
-    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;
+    }
 }