From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 151FF1B3E8 for ; Wed, 26 Sep 2018 16:01:13 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2018 07:01:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,306,1534834800"; d="scan'208";a="260407125" Received: from fyigit-mobl.ger.corp.intel.com (HELO [10.237.221.39]) ([10.237.221.39]) by orsmga005.jf.intel.com with ESMTP; 26 Sep 2018 07:01:06 -0700 To: Dan Gora , dev@dpdk.org Cc: Igor Ryzhov , Stephen Hemminger References: <20180911232906.18352-1-dg@adax.com> <20180919195549.5585-1-dg@adax.com> <20180919195549.5585-6-dg@adax.com> From: Ferruh Yigit Openpgp: preference=signencrypt Message-ID: Date: Wed, 26 Sep 2018 15:01:05 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180919195549.5585-6-dg@adax.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2 5/5] examples/kni: improve zeroing statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2018 14:01:14 -0000 On 9/19/2018 8:55 PM, Dan Gora wrote: > 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. Not sure about introducing an extra check to datapath for possible error on stats zero. I am for dropping this patch, what do you think? > > 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 ca45347d8..d00569740 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); >