From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailfilter03.viettel.com.vn (mailfilter03.viettel.com.vn [125.235.240.55]) by dpdk.org (Postfix) with ESMTP id E62BFF04 for ; Wed, 19 Sep 2018 10:17:28 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.53,393,1531760400"; d="scan'208";a="94195642" Received: from 125.235.240.45.adsl.viettel.vn (HELO mta2.viettel.com.vn) ([125.235.240.45]) by mailfilter03.viettel.com.vn with ESMTP; 19 Sep 2018 15:17:27 +0700 Received: from localhost (localhost [127.0.0.1]) by mta2.viettel.com.vn (Postfix) with ESMTP id 12FED68D99D; Wed, 19 Sep 2018 15:17:15 +0700 (ICT) Received: from mta2.viettel.com.vn ([127.0.0.1]) by localhost (mta2.viettel.com.vn [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id vCPXrjVv6OXx; Wed, 19 Sep 2018 15:17:15 +0700 (ICT) Received: from localhost (localhost [127.0.0.1]) by mta2.viettel.com.vn (Postfix) with ESMTP id E216968D995; Wed, 19 Sep 2018 15:17:14 +0700 (ICT) X-Virus-Scanned: amavisd-new at Received: from mta2.viettel.com.vn ([127.0.0.1]) by localhost (mta2.viettel.com.vn [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MesSBxWKFwEn; Wed, 19 Sep 2018 15:17:14 +0700 (ICT) Received: from localhost.localdomain (unknown [27.68.241.28]) by mta2.viettel.com.vn (Postfix) with ESMTPSA id 9E22E68D9AE; Wed, 19 Sep 2018 15:17:14 +0700 (ICT) To: reshma.pattan@intel.com Cc: dev@dpdk.org, Bao-Long Tran Message-Id: <1537345496-70207-1-git-send-email-longtb5@viettel.com.vn> X-Mailer: git-send-email 2.7.4 MilterAction: FORWARD Date: Wed, 19 Sep 2018 15:17:14 +0700 (ICT) From: longtb5@viettel.com.vn Subject: [dpdk-dev] Incorrect latencystats implementation 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, 19 Sep 2018 08:17:29 -0000 Currently, lib latencystats works as follow: * For every sample period, one packet is selected by RX callback to be later used for latency measurement. That packet is marked with a timestamp. * In TX callback, mbufs with non-zero timestamp are used for calculation. I see a problem with the current implementation. The timestamp field of a mbuf will not be cleared when that mbuf is freed back to the pool. Thus TX callback could potentially use an incorrect mbuf, one that had not been selected on RX but still has non-zero timestamp anyway because it was inherited from a previously selected packet. The simple fix for this is to reset the timestamp of the mbuf after it was used for latency calculation. However, that fix is not enough in the case where a selected mbuf get dropped by the application before reaching TX. That timestamp will eventually be cleared the next time that mbuf is used and not get dropped, but then the incorrect residued timestamp will still be used and it would affect all measurement results, most severely max_latency_ns. I have submit a patch to implement the trivial fix. For the drop case I can think of 2 options. We can either clear timestamp when putting mbufs back to their pool, or change lib latencystats implementation to perform packet selection at TX callback and let RX callback add timestamp to every packet. Both option could affect performance but I think the second option is less aggressive. Bao-Long Tran (1): latency: clear mbuf timestamp after latency calculation lib/librte_latencystats/rte_latencystats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.7.4