From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by dpdk.org (Postfix) with ESMTP id 961EF1B396 for ; Thu, 27 Sep 2018 02:34:18 +0200 (CEST) Received: by mail-qt1-f194.google.com with SMTP id l16-v6so934783qtq.10 for ; Wed, 26 Sep 2018 17:34:18 -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=XajtgKiqjzZQSpraVqsSiDSw1ckFngYhJNl+DiOidKw=; b=dXg14jedQ2/tM4nWsxX9jhcRBPrv8s4a0zKVp+Y0MCqYVjKqT1fKpy4xsojPv8Ybz2 x3VV+k9NUnOpYRcAucuLN/9kqQnVGS5dHt7Fe5ga5cEZ9/nbJ8akEvGY0RErUj5TcEJY +/Fv1d7fnBya1Cc2tUtgurJ9Ru3WOajrhV23yOHrJN5GquVpru8hZjCDplxA4YFFPFgk QigPLJ0EF3Z5+AmEQiGwsUkx5wjQdfRYL2rvTXCuAtibLc4XR02c29Yl8ugddGV8P95p 3sdTHuetb8udvsCkKzDySE6qngWvWljMcXCNmQGKAsIHu6v1SwmgHTjQ3EG6PfWUtxpn HilQ== 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=XajtgKiqjzZQSpraVqsSiDSw1ckFngYhJNl+DiOidKw=; b=h2Mvg3EYmZdHqbU48ouwRZJhkDG3iG4ytgTneOFClaecd12ZVT1QWKaQAmx1ouk8b+ hsCqw6Zz4mjqvNs3YRJQKj3qldNtiqKOELDWC/KJMP8uBVOCfHsJMPz7+5sb+iBUPQlD EzQjVKUXihjpDVrY2ARZOzmvsinIDjR7cQJVMuxktqF5SmvIgLXdbEApBQAedHaRKyhl 7q7Cv8rg15gx8Ii1+FbnhspGk/1SgP9aoLb1jYzETHWpRVd5D6E4s5C2SGML5S/AhFTj 76mosY1hawO5QFsaWSBYAonmlXxMigw5e0X3iieDV8AFwBcJWR8a+ORSaY/aKVibnjjn 6FPw== X-Gm-Message-State: ABuFfoiFP4y87X+IQcEo2KqopKoFgozqJvsYRRrG/6TFFMvBMdsqLLRA Xzf+QsYBrxY4uryOD1xCD4adfpNd X-Google-Smtp-Source: ACcGV63NfvTmfZUIyVUx2UgdJ6Vzg9ghcUUdETJkEVqjvjNhKFoqV/TQWeK5ZesG4w7f7tc0tz9+ig== X-Received: by 2002:ac8:34bc:: with SMTP id w57-v6mr6507747qtb.239.1538008457662; Wed, 26 Sep 2018 17:34:17 -0700 (PDT) Received: from snappy.local.lan (189-46-124-178.dsl.telesp.net.br. [189.46.124.178]) by smtp.gmail.com with ESMTPSA id x26-v6sm463053qth.15.2018.09.26.17.34.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Sep 2018 17:34:16 -0700 (PDT) Sender: Dan Gora From: Dan Gora To: dev@dpdk.org Cc: Igor Ryzhov , Stephen Hemminger , Ferruh Yigit , Dan Gora Date: Wed, 26 Sep 2018 21:32:56 -0300 Message-Id: <20180927003256.6901-7-dg@adax.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927003256.6901-1-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> <20180927003256.6901-1-dg@adax.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 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: Thu, 27 Sep 2018 00:34:19 -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 357cfd6fc..cda23b028 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