From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hJm2Nz7jWrFJUyXegi5KeKO7sLlN5Uz928Q+fW2s80k=; b=E9MFnC5yAJoLkVipzMVUF82P5VsPiOFz4KHQq+eLv6eVMV021ZahTDZfTpOYs5QMr2 5io2dYWc6nXxnBH/CtApLicHFy1sZdofc2LoDlR7toLAtXipbApVhV1kG9uqnG9kI8+P HlNbdG7658gw4DKdulJA+qCuxvTj7vyur6rKTx98GCJdldDVQ3z27DzaAwmRqe78KuXb X3qbJQhF1fAtDqetRun9nju1nnm+4RkDz6axQHflUqTaCKweZdmK5t8eQMV+RHRQ3Shs hztjzY7ryPgGgG6V4oz/35wtyBXKw1lFJOlRc3CquRBYKN1ICcgOKHTzq2rpid4Iuaaa 2AvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=hJm2Nz7jWrFJUyXegi5KeKO7sLlN5Uz928Q+fW2s80k=; b=INzfkKAPsZECptQceoS741yKfp9FVmDGUyV/k5BZNBdNhBhCQiIdMEl+I2L1BtPgPt v+BGY/OPCnZ1udgRG+S1snE+4Vx3/m54sKYQTyBSO+dsTSihnbwpbNuvHSDynp+jIuFh GJOf6zpMdCaGzFzSNRWgAD+VLgGWERNhK7N+DIWbFkTomShEmNYsbIql3Lt/lCeFvScO y+SC33W270wpPzS+MMlp6O5aWfBAC+qEdcAB/nidRu8hzn9P4aXAT94DDb4fqVtxOleO pAQSHMEOu/+U62+FDtKTHXwBVDMOKp4bdzQeo3KnTDjsSzZ4F381g3H0IWktwhaYQj0I kYTg== X-Gm-Message-State: ABuFfojNS6p31IeSJ4nviouT8WaEMLsADvJuxZsFqnyTaamckeqgRAfo T1z/dJVkwUWmhMN6nnj69Jw4C9Wd5+4= X-Google-Smtp-Source: ACcGV61vDquaGJXIXgw5hJnxNVcJzSdsPd1DQ37A7smWLjS7vEbzqbEz4RmLa1KvmhLPR/oHEAZSIg== X-Received: by 2002:a37:634e:: with SMTP id x75-v6mr4041099qkb.122.1539738291885; Tue, 16 Oct 2018 18:04:51 -0700 (PDT) Received: from snappy.local.lan ([187.74.142.5]) by smtp.gmail.com with ESMTPSA id v54-v6sm19547508qtc.81.2018.10.16.18.04.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Oct 2018 18:04:51 -0700 (PDT) Sender: Dan Gora From: Dan Gora To: dev@dpdk.org Cc: Igor Ryzhov , Stephen Hemminger , Ferruh Yigit , Dan Gora Date: Tue, 16 Oct 2018 22:04:13 -0300 Message-Id: <20181017010412.23141-7-dg@adax.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180911232906.18352-1-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 6/6] 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, 17 Oct 2018 01:04:53 -0000 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