From patchwork Wed May 29 22:54:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 140401 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 881BA44107; Thu, 30 May 2024 00:57:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26B76402F1; Thu, 30 May 2024 00:57:38 +0200 (CEST) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by mails.dpdk.org (Postfix) with ESMTP id 1EAC040289 for ; Thu, 30 May 2024 00:57:36 +0200 (CEST) Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-66629f45359so255671a12.3 for ; Wed, 29 May 2024 15:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1717023455; x=1717628255; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AX/RqP9vi9bMQ0mgv5ewy9DPg0OSgSf9xA+nKBv7llk=; b=h9YpCPCh5WQ8xIaADHLbf/GX/yedswww/P5XJE7h0UcGLgdw1UALUPhlPzL5l/mKN5 ZA/0ZnvPAcK3NOOlxtIZGQiuI0Ssli3xmH73c0npC6BxVhMADzzvwASQ4O1LwDmT5Wmo M67/zA3p1c30jBcwQbeChjvdK07IbGBDaDarsbCb/xYUVwfsyPRTaK3X3zhvk6KkzwQ9 rAQ2eXFizHQb0OMJYdljPnVdGE25zrGgfLw34+ebL0nXDBKPxM7NTqorHiOLlFmp97fz SW5OTVMHMlqS162nvMw65L+5CwwSNHV/GXngCgp/hUjXE4kMOmXHeoalRbMKZ339pcZc cKYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717023455; x=1717628255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AX/RqP9vi9bMQ0mgv5ewy9DPg0OSgSf9xA+nKBv7llk=; b=S23rMT3JgY8cUzk/a+lUny7FJEgeqCPen9owyIivFhTr2kEG/AX39A/YTxQ9HLCCLJ Gg/PqGAShpVrLJXbWRHDmfteWalFhHOZDPF9bzIKak9jdkKNaQOJkBt8B7MWSE7APpjd moV18A9u6JoBZeSSVH2ll53sc3/ln031u04x6zlh1lGACfNr6A8nU1PCZ/XP+TfA25BY APkorLPUfqVrPKx8tIiV53DfVGqXYr8j7TAnEw8fqxn9lwuuwEq2RMb/hKBQ/M/yEsYx MxeJUIT5MQLpVA/eioAu6o45G5nYe1xYqjAHoxwosq/3fklNv/zSiVSkNcSp6O0IrCIt SmJw== X-Gm-Message-State: AOJu0YyDyHsE9FWWgs+eQAYfPzSNrB8FKu+guYgXJSQdGW1UiBbfaTOn EsjqhAhR99HpIa3irxmFc0V2QAjrXWLSy+JWXcLlcqZyVeKnO2sp+zBWqlvKjlicoWaddXF/9oo 8 X-Google-Smtp-Source: AGHT+IFHniJ1fGUk4w8puq5FYNZ3ClaSXU3nD9pxbw7LcPAzE9V6WQ5SL0Z2/AA/P54HicEDV3h5pw== X-Received: by 2002:a17:90a:5587:b0:2bf:fa80:61f8 with SMTP id 98e67ed59e1d1-2c1abc4e67bmr445288a91.46.1717023455098; Wed, 29 May 2024 15:57:35 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a77baebcsm351762a91.53.2024.05.29.15.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 15:57:34 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?utf-8?q?Morten_Br?= =?utf-8?q?=C3=B8rup?= , Tyler Retzlaff , Reshma Pattan Subject: [PATCH v6 1/8] latencystats: replace use of VLA Date: Wed, 29 May 2024 15:54:38 -0700 Message-ID: <20240529225732.442539-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529225732.442539-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240529225732.442539-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The temporary array latencystats is not needed if the algorithm is converted into one pass. Signed-off-by: Stephen Hemminger Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- lib/latencystats/rte_latencystats.c | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index cae4b50878..3fb8321484 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -157,9 +157,9 @@ calc_latency(uint16_t pid __rte_unused, uint16_t nb_pkts, void *_ __rte_unused) { - unsigned int i, cnt = 0; + unsigned int i; uint64_t now; - float latency[nb_pkts]; + float latency; static float prev_latency; /* * Alpha represents degree of weighting decrease in EWMA, @@ -169,13 +169,14 @@ calc_latency(uint16_t pid __rte_unused, const float alpha = 0.2f; now = rte_rdtsc(); - for (i = 0; i < nb_pkts; i++) { - if (pkts[i]->ol_flags & timestamp_dynflag) - latency[cnt++] = now - *timestamp_dynfield(pkts[i]); - } rte_spinlock_lock(&glob_stats->lock); - for (i = 0; i < cnt; i++) { + for (i = 0; i < nb_pkts; i++) { + if (!(pkts[i]->ol_flags & timestamp_dynflag)) + continue; + + latency = now - *timestamp_dynfield(pkts[i]); + /* * The jitter is calculated as statistical mean of interpacket * delay variation. The "jitter estimate" is computed by taking @@ -187,22 +188,22 @@ calc_latency(uint16_t pid __rte_unused, * Reference: Calculated as per RFC 5481, sec 4.1, * RFC 3393 sec 4.5, RFC 1889 sec. */ - glob_stats->jitter += (fabsf(prev_latency - latency[i]) + glob_stats->jitter += (fabsf(prev_latency - latency) - glob_stats->jitter)/16; if (glob_stats->min_latency == 0) - glob_stats->min_latency = latency[i]; - else if (latency[i] < glob_stats->min_latency) - glob_stats->min_latency = latency[i]; - else if (latency[i] > glob_stats->max_latency) - glob_stats->max_latency = latency[i]; + glob_stats->min_latency = latency; + else if (latency < glob_stats->min_latency) + 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 */ glob_stats->avg_latency += - alpha * (latency[i] - glob_stats->avg_latency); - prev_latency = latency[i]; + alpha * (latency - glob_stats->avg_latency); + prev_latency = latency; } rte_spinlock_unlock(&glob_stats->lock); From patchwork Wed May 29 22:54:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 140402 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0CAFA44107; Thu, 30 May 2024 00:57:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 27D5040691; Thu, 30 May 2024 00:57:39 +0200 (CEST) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id D965C40289 for ; Thu, 30 May 2024 00:57:36 +0200 (CEST) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2bdb57f496eso187846a91.2 for ; Wed, 29 May 2024 15:57:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1717023456; x=1717628256; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q0Q50GmIVbnt3NSHcpRZY2pfgVHGqgyKjZhLQeiYYDo=; b=qdOhqzNLtNwnGrrNCOWzoiQt6pIhFPc1kRF/9t2SPmqXRq6kdXSZzbG8vsAIqgPB9N infIvNAl1MwOCys24nHVt87tpU1l788qE8xjWvH9QIK5bl4NOZC16r9kBoMGe3J2B4dd jGINHF5RXEq5MPQtxiWDvzMY/InErgYmgd3CqxxPvWd2L+J9z9Olv+M6CoqdgWLuYzRe +Pzp7/lSFMwyZS9ukon2NHike8eWoDYit7e/QZ8OtXYc7hMfQTl0O9c4ZMQuvBjHDOEY HlNbU3V3H07k0J/8y7I2vhmKWvAqo0C9ZVfXymlZUiKVS8vD5AI1qbKojw8Qbacka1W3 CIRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717023456; x=1717628256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q0Q50GmIVbnt3NSHcpRZY2pfgVHGqgyKjZhLQeiYYDo=; b=aTARImJUHBDnjbXlnSXyaxHU5n43dNi/U2Q5h1ygMR42mrUBwtEHyU82aKKE8xtS/l fVisC4KvcMVfGM2L00LR+kJ5Y5ot0wDWU72KbFAzqSjQrwYsb5FrrtYSSLk3ik7bfQyc Fcd4Ni6kXv6rl7v+cqHSjJYaoy2dpHpXwRTtPVfd79gMToC9hnmxB12FIFhwE0PosikS M9SK63YnVA8jH/9weWx3epzZFb3Xw0rIOTZ3/A+GqrVL5zEQYeBmqGqz+Okn2/d5bd9R 2vIBItskaOYQUAa3VybOmTNj0IJdKhzG2cwdReB4EaYSQSK997tOVuDx0aORYSvpv/Xj YxlA== X-Gm-Message-State: AOJu0YxsSqguHWiuIKtcXkXaJY+6NhwV9InWkIGxfaPvq7/f+keqIxIr q2WuVcVldHmE9SUsMakkGacUTqjaLMmdxmpxNU41QjUS8+DXKID0iutuCjLGh3KX6z8b7aHE0gK h X-Google-Smtp-Source: AGHT+IEyVQBwKGNdFzJwjKzt+64SCe3AJ5ByMD/OVAQuPNfClnOm4+y4gO9DfAEYmf1VYGKET5n3OQ== X-Received: by 2002:a17:90b:2d89:b0:2bf:8824:c0a5 with SMTP id 98e67ed59e1d1-2c1ab9d9fafmr609862a91.6.1717023456036; Wed, 29 May 2024 15:57:36 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a77baebcsm351762a91.53.2024.05.29.15.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 15:57:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v6 2/8] latencystats: handle fractional cycles per ns Date: Wed, 29 May 2024 15:54:39 -0700 Message-ID: <20240529225732.442539-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529225732.442539-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240529225732.442539-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The TSC frequency is not always an integral number of nanoseconds. For examples, cycles per nanoseconds on my test system is 2.8. Fix by using floating point where needed and calculate value once. Signed-off-by: Stephen Hemminger --- lib/latencystats/rte_latencystats.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 3fb8321484..c897df03c6 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -18,12 +18,7 @@ /** Nano seconds per second */ #define NS_PER_SEC 1E9 -/** Clock cycles per nano second */ -static uint64_t -latencystat_cycles_per_ns(void) -{ - return rte_get_timer_hz() / NS_PER_SEC; -} +static double cycles_per_ns; RTE_LOG_REGISTER_DEFAULT(latencystat_logtype, INFO); #define RTE_LOGTYPE_LATENCY_STATS latencystat_logtype @@ -89,8 +84,7 @@ rte_latencystats_update(void) for (i = 0; i < NUM_LATENCY_STATS; i++) { stats_ptr = RTE_PTR_ADD(glob_stats, lat_stats_strings[i].offset); - values[i] = (uint64_t)floor((*stats_ptr)/ - latencystat_cycles_per_ns()); + values[i] = floor(*stats_ptr / cycles_per_ns); } ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, @@ -112,8 +106,7 @@ rte_latencystats_fill_values(struct rte_metric_value *values) stats_ptr = RTE_PTR_ADD(glob_stats, lat_stats_strings[i].offset); values[i].key = i; - values[i].value = (uint64_t)floor((*stats_ptr)/ - latencystat_cycles_per_ns()); + values[i].value = floor(*stats_ptr / cycles_per_ns); } } @@ -235,9 +228,11 @@ rte_latencystats_init(uint64_t app_samp_intvl, return -ENOMEM; } + cycles_per_ns = (double)rte_get_tsc_hz() / NS_PER_SEC; + glob_stats = mz->addr; rte_spinlock_init(&glob_stats->lock); - samp_intvl = app_samp_intvl * latencystat_cycles_per_ns(); + samp_intvl = (uint64_t)(app_samp_intvl * cycles_per_ns); /** Register latency stats with stats library */ for (i = 0; i < NUM_LATENCY_STATS; i++) From patchwork Wed May 29 22:54:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 140403 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DFBBE44107; Thu, 30 May 2024 00:57:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64507406FF; Thu, 30 May 2024 00:57:40 +0200 (CEST) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by mails.dpdk.org (Postfix) with ESMTP id C9DA0402DF for ; Thu, 30 May 2024 00:57:37 +0200 (CEST) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-6bce380eb96so207251a12.0 for ; Wed, 29 May 2024 15:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1717023457; x=1717628257; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/dspqKZ7Gwydk7sWgMWJ84/aRMy8m2p+7G7/8P0RBFo=; b=TeI1up+gYjjKd4/e+F78OIxI+fFZnOT4hgcQx3cKKwtkkmbgbhg3jqDraSVvnGVVjS juCM7bToJzTY4+B0zgUavIQ1o13cQU4l7vPT9wA4bl0iXiaCUFICjRkWQ5J+mGCZyYVj ZO7HfhN4yB1yFyU96C744fe4jOexm0U2pdmc7lq51JTWNEEoAgRn+iXAwDJAyYkxWhFw ycZuXjydLBoaD+bMfU+iLVoBKOEiUIQ7XyoEPP0GM0XVNOemx1lhRwUSQ/FdF00q7RMK A26+9+YCJEKxtG0m7927Blbdda3ESx13CoJ3i+x9hfx8QsmLdkxfcUJCR5FMQGxxc3Ag TjMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717023457; x=1717628257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/dspqKZ7Gwydk7sWgMWJ84/aRMy8m2p+7G7/8P0RBFo=; b=cSV0bMCAOikxo5t/+QO3N9d7qu/TyMfKkwaDnLhFyHungOPovDoWACwxOFva1+G79E eyDD9zxAHd13f5B93E9nY+SLroQl/yzblz64E+PhaopVWBd0T+me1DRUxsyqxMouO1iL PBuHbRPOaP4L2EFqjTUsRuCh/PcDVxZIqj1HJS4m8SeQDhjxgP/QhTAkuJgyNRx2K0Dj PWQpX5UQlOrIlqoaNU+9N0iL+YWt1hKKv6g5j/5f7cu268tJm2u7rQ2dVicU1u8U0k9U l1OyrfCRMOTIpX0ySpdLqt3MApmsM79wr1B+zzmGbFUlZkrIbftYTOwVgXTs3uQKPmdj rHvQ== X-Gm-Message-State: AOJu0YxS1CAw7Mrr96qH566IYDXLUqlblHDfNf46ArdduT9auFIVrANu 6HnEkIBAYhOplXi6lbfnp6ICVNXBfa48uco/4ebdMEbwnDQRddjkee9i+qcm7ZkhVSltNFQbDd5 N X-Google-Smtp-Source: AGHT+IG8ay/QLI+iRR0R/45ObSF+CricOfFYPRrV/t4xDBlp9n60pYw/26sYjkRdFCQU4JpZENePzQ== X-Received: by 2002:a17:90b:17c4:b0:2bf:9981:e0bc with SMTP id 98e67ed59e1d1-2c1abbfb17bmr472846a91.27.1717023456843; Wed, 29 May 2024 15:57:36 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a77baebcsm351762a91.53.2024.05.29.15.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 15:57:36 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , =?utf-8?q?Morten_Br=C3=B8rup?= , Reshma Pattan Subject: [PATCH v6 3/8] latencystats: do not use floating point Date: Wed, 29 May 2024 15:54:40 -0700 Message-ID: <20240529225732.442539-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529225732.442539-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240529225732.442539-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The cycle counts do not need to be stored as floating point. Instead keep track of latency in cycles, and convert to nanoseconds when read. Use scaled math with exponential Weighted Moving Average weight of .25 to avoid use of floating point for that. The average latency took too long to "warm up". Do what RFC 6298 suggests and initialize on first sample. Signed-off-by: Stephen Hemminger Acked-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/latencystats/rte_latencystats.c | 128 ++++++++++++++++------------ 1 file changed, 73 insertions(+), 55 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index c897df03c6..2140ab87c4 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -41,11 +42,14 @@ static uint64_t samp_intvl; static uint64_t timer_tsc; static uint64_t prev_tsc; +#define LATENCY_AVG_SCALE 4 +#define LATENCY_JITTER_SCALE 16 + struct rte_latency_stats { - float min_latency; /**< Minimum latency in nano seconds */ - float avg_latency; /**< Average latency in nano seconds */ - float max_latency; /**< Maximum latency in nano seconds */ - float jitter; /** Latency variation */ + uint64_t min_latency; /**< Minimum latency */ + uint64_t avg_latency; /**< Average latency */ + uint64_t max_latency; /**< Maximum latency */ + uint64_t jitter; /** Latency variation */ rte_spinlock_t lock; /** Latency calculation lock */ }; @@ -61,31 +65,38 @@ static struct rxtx_cbs tx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT]; struct latency_stats_nameoff { char name[RTE_ETH_XSTATS_NAME_SIZE]; unsigned int offset; + unsigned int scale; }; static const struct latency_stats_nameoff lat_stats_strings[] = { - {"min_latency_ns", offsetof(struct rte_latency_stats, min_latency)}, - {"avg_latency_ns", offsetof(struct rte_latency_stats, avg_latency)}, - {"max_latency_ns", offsetof(struct rte_latency_stats, max_latency)}, - {"jitter_ns", offsetof(struct rte_latency_stats, jitter)}, + {"min_latency_ns", offsetof(struct rte_latency_stats, min_latency), 1}, + {"avg_latency_ns", offsetof(struct rte_latency_stats, avg_latency), LATENCY_AVG_SCALE}, + {"max_latency_ns", offsetof(struct rte_latency_stats, max_latency), 1}, + {"jitter_ns", offsetof(struct rte_latency_stats, jitter), LATENCY_JITTER_SCALE}, }; #define NUM_LATENCY_STATS (sizeof(lat_stats_strings) / \ sizeof(lat_stats_strings[0])) -int32_t -rte_latencystats_update(void) +static void +latencystats_collect(uint64_t values[]) { unsigned int i; - float *stats_ptr = NULL; - uint64_t values[NUM_LATENCY_STATS] = {0}; - int ret; + const uint64_t *stats; for (i = 0; i < NUM_LATENCY_STATS; i++) { - stats_ptr = RTE_PTR_ADD(glob_stats, - lat_stats_strings[i].offset); - values[i] = floor(*stats_ptr / cycles_per_ns); + stats = RTE_PTR_ADD(glob_stats, lat_stats_strings[i].offset); + values[i] = floor(*stats / (cycles_per_ns * lat_stats_strings[i].scale)); } +} + +int32_t +rte_latencystats_update(void) +{ + uint64_t values[NUM_LATENCY_STATS]; + int ret; + + latencystats_collect(values); ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, latency_stats_index, @@ -97,16 +108,16 @@ rte_latencystats_update(void) } static void -rte_latencystats_fill_values(struct rte_metric_value *values) +rte_latencystats_fill_values(struct rte_metric_value *metrics) { + uint64_t values[NUM_LATENCY_STATS]; unsigned int i; - float *stats_ptr = NULL; + + latencystats_collect(values); for (i = 0; i < NUM_LATENCY_STATS; i++) { - stats_ptr = RTE_PTR_ADD(glob_stats, - lat_stats_strings[i].offset); - values[i].key = i; - values[i].value = floor(*stats_ptr / cycles_per_ns); + metrics[i].key = i; + metrics[i].value = values[i]; } } @@ -151,15 +162,9 @@ calc_latency(uint16_t pid __rte_unused, void *_ __rte_unused) { unsigned int i; - uint64_t now; - float latency; - static float prev_latency; - /* - * Alpha represents degree of weighting decrease in EWMA, - * a constant smoothing factor between 0 and 1. The value - * is used below for measuring average latency. - */ - const float alpha = 0.2f; + uint64_t now, latency; + static uint64_t prev_latency; + static bool first_sample = true; now = rte_rdtsc(); @@ -170,32 +175,45 @@ 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 += (fabsf(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 (unlikely(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 - */ - glob_stats->avg_latency += - alpha * (latency - glob_stats->avg_latency); + glob_stats->avg_latency = latency * 4; + /* start ad if previous sample had 0 latency */ + glob_stats->jitter = latency / LATENCY_JITTER_SCALE; + } 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. Jitter is scaled by 16. + * Reference: Calculated as per RFC 5481, sec 4.1, + * RFC 3393 sec 4.5, RFC 1889 sec. + */ + long long delta = prev_latency - latency; + glob_stats->jitter += llabs(delta) + - glob_stats->jitter / LATENCY_JITTER_SCALE; + + 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, avg_latency is scaled by 4. + */ + glob_stats->avg_latency += latency + - glob_stats->avg_latency / LATENCY_AVG_SCALE; + } + prev_latency = latency; } rte_spinlock_unlock(&glob_stats->lock); From patchwork Wed May 29 22:54:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 140404 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0104444107; Thu, 30 May 2024 00:58:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9728540A6D; Thu, 30 May 2024 00:57:41 +0200 (CEST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 7A2344067E for ; Thu, 30 May 2024 00:57:38 +0200 (CEST) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2c1a9b151bcso194488a91.3 for ; Wed, 29 May 2024 15:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1717023458; x=1717628258; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i3+egRrx4JI9E2plWMu17CiEVJ7H/AoXfNFkJLwKwko=; b=JdF3JugePehMjIQ4AtJqE4V6gbdjDx0qvZBbACXPetPiNpbp5oCa0KDuehF9L/S5Dh zh69A6EmMI0Y33mVIiJurrW6seYzVJ1ZJXVRk5HOE+NUQTsKCZ6jYK8kt54hxdu2ZZC9 tZ5PdygPlUpFEien/gtsGvrh+ttv9/CRG4tRcG1PGkwVb79rmnPvx1yQyjQP67GXEau7 GkEH3xLoGLZl/MKKJZIC8qIauxvRlg/GU/9682XL+hjCSS0h1FrK6Zyg53uTrQNH0YEj W4MkEyAq/ncc0oz5B0zmnFKxzbZ6Xjyil51GmiqblYQ1kWi4xaiHXW7qc+0lQZmYiu3f WZrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717023458; x=1717628258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i3+egRrx4JI9E2plWMu17CiEVJ7H/AoXfNFkJLwKwko=; b=uUGsHIqHh3GRx24WYSSvx0gEAT0veipvGDeQWUTyLQ1LDQPpax+YA3+A9m5JJW4ZWD Yc2okn6SZV1QdCp54QM+psmVuOiK1u5Cz+TT/p+o69nFrnsS+XtAGTnpoeI72Ljd9/rv kN+U0DYxnrXwoSrN6aHVIfhxEuKvUXESnAM/bocu4l6t+MBNzmg2hq+z4SjaiwyliLoD Y/AJlbPVW/he0cQlq66j5hLGMzLLZZdu3AznAGVuHW0BqWucYiT0q4S+pJziRWwfye3R qHLedpiJTmNSrLkeqaI9mhfpDVyRZQ4DaGtso01G4YVgXOR7dhxbew4uA/4vljjrDqHT u9IA== X-Gm-Message-State: AOJu0YwD/XF5RjJi68/jLk9syQwJQZHHBGtziqFy6b02tdUx3jjCDcDd YCwO9d95jUTBjRv9pRYfYEjPKLzUrFvgZk1xUmnLrVFwZ8xdB13rKw6wW5fr9RWp1uNxHP/L1I4 e X-Google-Smtp-Source: AGHT+IHzv0QWsW9URg9qOqe5bn0PTgUUHw08GnEtsZ7po7QJC6hA3MEalzzH9qJauLVSzISag/dEPQ== X-Received: by 2002:a17:90a:7d0b:b0:2bf:8f9f:4adb with SMTP id 98e67ed59e1d1-2c1abc0653cmr493700a91.1.1717023457651; Wed, 29 May 2024 15:57:37 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a77baebcsm351762a91.53.2024.05.29.15.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 15:57:37 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , Reshma Pattan Subject: [PATCH v6 4/8] latencystats: fix log messages Date: Wed, 29 May 2024 15:54:41 -0700 Message-ID: <20240529225732.442539-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529225732.442539-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240529225732.442539-1-stephen@networkplumber.org> MIME-Version: 1.0 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 All messages that because of an error should be at log level NOTICE or above. Do not break log messages across lines. Reword message for the case where getting info about a port fails and it is skipped. Signed-off-by: Stephen Hemminger Acked-by: Tyler Retzlaff --- lib/latencystats/rte_latencystats.c | 35 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 2140ab87c4..c0ac60134f 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -259,7 +259,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, latency_stats_index = rte_metrics_reg_names(ptr_strings, NUM_LATENCY_STATS); if (latency_stats_index < 0) { - LATENCY_STATS_LOG(DEBUG, + LATENCY_STATS_LOG(ERR, "Failed to register latency stats names"); return -1; } @@ -279,8 +279,8 @@ rte_latencystats_init(uint64_t app_samp_intvl, ret = rte_eth_dev_info_get(pid, &dev_info); if (ret != 0) { - LATENCY_STATS_LOG(INFO, - "Error during getting device (port %u) info: %s", + LATENCY_STATS_LOG(NOTICE, + "Can not get info for device (port %u): %s", pid, strerror(-ret)); continue; @@ -291,18 +291,18 @@ rte_latencystats_init(uint64_t app_samp_intvl, cbs->cb = rte_eth_add_first_rx_callback(pid, qid, add_time_stamps, user_cb); if (!cbs->cb) - LATENCY_STATS_LOG(INFO, "Failed to " - "register Rx callback for pid=%d, " - "qid=%d", pid, qid); + LATENCY_STATS_LOG(NOTICE, + "Failed to register Rx callback for pid=%u, qid=%u", + pid, qid); } for (qid = 0; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; cbs->cb = rte_eth_add_tx_callback(pid, qid, calc_latency, user_cb); if (!cbs->cb) - LATENCY_STATS_LOG(INFO, "Failed to " - "register Tx callback for pid=%d, " - "qid=%d", pid, qid); + LATENCY_STATS_LOG(NOTICE, + "Failed to register Tx callback for pid=%u, qid=%u", + pid, qid); } } return 0; @@ -323,10 +323,9 @@ rte_latencystats_uninit(void) ret = rte_eth_dev_info_get(pid, &dev_info); if (ret != 0) { - LATENCY_STATS_LOG(INFO, - "Error during getting device (port %u) info: %s", + LATENCY_STATS_LOG(NOTICE, + "Can not get info for device (port %u): %s", pid, strerror(-ret)); - continue; } @@ -334,17 +333,17 @@ rte_latencystats_uninit(void) cbs = &rx_cbs[pid][qid]; ret = rte_eth_remove_rx_callback(pid, qid, cbs->cb); if (ret) - LATENCY_STATS_LOG(INFO, "failed to " - "remove Rx callback for pid=%d, " - "qid=%d", pid, qid); + LATENCY_STATS_LOG(NOTICE, + "Failed to remove Rx callback for pid=%u, qid=%u", + pid, qid); } for (qid = 0; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; ret = rte_eth_remove_tx_callback(pid, qid, cbs->cb); if (ret) - LATENCY_STATS_LOG(INFO, "failed to " - "remove Tx callback for pid=%d, " - "qid=%d", pid, qid); + LATENCY_STATS_LOG(NOTICE, + "Failed to remove Tx callback for pid=%u, qid=%u", + pid, qid); } } From patchwork Wed May 29 22:54:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 140405 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D80C544107; Thu, 30 May 2024 00:58:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C576240A72; Thu, 30 May 2024 00:57:42 +0200 (CEST) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mails.dpdk.org (Postfix) with ESMTP id 41180406B4 for ; Thu, 30 May 2024 00:57:39 +0200 (CEST) Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2bf5ee192b1so169952a91.1 for ; Wed, 29 May 2024 15:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1717023458; x=1717628258; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NLcIhuBFAGnFAgSH7Iuy+BgoNw13rLAjei8W7B5mHkc=; b=CciiLMKPFIvXDom3Mx+oCsvL4LA71YVGUF1lbSuHkTI7oYAnbNQoqed9Xiw40syhfY fGkUlnCBDqO9Hlz6OQbzsk6YGIDQpj9MchWi5ygCcvZ8lmwcCvXnZk9CBi53Mdp/ZkUI OEtPhagQ0CKDSAk0DFzaZ4T0dknLb78+PnJCSx6A0Lttzv0zghj+5tcoJVtrSAnZcxsn 2Uy9AF0HRcRVrr4lJtYn8rY68i4xpooILhoTcN849yYbQj+/EhsU1UpJUFF0Nl7eOXDl nrHSOnEpRF4MfyU0Dk18gC+JUEg/VDTYzavqh1KoUm39X++kDS/C8EhbaPZusg6iaRq7 0ARw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717023458; x=1717628258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NLcIhuBFAGnFAgSH7Iuy+BgoNw13rLAjei8W7B5mHkc=; b=eOlAgoBmxb/hIj4Cakl+z3QLoMGzr8YYiS8gN2lcm1obiDtzMeIiIyarabfuJ5y5Zg /dzG1XDSQSdJicj2I9M6iKGLgSEpKNu4xuOYyiGCrbzBCY/dKFIPBLR2wrggyA0rvdm9 KGXbHNOi6yPJHUtC5Lu1uG1YnU87UmeqYdgsn8iFeqOTfZjAE/USIfwzcGwZyj/0kiFJ m2et/30SfAqb1GBrp9k7EEaKAV3fuFesKZjUaSyMONAV6GJXcTXiCIcyrBMEXqpKOgN7 E6pkl3Lkgn+v49HCaPWqeKqo7rzRKbfd1/XifUm1r+Wu4mbQfP4sisNoJK9s+1MsFfKT ANmg== X-Gm-Message-State: AOJu0Yw1qNDj/WDDGH946XgLWjho0NXrBt/pcIb+uLJmDVUz5BydtB6B 2GI0ZRiroJuXvqZfXY6TvC7jW7S+ipB2HrR427D+t4/crojfKuw9xEgFOtZZSbwdPzOm+CB8HfK d X-Google-Smtp-Source: AGHT+IGpFdTjDna4YOxIs45jcHPsPbX8+lTiXI8Cr5rDLA8pHmrFJy+RFF48VmcsoamVt8FmH8OHAw== X-Received: by 2002:a17:90b:23d4:b0:2c1:a77c:33fb with SMTP id 98e67ed59e1d1-2c1acc40498mr270715a91.6.1717023458416; Wed, 29 May 2024 15:57:38 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a77baebcsm351762a91.53.2024.05.29.15.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 15:57:38 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v6 5/8] latencystats: update include files Date: Wed, 29 May 2024 15:54:42 -0700 Message-ID: <20240529225732.442539-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529225732.442539-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240529225732.442539-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Include what is used here. Signed-off-by: Stephen Hemminger --- lib/latencystats/rte_latencystats.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index c0ac60134f..bd8fde2f0c 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -2,17 +2,26 @@ * 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 #include "rte_latencystats.h" From patchwork Wed May 29 22:54:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 140406 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B060644107; Thu, 30 May 2024 00:58:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3577840A7F; Thu, 30 May 2024 00:57:45 +0200 (CEST) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by mails.dpdk.org (Postfix) with ESMTP id 51033406B7 for ; Thu, 30 May 2024 00:57:40 +0200 (CEST) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-6bf81d0d1f3so220472a12.3 for ; Wed, 29 May 2024 15:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1717023459; x=1717628259; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tbyh2BBDJylB3AYKzLsyjZ08dTesXypgKi0n1sS96uE=; b=BguL5cJbxnojbmZNexAAbHPZa1iizOKjHBVHdkjcw22HfJGR0XUlzVQRDLueQy3xy/ ogysmylAT8swyRpb3zkn/XDX0k6dM0vwtEClPayek4C9gqnWPqN53CI0Wp8UrWMC6noq IPa8W79IeIz/VaRkqjnXLEeilsPM0R97gKpCBfdYYMkFqVY0hcmybsUE1XtiHMYQqQnG dlkM1WdrihO5raS/ejiZCeXgAbOJyTJ9a9DP9ufWf15b+0OHUAGXAFImedzKDG5uI87B 4Sek5qIEA+scgMEK0/n3zTkANnJJcKTx6GIxOHc9oREMzxTw7QM4m5kexH5hDJe59EPB Q6iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717023459; x=1717628259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tbyh2BBDJylB3AYKzLsyjZ08dTesXypgKi0n1sS96uE=; b=l8zExc4A3gcuD7kIK15rcSEVZXp7hwPzRf65cQc3BAIo20tnydzAVRgWby2y3pMD34 bjBa2ou+mkkcjC8xoD+lrxWcEx0JSmJ+w+CdeRn3yx02Jw5TwLvcvgl/ccY2wIvN3xm+ xfvcyz7wbp57mns2UTOvIcS1TxHizW4aoHYDATS7FelwASXYsPEynzbrSQz2aT8rcSE1 5CCJ44QUNNjKifMJ2LdZ4sGsBEaTf1TPoYV12owPf9QigMlqpNz+e2Lrekzy0tLjIWwo AplCUg0fN99zU48mQIoEMQls3M7QolLvimD4pBwyyCpW0CqCSukyQPfzErJg/bV8Rrw5 Alpg== X-Gm-Message-State: AOJu0YxpZNZNAakl5kIIlyC+mH6yQSxLPkEMEmOZTdLLX8r/BrkwChUQ ODyZ7Vb5PsaQxIixq0YQIxWjS//0P6fqlEET6+9VEk+G7ElJ5L8MgRA1DXUIbtdgGuruEXGrsFx J X-Google-Smtp-Source: AGHT+IHYSVyOC/8S1uByc8Wh2ljZrYM3VWYTWgKhAwoy+E0QygXOOsPgjeRdViwcn8J3zx05ay++ag== X-Received: by 2002:a17:90a:69a3:b0:2bf:cf4f:d353 with SMTP id 98e67ed59e1d1-2c1ab9d9e2cmr609071a91.4.1717023459509; Wed, 29 May 2024 15:57:39 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a77baebcsm351762a91.53.2024.05.29.15.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 15:57:39 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v6 6/8] latencystats: enforce that unused callback function is NULL Date: Wed, 29 May 2024 15:54:43 -0700 Message-ID: <20240529225732.442539-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529225732.442539-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240529225732.442539-1-stephen@networkplumber.org> MIME-Version: 1.0 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 ISO C does not allow casting function pointer to void *. Resolve by enforcing the reserved argument. The user_cb argument for rte_latencystats_init() was not implemented, and had to be NULL anyway. The log type is local to this function and therefore can be local to this file. Signed-off-by: Stephen Hemminger --- lib/latencystats/rte_latencystats.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index bd8fde2f0c..8311adb411 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -30,7 +30,7 @@ static double cycles_per_ns; -RTE_LOG_REGISTER_DEFAULT(latencystat_logtype, INFO); +static RTE_LOG_REGISTER_DEFAULT(latencystat_logtype, INFO); #define RTE_LOGTYPE_LATENCY_STATS latencystat_logtype #define LATENCY_STATS_LOG(level, ...) \ RTE_LOG_LINE(level, LATENCY_STATS, "" __VA_ARGS__) @@ -246,6 +246,10 @@ rte_latencystats_init(uint64_t app_samp_intvl, if (rte_memzone_lookup(MZ_RTE_LATENCY_STATS)) return -EEXIST; + /** Reserved for possible future use */ + if (user_cb != NULL) + return -ENOTSUP; + /** Allocate stats in shared memory fo multi process support */ mz = rte_memzone_reserve(MZ_RTE_LATENCY_STATS, sizeof(*glob_stats), rte_socket_id(), flags); @@ -298,7 +302,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, for (qid = 0; qid < dev_info.nb_rx_queues; qid++) { cbs = &rx_cbs[pid][qid]; cbs->cb = rte_eth_add_first_rx_callback(pid, qid, - add_time_stamps, user_cb); + add_time_stamps, NULL); if (!cbs->cb) LATENCY_STATS_LOG(NOTICE, "Failed to register Rx callback for pid=%u, qid=%u", @@ -307,7 +311,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, for (qid = 0; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; cbs->cb = rte_eth_add_tx_callback(pid, qid, - calc_latency, user_cb); + calc_latency, NULL); if (!cbs->cb) LATENCY_STATS_LOG(NOTICE, "Failed to register Tx callback for pid=%u, qid=%u", From patchwork Wed May 29 22:54:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 140407 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 292E544107; Thu, 30 May 2024 00:58:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B4CC40A84; Thu, 30 May 2024 00:57:46 +0200 (CEST) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id 0C43740A67 for ; Thu, 30 May 2024 00:57:41 +0200 (CEST) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2c199e776ebso194926a91.3 for ; Wed, 29 May 2024 15:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1717023460; x=1717628260; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uDckzPMoggt3O0PD6CzLT8GtY/9DAGBqZIMGwEjEdxs=; b=hYLzLEaIlj9Tc1OiecuxKaJkoLgB3lt5W7ZIlF2h9Ig00vI0WA3LqSwepcSWLbQ4x7 otcVNWQJDSeMY42+BUTRd531pLE/bXa9lB0FsDDhPD2URDozgfRGXjxwNUM9ZLHBjWj0 kHhieeqFs5QRijamZm+lLTit+B0ZFcivH80amaib2ZTWbgKdkAk2V+a1ky/Z8flQpkBC NtcYZn3AvWO2GvEcYCWicVdrGIPoDdhvepXihuRqmLrjK6SMkYBhwPfHyCmSw3gREThd 1YQlKfZ/WrNRRsiomJM2rwiqEmWbiTpWy5+rC0qZWZeM9c/bY4IORi45++w/VwZdR3O1 RnMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717023460; x=1717628260; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uDckzPMoggt3O0PD6CzLT8GtY/9DAGBqZIMGwEjEdxs=; b=TyiqLXw6GzHUGtNuVM1lsZPO7ym9Mm8cM/fogRnqpZr30gW45Gr/Ai55uxvG1mGbFN MLvTH7KSesySiNbg8mIqGX30KdEOP+BvSyskvuSTo+AOU76XcuL5mZHAEktbT6bf9lkz k8knN0g8NdlHQjW/WjpKVUz9IEg4KgedKLtI2R8Uk8hlkhYVxVL/Nm35h7VrpgKHGlFn cQSMe1TwH77UqCoFLE6B86XeLQIVNs0HLQ2nYx301zoj8qTwQYHqcDIiH4c/UR56YL2p UQyfeDKgwdzUrvVnlgnOKP+wP2auTNSXkOCIiRE4DzoMMhIP78uEk/4GsB75yiWPZBJ6 aviQ== X-Gm-Message-State: AOJu0YzFrWPoL1NBUNFqBmjbMccuYx2YwiO7n1Gu2OJUjM7+UiPOEufk 4sBcJcL87vibqerq35FEvDRtWLVwx+ORkZBnlx6A578zeJwxCexl+vflqYI9Egf9L9m3TDh16FS / X-Google-Smtp-Source: AGHT+IHwbDBtw7hKzXvX4q/PC9dOs1fRZCy/3ahWQnlfkOUA4DMQ7YOqFicJIJu3kuCaFOwIM7ntew== X-Received: by 2002:a17:90b:33d0:b0:2bd:e917:232c with SMTP id 98e67ed59e1d1-2c1abc4a963mr490741a91.48.1717023460208; Wed, 29 May 2024 15:57:40 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a77baebcsm351762a91.53.2024.05.29.15.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 15:57:39 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v6 7/8] latencystats: add metric for number of samples Date: Wed, 29 May 2024 15:54:44 -0700 Message-ID: <20240529225732.442539-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529225732.442539-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240529225732.442539-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Keeping track of the number of samples is useful when doing debug and testing to make sure that samples are actually happening. Signed-off-by: Stephen Hemminger --- lib/latencystats/rte_latencystats.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 8311adb411..e5a84fbd92 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -59,6 +59,7 @@ struct rte_latency_stats { uint64_t avg_latency; /**< Average latency */ uint64_t max_latency; /**< Maximum latency */ uint64_t jitter; /** Latency variation */ + uint64_t samples; /** Number of latency samples */ rte_spinlock_t lock; /** Latency calculation lock */ }; @@ -82,20 +83,26 @@ static const struct latency_stats_nameoff lat_stats_strings[] = { {"avg_latency_ns", offsetof(struct rte_latency_stats, avg_latency), LATENCY_AVG_SCALE}, {"max_latency_ns", offsetof(struct rte_latency_stats, max_latency), 1}, {"jitter_ns", offsetof(struct rte_latency_stats, jitter), LATENCY_JITTER_SCALE}, + {"samples", offsetof(struct rte_latency_stats, samples), 0}, }; -#define NUM_LATENCY_STATS (sizeof(lat_stats_strings) / \ - sizeof(lat_stats_strings[0])) +#define NUM_LATENCY_STATS RTE_DIM(lat_stats_strings) static void latencystats_collect(uint64_t values[]) { - unsigned int i; + unsigned int i, scale; const uint64_t *stats; for (i = 0; i < NUM_LATENCY_STATS; i++) { stats = RTE_PTR_ADD(glob_stats, lat_stats_strings[i].offset); - values[i] = floor(*stats / (cycles_per_ns * lat_stats_strings[i].scale)); + scale = lat_stats_strings[i].scale; + + /* used to mark samples which are not a time interval */ + if (scale == 0) + values[i] = *stats; + else + values[i] = floor(*stats / (cycles_per_ns * scale)); } } @@ -173,7 +180,6 @@ calc_latency(uint16_t pid __rte_unused, unsigned int i; uint64_t now, latency; static uint64_t prev_latency; - static bool first_sample = true; now = rte_rdtsc(); @@ -184,9 +190,7 @@ calc_latency(uint16_t pid __rte_unused, latency = now - *timestamp_dynfield(pkts[i]); - if (unlikely(first_sample)) { - first_sample = false; - + if (glob_stats->samples++ == 0) { glob_stats->min_latency = latency; glob_stats->max_latency = latency; glob_stats->avg_latency = latency * 4; From patchwork Wed May 29 22:54:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 140408 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E1F644107; Thu, 30 May 2024 00:58:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73A5A40DCA; Thu, 30 May 2024 00:57:48 +0200 (CEST) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mails.dpdk.org (Postfix) with ESMTP id D8CF140A6F for ; Thu, 30 May 2024 00:57:41 +0200 (CEST) Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2bf62b121ccso185167a91.0 for ; Wed, 29 May 2024 15:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1717023461; x=1717628261; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IIkhU8oLFDEE/9mXOvOY6Hvh+Pj2IOf4e5YXH8jGfhY=; b=rkMnsv+OuoMUNt6NUjcZkYgsWRVwU66pAQpS5rUegeSTjFK7CcBOtyWcpr5t9WIvWk aAVmdYMCCDxH7kaidgtJuF3FCLMAWA7OE8Sz0ovAIBmp4Tp9xN023RFpNFXDj7xP46Wk 7xQ6tUy0RHkr6jKrEXfRJ/HlznzPif9Obt9XYJOXmgIXC7gpttFykO/qXCAfBpaW1yF+ fhY3gnX26zuGkOOik68ZwTMOs21uxCFYGtFuXB6Qdgtpe4DjFBqwJN5Riy+znKL8iPWL 4G1VJxewuD2b9QYN3+byAbuQl+RR+GixTRoeRNzsWEk/FWcq6uHf3I8ODxchuOvsoUvN 2ggg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717023461; x=1717628261; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IIkhU8oLFDEE/9mXOvOY6Hvh+Pj2IOf4e5YXH8jGfhY=; b=HDDFc9qhx2yqdntSmE1wGTVZHpm/iFGlxJ1+efEL6SxidrwGh3KZWXIar5uxKCA6Ae gU0u5DNA6J6m4M1SgM+ra7LRxHJPdgotTt7dReoHK1+tfRHkXW+ti3gxHC4qhI+j7EE/ j/dM5h0vCGedtnTlNq9poPsuct4vv6eXjWansXLPCp5Z1JMER1cMqJI44j7jOEE1PJ/T JywSAhIg5BYOUHMT8NocnKohtyFjYOzzy1QNfkJjkSa0t4AHLivrJgQMQ85MQOVmXNWL 1ULIXxvw+4TteOiHS8UiuOWZd1n6R23+SkEjx+hzhYROc2DU9K0Y43FCD8NssewTIFa0 qXvw== X-Gm-Message-State: AOJu0YyKyWl+F7zjGfFCSIAGQFQKmjI3xSmdhjfQmLNW+p7We9TOvvtO 8a5XTxotimnG6lBpkQE7SR2OYY/JFRaLWrM/slM/J4zD7OdC93jdZSXmvTm7c8sFS1Px9wXTkjM q X-Google-Smtp-Source: AGHT+IH3FGOxcTawTlj2kwc3MNDxU/CIA2U8Cg5BLSIqiQxZT/sIe4rLxbos/RTnZ2vz/NRJJZxgSA== X-Received: by 2002:a17:90a:ff0d:b0:2b5:91d1:3ae8 with SMTP id 98e67ed59e1d1-2c1acc59484mr257569a91.14.1717023460940; Wed, 29 May 2024 15:57:40 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a77baebcsm351762a91.53.2024.05.29.15.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 15:57:40 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v6 8/8] test: update to latencystats tests Date: Wed, 29 May 2024 15:54:45 -0700 Message-ID: <20240529225732.442539-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529225732.442539-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240529225732.442539-1-stephen@networkplumber.org> MIME-Version: 1.0 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 No need for loop and memset() here. Just use structure initialization. Remove unnecessary initializations. Look at the number of samples, min, max and average numbers to make sure they look correct. Forward for longer to make sure multiple samples are taken. Signed-off-by: Stephen Hemminger --- app/test/test_latencystats.c | 84 ++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/app/test/test_latencystats.c b/app/test/test_latencystats.c index c309ab194f..676a99d385 100644 --- a/app/test/test_latencystats.c +++ b/app/test/test_latencystats.c @@ -14,18 +14,19 @@ #include "sample_packet_forward.h" #include "test.h" -#define NUM_STATS 4 +#define NUM_STATS 5 #define LATENCY_NUM_PACKETS 10 #define QUEUE_ID 0 static uint16_t portid; static struct rte_ring *ring; -static struct rte_metric_name lat_stats_strings[] = { +static struct rte_metric_name lat_stats_strings[NUM_STATS] = { {"min_latency_ns"}, {"avg_latency_ns"}, {"max_latency_ns"}, {"jitter_ns"}, + {"samples"}, }; /* Test case for latency init with metrics init */ @@ -70,13 +71,9 @@ static int test_latency_uninit(void) /* Test case to get names of latency stats */ static int test_latencystats_get_names(void) { - int ret = 0, i = 0; - int size = 0; - struct rte_metric_name names[NUM_STATS]; - - size_t m_size = sizeof(struct rte_metric_name); - for (i = 0; i < NUM_STATS; i++) - memset(&names[i], 0, m_size); + int ret, i; + uint16_t size; + struct rte_metric_name names[NUM_STATS] = { }; /* Success Test: Valid names and size */ size = NUM_STATS; @@ -106,13 +103,9 @@ static int test_latencystats_get_names(void) /* Test case to get latency stats values */ static int test_latencystats_get(void) { - int ret = 0, i = 0; - int size = 0; - struct rte_metric_value values[NUM_STATS]; - - size_t v_size = sizeof(struct rte_metric_value); - for (i = 0; i < NUM_STATS; i++) - memset(&values[i], 0, v_size); + int ret; + uint16_t size; + struct rte_metric_value values[NUM_STATS] = { }; /* Success Test: Valid values and valid size */ size = NUM_STATS; @@ -149,10 +142,14 @@ static void test_latency_ring_free(void) static int test_latency_packet_forward(void) { + unsigned int i; int ret; struct rte_mbuf *pbuf[LATENCY_NUM_PACKETS] = { }; struct rte_mempool *mp; char poolname[] = "mbuf_pool"; + uint64_t end_cycles; + struct rte_metric_value values[NUM_STATS] = { }; + struct rte_metric_name names[NUM_STATS] = { }; ret = test_get_mbuf_from_pool(&mp, pbuf, poolname); if (ret < 0) { @@ -166,9 +163,41 @@ static int test_latency_packet_forward(void) return TEST_FAILED; } - ret = test_packet_forward(pbuf, portid, QUEUE_ID); - if (ret < 0) - printf("send pkts Failed\n"); + ret = rte_latencystats_get_names(names, NUM_STATS); + TEST_ASSERT((ret == NUM_STATS), "Test Failed to get metrics names"); + + ret = rte_latencystats_get(values, NUM_STATS); + TEST_ASSERT(ret == NUM_STATS, "Test failed to get results before forwarding"); + TEST_ASSERT(values[4].value == 0, "Samples not zero at start of test"); + + /* + * Want test to run long enough to collect sufficient samples + * but not so long that scheduler decides to reschedule it (1000 hz). + */ + end_cycles = rte_rdtsc() + rte_get_tsc_hz() / 2000; + do { + ret = test_packet_forward(pbuf, portid, QUEUE_ID); + if (ret < 0) + printf("send pkts Failed\n"); + } while (rte_rdtsc() < end_cycles); + + ret = rte_latencystats_get(values, NUM_STATS); + TEST_ASSERT(ret == NUM_STATS, "Test failed to get results after forwarding"); + + for (i = 0; i < NUM_STATS; i++) { + uint16_t k = values[i].key; + + printf("%s = %"PRIu64"\n", + names[k].name, values[i].value); + } + + TEST_ASSERT(values[4].value > 0, "No samples taken"); + TEST_ASSERT(values[0].value > 0, "Min latency should not be zero"); + TEST_ASSERT(values[1].value > 0, "Avg latency should not be zero"); + TEST_ASSERT(values[2].value > 0, "Max latency should not be zero"); + TEST_ASSERT(values[0].value < values[1].value, "Min latency > Avg latency"); + TEST_ASSERT(values[0].value < values[2].value, "Min latency > Max latency"); + TEST_ASSERT(values[1].value < values[2].value, "Avg latency > Max latency"); rte_eth_dev_stop(portid); test_put_mbuf_to_pool(mp, pbuf); @@ -188,22 +217,23 @@ unit_test_suite latencystats_testsuite = { */ TEST_CASE_ST(NULL, NULL, test_latency_init), - /* Test Case 2: Do packet forwarding for metrics - * calculation and check the latency metrics values - * are updated - */ - TEST_CASE_ST(test_latency_packet_forward, NULL, - test_latency_update), - /* Test Case 3: To check whether latency stats names + /* Test Case 2: To check whether latency stats names * are retrieved */ TEST_CASE_ST(NULL, NULL, test_latencystats_get_names), - /* Test Case 4: To check whether latency stats + /* Test Case 3: To check whether latency stats * values are retrieved */ TEST_CASE_ST(NULL, NULL, test_latencystats_get), + /* Test Case 4: Do packet forwarding for metrics + * calculation and check the latency metrics values + * are updated + */ + TEST_CASE_ST(test_latency_packet_forward, NULL, + test_latency_update), + /* Test Case 5: To check uninit of latency test */ TEST_CASE_ST(NULL, NULL, test_latency_uninit),