From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by dpdk.org (Postfix) with ESMTP id 4E0501B136 for ; Fri, 19 Oct 2018 02:24:49 +0200 (CEST) Received: by mail-qk1-f195.google.com with SMTP id x8-v6so20027921qka.4 for ; Thu, 18 Oct 2018 17:24:49 -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=jROYTLdS9ZbxCgodQ0gwlNg0/0Cl3FtobVn2mClMJfR+vlnuuwS1Phj7yQ79OpdgRY djVFABAVtvLO08cLOk0EngoBWuYlF/7eYazpSE9RANVGA9tBlhKyDGg75EhkjTs+ZZjP B9BqON2W6pLdEt3y9CqT6QBKLWt6pq0To3QEP4PZYefR81mR45z7ti8ESEnRTq/+UFVl LMBV+R/2KMwgPyK8jB1UY8t5h/TC9Sq9hIyUYz7DpQhvAwz2Wxa2n1h+OZxylh0496yV 1DpAOUCCEkVnyCnwxrYG9e9anLM4/NigOJWijxfb36PPCQYVUiZxPdeqo4/BnKXO2RNK FxJA== 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=sEIeWThAqhb58Fv/KRSPx/WPoCxwiWdlRy9MHnDGAvrNR+W5eJs7kK7zur+mtok+Yr FjeChatSHT1rKmci6KSegsjPEQ+jWbEEZliQK1tjUPG//ENi0Aq5jeJgTIczg+VylASm xFyXK7r9HHtB0bmWNjPh64dkiCTWweeNkVBfoID/6qqb0HNvYbvHt0+etHTR//kpbkSr +RIyAhaiuPVVTVbndGq3bF6h6fnRJLPvEBaux7VkuIf1gHirtnDKaKbji7EUoM//wjNT YHPztUR2YwnlC8PQtz15q2PbTY/QqtV49Y8uXydaLzrf4080AWzi4EWPSD2waWoid3sG Cj4g== X-Gm-Message-State: AGRZ1gLklT1dzVidIGZFXlk5fK4GGiDzqG7jC4MU+aEE51dN3rHc0VLi cEjIdUv/L6Uz3HGtu24gqZXuQhEY X-Google-Smtp-Source: ACcGV60nUScUbNbXGFUliaoluxz7AVnSk4RpoYmuAgNCCtA7z7i+NxLjqteTuYHwMLUUTBPQY8j3fQ== X-Received: by 2002:ae9:ee02:: with SMTP id i2-v6mr1277957qkg.0.1539908688307; Thu, 18 Oct 2018 17:24:48 -0700 (PDT) Received: from snappy.local.lan ([191.205.43.134]) by smtp.gmail.com with ESMTPSA id y124-v6sm12963926qke.22.2018.10.18.17.24.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 17:24:47 -0700 (PDT) Sender: Dan Gora From: Dan Gora To: dev@dpdk.org Cc: Igor Ryzhov , Stephen Hemminger , Ferruh Yigit , Dan Gora Date: Thu, 18 Oct 2018 21:23:58 -0300 Message-Id: <20181019002358.17132-6-dg@adax.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181019002358.17132-1-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> <20181019002358.17132-1-dg@adax.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 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: Fri, 19 Oct 2018 00:24:49 -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