From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B91F143E94; Wed, 17 Apr 2024 19:30:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87C9540A76; Wed, 17 Apr 2024 19:30:48 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by mails.dpdk.org (Postfix) with ESMTP id 3A696402B5 for ; Wed, 17 Apr 2024 19:30:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713375048; x=1744911048; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=21EphMAvz+5JzAgXyPSOf1vwYD03HuEWWjj0ZLL34GA=; b=THFIdoFd/s93A16liJvH1Df1+XQuCnBxi2Dmogq1/dn6k57bLCxgL+sn yj4Y4QFJ/hh1B9ZTkNrzyXfFSPAnISoCTn2kxZLIc5hedIdLn0wiQQVOD Xcjr73w5HrzOLrhq6KVRUgeWwYUeEWhif7Uw0ylLfb/Dk6g8dJiKZ4OHs h3Snbk65/jjJo9skWYUu1vFIntr+rP5YsH3ZqSVA4cRbmaEh3SoX5dJL0 wbvYPkul0TbNyloAcP9vN9f95rtkfGEZ3q+ASIitne1dPm3d55FAZi8gB nsBjb5nX9AfF/p3zr4BDTrxeKsKlK966G8dMZG/keYIElXb3WsQmfG9hy A==; X-CSE-ConnectionGUID: 0PWUfGKMRxiN6gcLOzcGSw== X-CSE-MsgGUID: kHPV697rTSaaBsQZpbHSlw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="9009881" X-IronPort-AV: E=Sophos;i="6.07,209,1708416000"; d="scan'208";a="9009881" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2024 10:30:47 -0700 X-CSE-ConnectionGUID: e335a2KQQUW53QANL7F5pA== X-CSE-MsgGUID: G3va0OD1QSCeE88XSrKs5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,209,1708416000"; d="scan'208";a="60109718" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orviesa001.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 17 Apr 2024 10:30:46 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 17 Apr 2024 10:30:46 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 17 Apr 2024 10:30:46 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 17 Apr 2024 10:30:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X3qGWZSp1zOATkqvcu4vaaBHl6cyMNyoEGW5KtwT1j0iVd17RHxxKtjeXOWMiq9iuRje8TFwdk7XHrXEi5YbG6ZEXgJ5KMjAO+/cVMKFItyslGdVdxfRH6njASzkZ9ZaxmEQLRfL2Pft6xAwEGAPUPGPNbvkreZXRY9aTTSngWcy0v7OsBCCjaNiJMGLjbzL07EdwmCJN4tO8F2p3HzX0jBrDzbYa+x2VjInEgzbl9dXQJ6vxV4F8ghTv/Wygfdu2nw3jODn+FH1B+J2WiWxwOIfi5tc+u0xBISir8qRdZjq7ujwQoKcIJZGwgQBM6aQ7DRYR/M/vW4IHlaBZpOmVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uRz6p4AIwtlQXOK+vdRFHC0dY74gfCUK1pp/Q3kZVK0=; b=C+qR2jx8eRbwJng2hE2oo0CGNYk8f3JUFgBpOZBa2M7LSFlU3Ob2Fha2Aci4v/VOPgTgBL3HHMgD9/o/RrLn1y6UgzstWPIV9QKdntPg1ZLXgcIf66m23hCJcjHkwZ7YVDM5EwC6ns3p7ZDwQBPG+wy+QADXs2lGtLKmswlIdEp8yoNZxBGx2KzClYRoUsqCzoOwEkTUrbStPHXfgB1IFOSZRChuSJ1iqm+5T0BZ58DWD6/8VfTFpetiWVqxP8E+9pF2HV013L7vQD/0EYvD7+EkE7cv2DmEcJ33r0iQwpO+HgomzjIhKKl8C/wFLIYRCttepJjWCyB5EkLBe8JWcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by SA1PR11MB8425.namprd11.prod.outlook.com (2603:10b6:806:385::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.31; Wed, 17 Apr 2024 17:30:43 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::487e:e20c:ad88:9c0f]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::487e:e20c:ad88:9c0f%7]) with mapi id 15.20.7472.025; Wed, 17 Apr 2024 17:30:43 +0000 Date: Wed, 17 Apr 2024 18:30:38 +0100 From: Bruce Richardson To: Stephen Hemminger CC: , Reshma Pattan Subject: Re: [PATCH v3 5/5] latencystats: include file cleanup Message-ID: References: <0240408195036.182545-1-stephen@networkplumber.org> <20240417170908.76701-1-stephen@networkplumber.org> <20240417170908.76701-6-stephen@networkplumber.org> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240417170908.76701-6-stephen@networkplumber.org> X-ClientProxiedBy: DU7P190CA0006.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:550::18) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|SA1PR11MB8425:EE_ X-MS-Office365-Filtering-Correlation-Id: d3dee744-8bc6-4562-9591-08dc5f041bbf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TGxv1qxX+8afzadq4efHWR7Q/D1OY7Vc6s5M9UHuyE+SHZW05kJvWf6DeEBHNriodUj5iqV1LfYk/uBr9HagA+I8G8Nt4okVu1R6NR/ahCeQZBf+escWVleLV2o5R8aFekP/Zm1My5E2BeX1eymKh40bMAhcnln3nHnkMSmNWPDY9JJiX0pyz3i2Udhvj8LVZj0WMQoN2AyGkTMVg+AHwWsdLOOkQ9RBZr+ithoSWZ4yEhD5kvLTwQm/N+693D8RrrqbIb6hIP66C/ZHGrHiXR/B7ygz9bVabjyF4e/o0wRXbCXhwAGyu0JYWKmEpNh1Qc3uDsjo9XZXl7BYRb4qMJWt9dFaB7nRI1Tm7476H8cLV12w2mKAILQl6YnwKs3o/K0/oQF/1QUaIy8tKlVc54man367boipLaB7gHrp8D+VNjRYbNpfa249IcZQZFiTqzbNGwjNcn7ZTExlHFQcvxLiFR8H7SUkRIQdKmPUGgx4yVdf2TIava83RzhqemSirsLzxn8UGnMwBCZv08+w4NiNNVBnUbbjy7c06ydjfnigb1yTxaxKwqp3TD/KppM47wh5kgaB0fnQezZtBA5sg4hYC28wI64nIsrcyPDr1SU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(366007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2HdxLWWTcC9E8KmvkfseY3lQwyNBfl0q45+w3R0hCJOQZp9xTSOIascAz+uC?= =?us-ascii?Q?cxinl8JWFENsOWd1xxMIrWtzuwfwojLC3I7dXBUQZGCs8aOYioArF8c0xDil?= =?us-ascii?Q?w3yKtqeeOLkd9yzSgGvRlO6paO9AylLlsrB6tc2VB0tZVQcoQQgpBYOzGhVf?= =?us-ascii?Q?v2sBcqenfXssdt9qdSVZJMS4BHxPa+FOOWz8X6+Lv+K7paToUfW1FnJ4Q5gk?= =?us-ascii?Q?Cn60W2YbST8DXWF1fxkPhA7fjG253yFnbSnsatk+yYAT7tt4VWN5fCnRRzdQ?= =?us-ascii?Q?45nVcTFVtEeiiD8nkppcZ4tAmHAGDozDvqa3xLCeA+GbJ60KZjVynN18l0tE?= =?us-ascii?Q?ZIgX//cdQ7jk5UQUecJh7+1YBF8tC5Dr9xksKQFEQPKcumoH0cRRWG5xUm9K?= =?us-ascii?Q?MkHCAaxgGEMNiYOo1G6uEiaVU5PzMJr3ODXEBOgS5dHSKAYHkbHPIQocuJZT?= =?us-ascii?Q?PKiala2bqy5opmdE4z1c9pwn1ncFvL+JmzF8En0JhU8CKQ72VVYd3YDVUU7I?= =?us-ascii?Q?AL6GFmj8/zt1Jql18folSsIWpIXsWOKKh+zMEP2a9YArgkZWcnAALzSgcpYL?= =?us-ascii?Q?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0b0jmdH24DD4GIwyJp2J?= =?us-ascii?Q?L7X0/Gwh73+wnRmtiUMM9unC0mJ3U0dd76fOLoHL4y+zOvlMcswVj+H+bJV4?= =?us-ascii?Q?i/6mw/VGgauura7wgKZpSDkvNeFOTPaog42PWMy2ic0H1wJOSBemHcsglqoB?= =?us-ascii?Q?2w=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: d3dee744-8bc6-4562-9591-08dc5f041bbf X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 17:30:43.2378 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mgSptl4k4gGPBc7BlP+rb24VW3pDSHTbb/u34iEnAU3Pvm5bC2QPqFa60nC7baakDeUi0UqLpEMC35KgNrFoiwCasqocML9scmYeXKAQI9Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB8425 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Apr 17, 2024 at 10:07:27AM -0700, Stephen Hemminger wrote: > Include what is used here. > There are more changes in this patch than just includes cleanup. > Signed-off-by: Stephen Hemminger > --- > lib/latencystats/rte_latencystats.c | 85 ++++++++++++++++++----------- > 1 file changed, 52 insertions(+), 33 deletions(-) > > diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c > index 62038a9f5d..31e7a6eb88 100644 > --- a/lib/latencystats/rte_latencystats.c > +++ b/lib/latencystats/rte_latencystats.c > @@ -2,16 +2,25 @@ > * Copyright(c) 2018 Intel Corporation > */ > > +#include > #include > +#include > +#include > +#include > > -#include > -#include > -#include > +#include > #include > +#include > +#include > #include > -#include > -#include > #include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > > #include "rte_latencystats.h" > > @@ -148,14 +157,15 @@ add_time_stamps(uint16_t pid __rte_unused, > > static uint16_t > calc_latency(uint16_t pid __rte_unused, > - uint16_t qid __rte_unused, > - struct rte_mbuf **pkts, > - uint16_t nb_pkts, > - void *_ __rte_unused) > + uint16_t qid __rte_unused, > + struct rte_mbuf **pkts, > + uint16_t nb_pkts, > + void *_ __rte_unused) > { > unsigned int i; > uint64_t now, latency; > static uint64_t prev_latency; > + static bool first_sample = true; > > now = rte_rdtsc(); > > @@ -166,32 +176,41 @@ calc_latency(uint16_t pid __rte_unused, > > latency = now - *timestamp_dynfield(pkts[i]); > > - /* > - * The jitter is calculated as statistical mean of interpacket > - * delay variation. The "jitter estimate" is computed by taking > - * the absolute values of the ipdv sequence and applying an > - * exponential filter with parameter 1/16 to generate the > - * estimate. i.e J=J+(|D(i-1,i)|-J)/16. Where J is jitter, > - * D(i-1,i) is difference in latency of two consecutive packets > - * i-1 and i. > - * Reference: Calculated as per RFC 5481, sec 4.1, > - * RFC 3393 sec 4.5, RFC 1889 sec. > - */ > - glob_stats->jitter += ((prev_latency - latency) - glob_stats->jitter) / 16; > - if (glob_stats->min_latency == 0) > - glob_stats->min_latency = latency; > - else if (latency < glob_stats->min_latency) > + if (first_sample) { > + first_sample = false; > + > glob_stats->min_latency = latency; > - else if (latency > glob_stats->max_latency) > glob_stats->max_latency = latency; > - /* > - * The average latency is measured using exponential moving > - * average, i.e. using EWMA > - * https://en.wikipedia.org/wiki/Moving_average > - * > - * Alpha is .25 > - */ > - glob_stats->avg_latency += (latency - glob_stats->avg_latency) / 4; > + glob_stats->avg_latency = latency; > + glob_stats->jitter = 0; > + } else { > + /* > + * The jitter is calculated as statistical mean of interpacket > + * delay variation. The "jitter estimate" is computed by taking > + * the absolute values of the ipdv sequence and applying an > + * exponential filter with parameter 1/16 to generate the > + * estimate. i.e J=J+(|D(i-1,i)|-J)/16. Where J is jitter, > + * D(i-1,i) is difference in latency of two consecutive packets > + * i-1 and i. > + * Reference: Calculated as per RFC 5481, sec 4.1, > + * RFC 3393 sec 4.5, RFC 1889 sec. > + */ > + glob_stats->jitter += ((prev_latency - latency) > + - glob_stats->jitter) / 16; > + if (latency < glob_stats->min_latency) > + glob_stats->min_latency = latency; > + if (latency > glob_stats->max_latency) > + glob_stats->max_latency = latency; > + /* > + * The average latency is measured using exponential moving > + * average, i.e. using EWMA > + * https://en.wikipedia.org/wiki/Moving_average > + * > + * Alpha is .25 > + */ > + glob_stats->avg_latency += (latency - glob_stats->avg_latency) / 4; > + } > + > prev_latency = latency; > } > rte_spinlock_unlock(&glob_stats->lock); > -- > 2.43.0 >