From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id EE5155A44 for ; Tue, 25 Sep 2018 16:31:53 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2018 07:31:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,302,1534834800"; d="scan'208";a="86408117" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by orsmga003.jf.intel.com with ESMTP; 25 Sep 2018 07:30:52 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.54]) by IRSMSX108.ger.corp.intel.com ([169.254.11.13]) with mapi id 14.03.0319.002; Tue, 25 Sep 2018 15:30:51 +0100 From: "Ananyev, Konstantin" To: "Pattan, Reshma" , "longtb5@viettel.com.vn" , "dev@dpdk.org" Thread-Topic: [PATCH v2] latencystats: fix timestamp marking and latency calculation Thread-Index: AQHUVMqz4i0+Z7pAAk6kr3nxmPX9BaUBDfrg Date: Tue, 25 Sep 2018 14:30:50 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258EA95B151@irsmsx105.ger.corp.intel.com> References: <1537545703-9599-1-git-send-email-reshma.pattan@intel.com> <1537878252-21061-1-git-send-email-reshma.pattan@intel.com> In-Reply-To: <1537878252-21061-1-git-send-email-reshma.pattan@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzQ4OGI0NzctZGE2Zi00NzE0LThlMGMtNGRlNDUzZDYwMjliIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidkxVb3VzRkhiYVhsSnlTN1pPZW4wRitcLzVRMWk4N1g2N01IcjFmMjBmSUFhRXViQWlYWDhYZzR4T1ZiMUdvZ3MifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] latencystats: fix timestamp marking and latency calculation 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: Tue, 25 Sep 2018 14:31:54 -0000 Hi Reshma, >=20 >=20 > Latency calculation logic is not correct for the case where > packets gets dropped before TX. As for the dropped packets, > the timestamp is not cleared, and such packets still gets > counted for latency calculation in next runs, that will result > in inaccurate latency measurement. >=20 > So fix this issue as below, >=20 > Before setting timestamp in mbuf, check mbuf don't have > any prior valid time stamp flag set and after marking > the timestamp, set mbuf flags to indicate timestamp is > valid. >=20 > Before calculating timestamp check mbuf flags are set to > indicate timestamp is valid. >=20 > With the above logic it is guaranteed that correct timestamps > have been used. >=20 > Fixes: 5cd3cac9ed ("latency: added new library for latency stats") >=20 > Reported-by: Bao-Long Tran > Signed-off-by: Reshma Pattan > Tested-by: Bao-Long Tran >=20 > --- > v2: remove check for mbuf->timestamp > --- > lib/librte_latencystats/rte_latencystats.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_late= ncystats/rte_latencystats.c > index 1fdec68e3..0f702b722 100644 > --- a/lib/librte_latencystats/rte_latencystats.c > +++ b/lib/librte_latencystats/rte_latencystats.c > @@ -125,8 +125,11 @@ add_time_stamps(uint16_t pid __rte_unused, > for (i =3D 0; i < nb_pkts; i++) { > diff_tsc =3D now - prev_tsc; > timer_tsc +=3D diff_tsc; > - if (timer_tsc >=3D samp_intvl) { > + > + if ((pkts[i]->ol_flags & PKT_RX_TIMESTAMP) =3D=3D 0 > + && (timer_tsc >=3D samp_intvl)) { As a nit - I think you need extra tab here, to follow dpdk codying style. Apart from that: Acked-by: Konstantin Ananyev > pkts[i]->timestamp =3D now; > + pkts[i]->ol_flags |=3D PKT_RX_TIMESTAMP; > timer_tsc =3D 0; > } > prev_tsc =3D now; > @@ -156,7 +159,7 @@ calc_latency(uint16_t pid __rte_unused, >=20 > now =3D rte_rdtsc(); > for (i =3D 0; i < nb_pkts; i++) { > - if (pkts[i]->timestamp) > + if (pkts[i]->ol_flags & PKT_RX_TIMESTAMP) > latency[cnt++] =3D now - pkts[i]->timestamp; > } >=20 > -- > 2.14.4