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 126BA4C99 for ; Thu, 25 Oct 2018 00:26:58 +0200 (CEST) Received: by mail-qt1-f194.google.com with SMTP id p24-v6so1661234qtq.0 for ; Wed, 24 Oct 2018 15:26:58 -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=JwmDWRL5/7RwjznFzzkNPP/qS13MQTZLJsGZzBQSHNsU7zo9FIJOiolBlyQwIxSIU0 6rrTtXSbrUcSN4aIJxtRqEbDzp0AYk97Cd21DiD7B+k4uDhjd4LNWHaXTS3FQupfMOvT XDJJkya23EcXrfZE9z1DdmQVlDzZdjGKGZycShXAu/RXJFHtXMzl1RC+dqciCDOKQes7 bUtrlCl7FszDez+GTBQRsna1fPiKD4UnYuTKXcKfO9yugCjQauQNCQsmU7M8oFxf6hWh ADcoi0morfGtDWC1mQBr5XOa5Fvbqzqy7UdvHrcInXllBGbS5uoQmqvP3DtkRqMWGPHH Qoyw== 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=fVjPvQq7fTiEEjgEVMOu3k3lnCvIli5j6pbjnJO2lornHkSkM7h3aI/yJu99Mf5xAc 7zBZ0ygKG0vXxXxCKyPkM96flWC2t2LkCyokSBBEvDthDmUTEdxRa9HhD5QehevuG4/M 8Q/hdvk8dsgsAgaRmGP4y1f0JvbbadPd589WlR2tBW3Zp6S97WlrR9rJPvcESxOXehej lXg43+J0HAhx+H1mO60YcTHNzcp+wkZWRRlH4aj2W2Kz5RXc3ITPBVZMYJroJEv0fAfY Tcn/1rLGClvOrB6IOfQL/q9WGf1pN4WN34dsW2Dkbuty/S5/WxGMRW8WIA9G1QshV2/x veRQ== X-Gm-Message-State: AGRZ1gJxojSzl+RL778l1gFZJqXNBnnTedGEcJMD13aKdcKcJu+1EXQw +dpk0MFhxyWSuv6IeNex3Iy1Xpam X-Google-Smtp-Source: AJdET5eeTOocmNu0AT7ep2j4ZYbkR6CysO1OMWfb0WLOpPpgS0KiPLDTsjzBkpxViDuNxlQRQ57SVQ== X-Received: by 2002:a0c:f3c1:: with SMTP id f1mr4256887qvm.167.1540420017084; Wed, 24 Oct 2018 15:26:57 -0700 (PDT) Received: from snappy.local.lan ([179.228.213.114]) by smtp.gmail.com with ESMTPSA id s52-v6sm5506026qts.5.2018.10.24.15.26.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Oct 2018 15:26:56 -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 19:26:31 -0300 Message-Id: <20181024222631.30461-6-dg@adax.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181024222631.30461-1-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> <20181024222631.30461-1-dg@adax.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 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 22:26:58 -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