From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Gora Subject: [PATCH v4 6/6] examples/kni: improve zeroing statistics Date: Tue, 16 Oct 2018 22:04:13 -0300 Message-ID: <20181017010412.23141-7-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Igor Ryzhov , Stephen Hemminger , Ferruh Yigit , Dan Gora To: dev@dpdk.org Return-path: Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by dpdk.org (Postfix) with ESMTP id D2C175B12 for ; Wed, 17 Oct 2018 03:04:52 +0200 (CEST) Received: by mail-qk1-f196.google.com with SMTP id 84-v6so15464382qkf.0 for ; Tue, 16 Oct 2018 18:04:52 -0700 (PDT) In-Reply-To: <20180911232906.18352-1-dg@adax.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The worker threads incrementing the rx/tx_packets race with the signal handler from the main thread zeroing the entire statistics structure. This can cause the statistics to fail to be zeroed, even when there is no traffic on those interfaces. Improve zeroing the statistics by only incrementing rx/tx_packets in worker threads by a non-zero amount. This limits the race to the periods in which traffic is actually being received or transmitted. Signed-off-by: Dan Gora --- examples/kni/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/kni/main.c b/examples/kni/main.c index 314e19c68..3ae4c13a2 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -223,7 +223,8 @@ kni_ingress(struct kni_port_params *p) } /* Burst tx to kni */ num = rte_kni_tx_burst(p->kni[i], pkts_burst, nb_rx); - kni_stats[port_id].rx_packets += num; + if (num) + kni_stats[port_id].rx_packets += num; rte_kni_handle_request(p->kni[i]); if (unlikely(num < nb_rx)) { @@ -260,7 +261,8 @@ kni_egress(struct kni_port_params *p) } /* Burst tx to eth */ nb_tx = rte_eth_tx_burst(port_id, 0, pkts_burst, (uint16_t)num); - kni_stats[port_id].tx_packets += nb_tx; + if (nb_tx) + kni_stats[port_id].tx_packets += nb_tx; if (unlikely(nb_tx < num)) { /* Free mbufs not tx to NIC */ kni_burst_free_mbufs(&pkts_burst[nb_tx], num - nb_tx); -- 2.19.0