From patchwork Wed Sep 19 19:55:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Gora X-Patchwork-Id: 44979 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F18151B144; Wed, 19 Sep 2018 21:56:33 +0200 (CEST) Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by dpdk.org (Postfix) with ESMTP id 997DB1B139 for ; Wed, 19 Sep 2018 21:56:31 +0200 (CEST) Received: by mail-qt0-f196.google.com with SMTP id t39-v6so6303989qtc.8 for ; Wed, 19 Sep 2018 12:56:31 -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=tB/2EJyp2DqxuqeCx3cu4cWQhnJqCkB6QueQXqBozcE=; b=s8emZmjBni2LSi65F5mKvq5dmtu1pav/SwIgzKL3JFfesHe7Jnpy2UZsH0Dz1Qsz2B k8ETnpVIxL6oibeKexpXs94cAfyV9nxe7DyXWGT/PgPItfJqowX1/0VkVa2CxnBYYQD0 GYTwELoXX05D2nutDCvG2GofuaJlhPtc9om4xWj44dVFDMXqROCHv03MSInyYhLfU18W GsImeDn7PlBg4QQJVNfsy7rQ8uOE18t1+jMrv2IZyfGeUOejOfvF8tjJas9ZSAz/NTdD 1P2wfBxHevWR5VMr0cstpawVGWx4SXVvN65QIkFhCkIPXaxraevT7F608qqT5dcFU399 Z2eQ== 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=tB/2EJyp2DqxuqeCx3cu4cWQhnJqCkB6QueQXqBozcE=; b=BaJCTYmV/QQyQi3tW9E0UkNuIJqD+sP+jKl7acYeAEcp8YDcWbI25+RbstIp8Hr4zn bEO49xfMsT60aVzGlPQQvT6ojy0pUnJpKPgQlp6LwsDFMcs9ktEzmR6soze7pESbOlvh 7PTWUHcPfiWLOZZStk5ywiGCKfikOmikXp3OtXkQDyzk3DgW9BBXtdL5G+knUk2ju3De o1CKENTMFHDLWzEFuaE2JAyNzUUm2xk40oL0txBXOoVeTh/qy0NhiEAkJG+96fSn1AuI AtALXDa89ilN1+2kNpBSCf06TKoGjuXOq0R6mLGZm/LiBHz4ZoWrdbQAXsclK4aaylqM jhlg== X-Gm-Message-State: APzg51DjDjdcLXxgjSZYlFEB2QmTq+FGtZqs5v0P+il08EVdbfrxygtm cgvp7T8S7QMNi6sG0tOAmk6KeBMR X-Google-Smtp-Source: ANB0VdafN/pn3aKuIRFqE82uRIPlIUIrTcou844tpOhITIUFjrzZX7503HMuczi245SctV0MfwNUBQ== X-Received: by 2002:ac8:376c:: with SMTP id p41-v6mr25652136qtb.225.1537386990679; Wed, 19 Sep 2018 12:56:30 -0700 (PDT) Received: from snappy.local.lan ([187.10.145.241]) by smtp.gmail.com with ESMTPSA id g184-v6sm12431369qkb.15.2018.09.19.12.56.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Sep 2018 12:56:29 -0700 (PDT) From: Dan Gora To: dev@dpdk.org Cc: Igor Ryzhov , Stephen Hemminger , Dan Gora , Ferruh Yigit Date: Wed, 19 Sep 2018 16:55:49 -0300 Message-Id: <20180919195549.5585-6-dg@adax.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180919195549.5585-1-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> <20180919195549.5585-1-dg@adax.com> MIME-Version: 1.0 Subject: [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: , 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 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);