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 39F01548B for ; Wed, 24 Oct 2018 22:27:51 +0200 (CEST) Received: by mail-qt1-f194.google.com with SMTP id p24-v6so1284563qtq.0 for ; Wed, 24 Oct 2018 13:27:51 -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=+6LWhTYsYoXPIT940Q4sXLq6n9xxmxPAOZVAMSdxNcE=; b=BnUUfLR+z+hViiCO3UlFHuAmmuG8fxpIyvbsXxgvagPCh5wNt1jGX30nAf3W9yT5L0 zyLJ/p7Reca2sQx+N+j7wnLrTDMKajBNJQOIVUg6VgycRLO5jNQ/TebIBVq9YbFyJ7pN tVNpuf+GaKfHX+U/x+CJTLg4bL7btAx1BLu+DBdoWxM//Lus+U/Fs/1nhU0z8xYR8lM4 0PIDulxQTOXkwGCA2SGqMu3gpK89qaBkSomajazSCqpuTGqhbV3OnZu2TIQMyQ2jFLqs KPPjsR7+1sw2dhu4WOGyFAtaVnb47mG9KPQ0NJjD86UtAxewOFnYVoxwSxlqHCgmkPAU Sh3w== 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=+6LWhTYsYoXPIT940Q4sXLq6n9xxmxPAOZVAMSdxNcE=; b=FIK4x+s0aLEf4Tb4KMVC2zxpxn8O3MIJysQR36iv1JJRf7n0bNPKd25La2eA5fennc ue3bFjOaKopg1E//VduQHqh48lSocd2AZKi65mMG/k+TlEbdl/ngezoeZf5ZJRzuLskd Ss4RjnfSMCPVhsnwO7RGUMPgxV6L1+XKiB59VsKzgY28JVJLj/4j1peo/YTu8HuHA2ar ZeaQnwpGp6Eo2KOVd7fn71A45KyfCRY/6TvgY4cVsdcRcAm2IX5dQ75d8f5XQ8GStqBB YlaqM+BOiovNrHH4IOHWmv9oSdwoTIFABHLmcz+QOWtWWmzntlP3qEUW0cWsF5X55/7x aZaA== X-Gm-Message-State: AGRZ1gLD3l+I8RtJvmIZ9X/gmgvb5VDcxgNqWRbrOMaKlIdEbnV4aGhb M+ZnNfItETIZigJxBjOIWYF3FwQS X-Google-Smtp-Source: AJdET5cR6ThDTeQm5FKCSVlmhtfuzvfSxrEf/DzuBHGrpPido7o7JDJJaThJZPmWZUptrH3rs1iFsg== X-Received: by 2002:ac8:23ad:: with SMTP id q42-v6mr4022826qtq.322.1540412870237; Wed, 24 Oct 2018 13:27:50 -0700 (PDT) Received: from snappy.local.lan ([179.228.213.114]) by smtp.gmail.com with ESMTPSA id p64-v6sm3509117qkc.96.2018.10.24.13.27.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Oct 2018 13:27:49 -0700 (PDT) Sender: Dan Gora From: Dan Gora To: dev@dpdk.org Cc: Igor Ryzhov , Stephen Hemminger , Ferruh Yigit , Dan Gora Date: Wed, 24 Oct 2018 17:27:19 -0300 Message-Id: <20181024202719.24902-6-dg@adax.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181024202719.24902-1-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> <20181024202719.24902-1-dg@adax.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 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, 24 Oct 2018 20:27:51 -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 0e3b2a2f7..e37b1ad36 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