From patchwork Thu Feb 13 21:20:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151472 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 8A8EB4621D; Thu, 13 Feb 2025 22:22:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1FC05402E7; Thu, 13 Feb 2025 22:22:06 +0100 (CET) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id DCF0A40263 for ; Thu, 13 Feb 2025 22:22:03 +0100 (CET) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-21f49837d36so17781685ad.3 for ; Thu, 13 Feb 2025 13:22:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739481723; x=1740086523; 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=CnVSAYAbQ2z/4cSeWqU+i2QAV8uRRSj293RCRmal4rk=; b=Ddu2tGm1NbqOw59lXqtE6Ns8pyQ2cyMYrKwGh3r04ud5fm5P+1BWCRUYTEq7oK77HI YTeRRMmVhecMfOktZuTbfobh4ZpIANuVG3Lyw+cUzTSIBFRw3Nec7vZ0G7R3kpF9XxYN y8O3GWMwwrMJLUNx56oKPw2LOVrdIeQRcyCboOTf5ndYW09x/8w5ct0jQX5ored/uoZT CUYj8GZuB/zjezWoAMJLiqASWNxO8Ta+AqAEBeD/pxJDSguXKojikVPKeuj9kDWfMuze AaDh+ZOxqF1wQZwNIQcnwxkEGH6MF3cTBrnARCGr7jdtRJFT3TNc/7Vnr6BLvmAMMKvq Yd2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739481723; x=1740086523; 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=CnVSAYAbQ2z/4cSeWqU+i2QAV8uRRSj293RCRmal4rk=; b=pqiP3QUBiCHSUaiDkvqkKw3uHJTKsNJfjFPV7kwC/Ff8u+PYvz8WKq78Kmh2u+0OYL 7AXO1+6lnSqkw6U3RodcmKu5zwJ/POZL/h7R6NcoyynmDQZDK5gVj7P5nRyq8smHZh04 Z/ISbRfowBzECMxkRl1QIxq8k7qt4F+H/uKh00FWwZ5BfQLZG3DsZYlRkYyNgq1EIuGO iIj0t5CiuGmFmsObcf7xJzrccltaSJsnlcX+nrf5ZOyMtZjRX9Nqu6hyoJqde4wqSDmz 9CtFZPWCGAvVv3kavIFxOJX6HMtP2NtoKnSKCAW2wZVNz8lIJnKyjKnnTYgTw/9NBS5A Jcog== X-Gm-Message-State: AOJu0YweUmAgDWDQ6sEvD/4eq1yEJE27twIl1hJmW0IKEg7wBuE5n7Mp F0ZJN5vHBLcJp6hEPWFxQG7W6TxNb3gIFHZjZ2pm5CEiXVDp1K49Vntjbqsolr6KTS3EqUup94F q X-Gm-Gg: ASbGncsmTP6UBCpFjEzDeig3F2Sj1PfvV+erjRuoDf8zNGWCRXMnIpJfqhu/3ggxZ6l OEA6slF1zsnONhgT/ag8iUcdURyqCj6VM3frZQ+CmgEk51H+a5cxi2DE278y5Ra/DPXcekuAeW+ kHFAYxRyGseGJlIWk/YFMKiyWMrLLR95JylqxLbgYMTtni1ojRrBP/xGV8jvm6LX1rMX2vwBCqq /jrLdGil3+4imyIQDxz+AYp6n25fefQABVNkbrrqvxFsGuJGtJkXacqbicr0LABmyXuWSCIrJ1e 0re7Iwcmbl4fal1UpUGE0wfMb2W7U3NmHDQmLKzoJYYjK1Cf4ALD4z3ZjbjgMdIQIsk6 X-Google-Smtp-Source: AGHT+IF4A7Ssc1uvzczPke+Flyq8nSIdXz3Flfo1ZtB/SnDxeh0S5CwK6sTt8daVSSN5wGFlz3U0sw== X-Received: by 2002:a05:6a21:d86:b0:1e1:b60c:5bdb with SMTP id adf61e73a8af0-1ee6b39bdc7mr8554506637.26.1739481723115; Thu, 13 Feb 2025 13:22:03 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-adb57c5de85sm1615822a12.10.2025.02.13.13.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 13:22:02 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v7 1/7] latencystats: handle fractional cycles per ns Date: Thu, 13 Feb 2025 13:20:30 -0800 Message-ID: <20250213212151.1693506-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213212151.1693506-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250213212151.1693506-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 6a261309f9..91eb0e4544 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 Thu Feb 13 21:20:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151473 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 4F1964621D; Thu, 13 Feb 2025 22:22:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D1B6402F0; Thu, 13 Feb 2025 22:22:07 +0100 (CET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 35A4C402C5 for ; Thu, 13 Feb 2025 22:22:05 +0100 (CET) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-220ec47991aso2791995ad.1 for ; Thu, 13 Feb 2025 13:22:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739481724; x=1740086524; 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=Z0Fs7TdQ0CDqCtFz3XS2x5TmvWpmJDSQ8mBHwYclupg=; b=ZQmuIVuwhuHNRZ+uCJmU3l4uOk/h560qbHJZZsvzC3N8Xdm7FsI7yFBdDA00HY9qGh 24oK/dg6LrwEbRgafmk/apgbFKTqtj+rfoRNjzVrsYIRBeAu5JXSGtlaGQIH0Zs8C8Vz NvAYJ6ryBM93t8u1cswb4AfvBtS1m20qSHTJu3RkenrgUYSgTLCL1unOcrIlHQ4ZyJwD N6FXu+RiaNQ0qPg/tTTp+z/x9nD9TLnpL7ZaKhIHRWMlYw/PFNB4J1fjZFq/d7mG1j1d t0Lms1r6GEifAzPmN4I2wm/mFroMbfIgiOGEXzdp4YJMLCt/pw5ri6Ijz41DvYw+4E0e 8fHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739481724; x=1740086524; 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=Z0Fs7TdQ0CDqCtFz3XS2x5TmvWpmJDSQ8mBHwYclupg=; b=Df3s40WAv6HVLtY3BwretpR12zsVnWOhRvc/qh90S8yhG2kd+4T9809RU9BF1lRnJG 0PM9S/4UhMgFa7+/NTUhZ8eQ7AFol18t5Ug68lLAP8GYmO4Wc3TmTzC0xztgbf/dWD2M rsFczgYXaXOzGmouiDlwOrZO1y8+H3ijb4KU9xV/mgY3OJXseCzYRJiAuCjWcQ6AqVrv 86wzrzjcd7jMdudlRVW700+BgwqQxOvTytv75z/j/DHUNelWXiGNsc87uHTYJZk+itST V+saQ5g0MpSfD4bNWZrOWTS/cUmNpdaXkEqUBuENno3LM4ZGZn5ADuxxhglGXEb252LD y1Eg== X-Gm-Message-State: AOJu0YzoZmlR6ZSEIy0XcLaMxPK9rShtwBkXt3IBH3Ut2wYA2paksW/n 6SdvHaRKEN3F93UKm20AokzQLfSzQQxVk3RxwYWyfx3L+Fk+bDD9/D5tg6wDVibdMZKyF1JRrO1 v X-Gm-Gg: ASbGnctc96uWpHoGPpAj/Cnw6JlyiZsUhGHXdcTFKeZieYfbMcYQ24NaFQYfXTrU1dv +VVIFeUY/lDVCpcwuoQVE5qboDZRqMAv5Ly2Ruk39jsbgDjw/4cc5oS5gCw6IVUO/STdsqVHh48 HTv7+3g28Yi9sJJUjMKHchrLphpF2e3p/nL0BdPvEYMJb/LGEMqXglPI9BmOAMXFcsVaYS3mLuv DU5l5oSR0/5Vev3Ugk0eR1udjEck6TYgtFfvwzmZ7QrQxhCq6hVJjTlpSkjSiBegvNW9DuugaZd pXT1s1BOjM0CLi9eKMTvdp6Qdsym5ERgJyVj09Crp4OqgY/H4XMPP4NKblvPZHZtUWgG X-Google-Smtp-Source: AGHT+IGmYXtQTpi1rLxtgMsWX0kHmybZ82fYtI6mWWrCWhvQfpz/lPygKFUpWzHRmhxXWbUbceWwaw== X-Received: by 2002:a17:902:e84c:b0:21c:1140:136c with SMTP id d9443c01a7336-220bbaae91dmr121841945ad.3.1739481724185; Thu, 13 Feb 2025 13:22:04 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-adb57c5de85sm1615822a12.10.2025.02.13.13.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 13:22:03 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , =?utf-8?q?Morten_Br=C3=B8rup?= , Reshma Pattan Subject: [PATCH v7 2/7] latencystats: do not use floating point Date: Thu, 13 Feb 2025 13:20:31 -0800 Message-ID: <20250213212151.1693506-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213212151.1693506-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250213212151.1693506-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 Acked-by: Konstantin Ananyev --- 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 91eb0e4544..b7a4e313ad 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 Thu Feb 13 21:20:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151474 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 B4EF94621D; Thu, 13 Feb 2025 22:22:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 33C6F402DD; Thu, 13 Feb 2025 22:22:08 +0100 (CET) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mails.dpdk.org (Postfix) with ESMTP id ECB7E402C5 for ; Thu, 13 Feb 2025 22:22:05 +0100 (CET) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-21f78b1fb7dso23405675ad.3 for ; Thu, 13 Feb 2025 13:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739481725; x=1740086525; 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=Iabywrl0u11YGh3Q3Dtu1Jk/vzT4tGJ0vMVH+hzkvQ0=; b=GeCtngkORSvoukbHq1WSof+Ei7Zbs99/4x0+4v1pMy80yiJyga5EvcRv0VRfK2QMnA JF2DnsjxJscHyENgBqQEXAaeptE0zBdFU8Qy8Giv3CNPN1L/c3PjRpsldKX0GPxleUxx 9CRgYOF9CrVljKLnW9e3fv8nO3OjSn/NnOyxd3hNu/kEwXxzJ7aIepVZlmeAFed71ASZ z7eLVwYzKyUCoJMx41qM+U+gT5R6USQdbIgIeyhBQkvvwGCfsohoMI5S8lNwJp8nThsa TPeNVhhFtUeDR3c7dKcdpl6knHm3gT+nqGbyNamXzRWV+xrm+PLAKwQFrrgyX4h7Fb/L G1Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739481725; x=1740086525; 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=Iabywrl0u11YGh3Q3Dtu1Jk/vzT4tGJ0vMVH+hzkvQ0=; b=qWenq+KlTLyGh8gNzTXVhzGtCEla6m8kZw1CNCJIj41pAfFdfkY5eReET8D9+rfF8X BKbWCg7LSCCzPY+Zcg1rK2M0sxB1SxtOsqJoPa7MU6wYcJYpLhT0G2N8HWykcULXugtY ckFT872diFjE2ObL5sOS2FyaqbvbWXp0ggeRdiARArr/k7HT4Gx3u5yg7ILe5rJVPuRv RdAvq3EoWmoySKSxWuWB292xovtwblLrdfSfFV0gMEi/sjc2pPpUmYkesmSkkeLYmWaC CLLc5+xQ2d1Sg79HfSDhp0ds6yjyIDif9aNNUwRJCkmWsp9dz0KV62mzOM1DyxkCwKT4 4GeA== X-Gm-Message-State: AOJu0YyrTetaqXLQ6VxCPIJDR+rfm5t1xu8nhERgA8bd4zJan1uSkDtk ZqRCk6Bigw0xHUoTLc/8imKxRFRqi3nto+pQg3Bb7zRHMdhfPxaOheoAhZ7b2cRJl35h5gmaYGx W X-Gm-Gg: ASbGnculnta9AskdMRQ10mbLdOB5WrfAhjwVc12nq9HVHF1nUWl6wMMnv5hGPO2Qdud Tiu6pwOhwDc34HBbdu/3CCl8TPC7T9gDM/lmLQ0cTLkjS4l/EIvsXrTyQQIL7uulELXtjpsA2FS mHEFAtZbP5i0GjgE/ZCGyOpJIVJPa6gT2uSBLrRQj/pDfD+q+o7+8kjnXmo9Ic26ah+sAx+XZWm /c/pY5QV2DZd/GyYNqmy3q2lsRiJhsaOvpPQSYmW24bam2r8zeby34W5fsjyV6UHhtIGlYDUPvp UJdjGBk+ijtb8JwyBrSnsKu8sQ1ULxlEJ4gZE6T81KbHfmpKB7/Z7oE2FbS0LGywNX0Y X-Google-Smtp-Source: AGHT+IHwd6NpUdbnrgK1EgtQ54zdTyOU7ebAssScAuV4up9LUf9k/40DL+yW6WjO9xuZUpcgIdrDhw== X-Received: by 2002:a17:902:d50c:b0:220:be86:a42d with SMTP id d9443c01a7336-220be86a79amr120983235ad.21.1739481725095; Thu, 13 Feb 2025 13:22:05 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-adb57c5de85sm1615822a12.10.2025.02.13.13.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 13:22:04 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , Reshma Pattan Subject: [PATCH v7 3/7] latencystats: fix log messages Date: Thu, 13 Feb 2025 13:20:32 -0800 Message-ID: <20250213212151.1693506-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213212151.1693506-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250213212151.1693506-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 b7a4e313ad..82c310da92 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 Thu Feb 13 21:20:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151475 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 18B8F4621D; Thu, 13 Feb 2025 22:22:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 29E8A40613; Thu, 13 Feb 2025 22:22:09 +0100 (CET) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mails.dpdk.org (Postfix) with ESMTP id E84C7402F0 for ; Thu, 13 Feb 2025 22:22:06 +0100 (CET) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21c2f1b610dso31550235ad.0 for ; Thu, 13 Feb 2025 13:22:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739481726; x=1740086526; 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=NE6zl8XsJ9Mi4v6+xHRRaeLGuAW7qv3igvxwRXR74us=; b=1FzD1BYwGVTnhmavJs2p1Gpvy18/Klv1rWqcN2/mN08C7Jq0zR65pCWdFtt+M/8PFL ilQBuO1WNr5i3ZGq5vH8jbqALxBfCcWxYhPAv3rsKL3tjQH1yCZKoySB0cBrpR0r7kGd wRGg8FOnMOfS+IuIRa7tjk5ZtLfpxUmdbxvtVR3u7bhINtFDLE0iml3iWa75c8sX2PaW e+aV9tVrdiTA2ohhO5/Nozwza1yWazSkhL9x+pBY51y/WUb/TqHIoPiTGphsVomawBve IqO4q4BWgY1I+Isc/CkV9VeefWZ14mk37n2SlJjwMZ+z6xuW1l9MedHtsBRWNFRRKmUJ mdaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739481726; x=1740086526; 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=NE6zl8XsJ9Mi4v6+xHRRaeLGuAW7qv3igvxwRXR74us=; b=A6o7S52SYIvcxP8aP6JUPwdyUQbzTEdUI5z8XztosZRdz1tS8gGLIyV4oOiUxVsY/V gIz0JVnT4reEFRI6aWPsnQX1NmMCP+NralPqTJFzRw4bDp/VZlH/+eBWich4xD0yTvGH NjSREv0s45CW3qgotugD4Wo/3OW22zZxO0V1AlKt8ZkqTutfUx8WnYvUwkeMycQOIQWl SYSe0lo5PQEydc68gT9tbIHLCkp1QvKRdMMzuHa6/LqWLbllVaNgHBBkLlV74ZaePXP7 tDyvW5pXy6WjmHLxQ8ozuYQ127fQkNgHH88LB1nYh36d+deTbwLD8r28yKeEv458fzGs qbKw== X-Gm-Message-State: AOJu0YxfSoftTFkZDl2Z3dpBYupC300K4mkoekkK5WadpEXm40u7BlGu A44rGqnMJ8/k0EY74ovYDRP8hKqV+wchBpUSeypD0F98XJFeJJFQHzGR0O+3mD5ve8WmX9BuUpG 6 X-Gm-Gg: ASbGncuic1qO65lC9MUE/j7cdSdOSQswLDTfnmADFCn5SJ8thgO5jlKXgoFSVMOQl7u /7kKQlakTg51uCFnYf0Vhh6Tc+xp8zysEJpgetyF3mx1SXRYiz89KDXnyhzUbCYp5U1wEFoTQ1J b4v1c//pw5BrBM9AIFiSXgzosGLqrnpi7j381bldqqbVYrR7mmggHGsv0ndcBraAcxJMP9OSpy9 OZAE7H+Se3doMQKRJ3jcaIw5oOF1gpm/K+ZKG5j79oWHWBBb1qKG6AkiRNoCdkTNKzXQOq+L1l0 i86vSPdatPw8I20y1Acn4zTq4qLpZ3gbF00GLNrB0AxfCJIUfuHyPVxbcm8LucEJjAG2 X-Google-Smtp-Source: AGHT+IH77qgWKF3Nq2LjU8LCAdDaCkaIDeLVTRZSAWn8GMTr8X7V+wxzmLk7e1LR6hUIb1XFFfeq4Q== X-Received: by 2002:a05:6a21:e8e:b0:1ee:40e2:8f51 with SMTP id adf61e73a8af0-1ee6b4459b1mr8659050637.42.1739481726119; Thu, 13 Feb 2025 13:22:06 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-adb57c5de85sm1615822a12.10.2025.02.13.13.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 13:22:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v7 4/7] latencystats: update include files Date: Thu, 13 Feb 2025 13:20:33 -0800 Message-ID: <20250213212151.1693506-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213212151.1693506-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250213212151.1693506-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 82c310da92..b990e5760f 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 Thu Feb 13 21:20:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151476 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 450EA4621D; Thu, 13 Feb 2025 22:22:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C86B4064C; Thu, 13 Feb 2025 22:22:10 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id DD77240608 for ; Thu, 13 Feb 2025 22:22:07 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-21f78b1fb7dso23406195ad.3 for ; Thu, 13 Feb 2025 13:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739481727; x=1740086527; 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=uV4ZLpATtL7ThVS5wKYNiH3TvFWVsITy/umpAzX6evc=; b=CzPUlUu8Jyev4bZcVeNnElWGBI8hPkksOflYy06pZlJ1Aui89vR4Ox17+uokhtDBkZ xtGHyT9GtTBBvVT6QeZdaWlrUxGtcbmKlIYwZ8FAdh+pN4JLFCjE8Tqj9UcEamCUNW2X gVLEi8OKVEKDmTShi41NPYdHEarH9IuvIaI7ofcs+tSFZDXReG59Av2cg8UuteFI0vZG P+zxY08jhE/4YBYkU0+mMunIodRKuHvnBQ1VzdkqkupseafXesYiGboDAeG8Gqy9BNGd UnzGg+JHSTCdDAHx3/JLnv2CGpAOf9uuGs4O8H7/2BqMG6ziW33r2sKdCVpGfRAlAnWj JdnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739481727; x=1740086527; 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=uV4ZLpATtL7ThVS5wKYNiH3TvFWVsITy/umpAzX6evc=; b=FRyyg6LaiAtTbC85nV4goxzmMdViF3oVZ9jDefrxvde69ybh+CLNd1MG0Fj4HmW7rp +H/y0vsoyBmzlQQAl4OOLsY0exUwzzRBuRi1WRJmjk93LstZSwwjaSSN59di9d3/IwSZ Dm8qcNoZvkMWbvXXTQGMj1xVXq+0ivsyiPDlfYYrZ3I17xVgNHE3O+i3K48bdB4ITZR+ uPrVrpFG3Atb8LgfczPPsGlRUpZtio65XK7AqHQdKOIifW2Zw/oW0lPkehQsUhP9ejmV 6YMuawkzzBT9bj98eyaf7kHAIPqTDk2wCCxjkf37Ax7hRy04CTpxl/osSK1AuTVt1/ar kl0w== X-Gm-Message-State: AOJu0YzGmXwd7uiZ/55C6oo0XzUEW6R8mXS11kskkyo/3ly2GOre/zWN ruqcT8eD0Y9OecmanvXRNAYaKlWwgBgrIG4fBzno4ZumozxmmWMlbGjFrh6//9t3Cw44S6plp7k m X-Gm-Gg: ASbGncuadEpiciKr0ZXZmPDusrQq01fP/jzK8wpcMGLMg13NoyXJSuXqAfJL6DbOvXn bxNmM8R+MjOftqccYU2eACZbBDk6YcD4yAFX6iK5OPCKeblSbw6FZoH1UKLOImvu3GqnELwZhbU NBZc1ECMCbTndNngsyRZ4Utc1vo44cAeIxYbF/uPqOQtiWRiamvzAd19M/J74G4Wehl5V7JviUw I6eKGuiq9st8PuXFatY9e3Cq3xmgptWrp61twxSUW9noQknSbopeCwQNFFUzZ4PXNQMxuLvy9pv OoT9IgS3aNXBcbuEzIpsuYU/98snfy9r27rQJK7bt8JDQzOSb5ORlmPaN1CcX3K70d8u X-Google-Smtp-Source: AGHT+IHqEPvOuPchlBOi0raoa5bhTWOJvGfItWr5clN7qkrzD5jMt/jIJttptATzkV1cNfYE52FEJw== X-Received: by 2002:a17:902:dac6:b0:220:da88:2009 with SMTP id d9443c01a7336-220da8820d6mr50187345ad.45.1739481727082; Thu, 13 Feb 2025 13:22:07 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-adb57c5de85sm1615822a12.10.2025.02.13.13.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 13:22:06 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v7 5/7] latencystats: enforce that unused callback function is NULL Date: Thu, 13 Feb 2025 13:20:34 -0800 Message-ID: <20250213212151.1693506-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213212151.1693506-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250213212151.1693506-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 b990e5760f..d2289df7f2 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 Thu Feb 13 21:20:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151477 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 5B2CF4621D; Thu, 13 Feb 2025 22:22:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DEFA24065F; Thu, 13 Feb 2025 22:22:12 +0100 (CET) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id 1693440611 for ; Thu, 13 Feb 2025 22:22:09 +0100 (CET) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-220e6028214so14090145ad.0 for ; Thu, 13 Feb 2025 13:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739481728; x=1740086528; 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=JE7QkW64Wddm3KJJIswSSi7oP0fmo+bfzNvhU5m6WKM=; b=w5+O1Qi4HqAFwTIj6tm+yG1jAu6eMyEEth3AoBoZ860p6oyF3arMDBRmx2Bo1rBwTj xaqlqhb8MxEmAfzxIzwUCeiVJHUJemb7nj3bKk5pJOLcPp++p5ILuzdIifZFEei0vIV3 eBSXcz8A6nCnykxhINMR/hgC/sozEG2Cs0HjIFyf18bCSLUmuDqPY15zHUqasKm7eyh7 Rw2D1vaSIwXjcG/fTYNEG/63IXMcK4/2Hp/uok208UiQqI2bni2ICH829g36NfRVmU0X Y958t6D4fKF7Z9TTB7mw4cNCrhAA+yK1nu4jS4i77YpDkiNJ4NgMRHA1xINJGFy96giJ A23g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739481728; x=1740086528; 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=JE7QkW64Wddm3KJJIswSSi7oP0fmo+bfzNvhU5m6WKM=; b=bToOF6vpXFTN4+0BIn9v6NMOtAiGaKn92AjnY3+eQX/rwlcKZBA2wUKwnpJEb2m65T PZkIGSkRBDT77gqDrwKMUHA5+7N3aE3Kf+f0p3RvE2084rHRtE5S9RejzeQ8dCFfXe2M Um7ww0avyJHPl+jkVADsr9xGWGTg3Zv+syz96QRP5nDJAUjafM76XHOIPZGC1HhdEjfb 73pddybNDEQUDtL7MQr3W6FVtk5cpZ0Vdrv1UP4YoRtLzAETOaQVQbqzTkqfiaIZ6jlM rIzQVEA+p5yKJZLEtCTiA08drK0fWmSyhsgQ7YpYt/LlHGL1KGQqvxGYa1hfsFxR9L/Z S4Tw== X-Gm-Message-State: AOJu0Yzh8bpZCLK+xyvdERkzdgP7EA04pOJp8akWfkzXaAO5mAwkax7/ oi36VTSuPuHGEhT/oVMpHFyJNQpZxhuNuS+z2tsGhoKnLOhwjdg/vlWMy7Nk+YIwm2lmt/fkeMM A X-Gm-Gg: ASbGncur7xNxkZJ2PUKp+fzQh3+4TY1p5dq4SKO5wVqTOLNxs4bvG6DUVlNabuWo2Fh t7hqJNDsUvbEc1WjD+avPrxqlIYtNZoydAbqzGSMCdo0uzsA/g8vZFnySWH1KEp8wtQD9rOqqD/ GH2T+qbqUrUk4Ur4SyNKoAUAlu2QglPGwruKdzPsDssDSPH+5rcLNQg3ABT3JtkN88lKk7cZw3U BMSZhxEBl2x3RbwMkSdck1udHBiU9fYkUinAASHs1ImjyO34F1xflCP/FhXA5j5iMLaiNuEBj+J 9hn8Rup3ErpdsWac8xcmDfc7vKGkScuETUb2WHPJKMpbCFc1jqz7iBfQiDNRM/rdnKiE X-Google-Smtp-Source: AGHT+IEy3bHU/q902o1E+uo1P2Yz86Ioru93zSJgsBoDqFxrui6b+dj/n1gmng90MWZH8EEaTWQ44g== X-Received: by 2002:a17:903:1cc:b0:21f:658b:8ee8 with SMTP id d9443c01a7336-220bdedc600mr135535295ad.2.1739481728359; Thu, 13 Feb 2025 13:22:08 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-adb57c5de85sm1615822a12.10.2025.02.13.13.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 13:22:08 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v7 6/7] latencystats: add metric for number of samples Date: Thu, 13 Feb 2025 13:20:35 -0800 Message-ID: <20250213212151.1693506-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213212151.1693506-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250213212151.1693506-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 d2289df7f2..dd3504996e 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 Thu Feb 13 21:20:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 151478 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 3A9CD4621D; Thu, 13 Feb 2025 22:22:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 101FF4066C; Thu, 13 Feb 2025 22:22:14 +0100 (CET) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 302974064E for ; Thu, 13 Feb 2025 22:22:10 +0100 (CET) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-219f8263ae0so22811795ad.0 for ; Thu, 13 Feb 2025 13:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1739481729; x=1740086529; 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=Nfzftuol9TKasfULCQivt7OsevKxD6HzWoJJXbL/TuA=; b=EnfX7AQBJd9HrikYFj9AfYI/9MLZZWesA63yf/9hqG8LgxJUHVXHPrzGSTBGKAR+MC n1aIgjHx/ARrU1S+Ey8k3EYqzOv4kLz0kyroB6NfreIAT8/vyDc00B9kBtA7K9Ybu6Zp vZ5HGwHJLMkoZefTQGoRf5AhbiaRPX4BCmvR7/2LY5Ka0MkEEvMn9e5ll+uUtCOnnWhi 4h2KhjDn/vtkOsMRZuKIp8txuoQ2ThY6C4+4OE9oOFaMgOZg17DHHuVjBXp0jZvFc18I GS7k/Y8susd5okmfDRpLqt2S8aos+xIKZQJP9eI9dcyrDl6eH+jaaqKc6IbMQFONsz8d d02w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739481729; x=1740086529; 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=Nfzftuol9TKasfULCQivt7OsevKxD6HzWoJJXbL/TuA=; b=onxnTpdCN0Pu2apN2iWgaV4VT0uf6d1LW1aBhplo/Hdafln+RqZOh9EaytkF+Q1B/k I9vv0ZEUQVs5y05L49shZwPC8VTHX12oHUYmUNCZ7rgQQYEyekG3gnH7/os4qekd1JVO 3OpZD9YxFkPgVsfPjHz/g4CzwZYE/tnSFLvBsUj98nrrQvfZSRHiYMTtKTs9Xn/n+PTH HLChPkYlqi3AKGeUeNdPK91cT/EpF/5KYOISEOWJ7Yd150HM8mTQhJYKaRTShlz4BvO8 3DxW8yKHCnP73NpRwNlXLb+IkY1uTgprpdXJghTqjVlb5SLuaDV0kSb6LCSteKzZ1znQ 1QeA== X-Gm-Message-State: AOJu0YxVsymuHpDK2gnWviLl6crTeiHXv3JAFaQ0sRXAgwkSUadBoF51 TFfpiSKZ0MCUpKHsCMtrltJr8xllj08QSwH663GGxUuactHCEqlV5SRERo7tW4pewIVkXOEmyS9 O X-Gm-Gg: ASbGncuehvxD0CjRiN+HFeH0epzw/BXgnMr/rFWpmUZW2TNE2z9CP8U67anXzUsTVTM wKmpJVmsWB1POulffwFy3r0hRPMzQOkJGtJe4IQ76u7wKcPNGv6IiIe/SDfBjFwfIsU+2q4QyjQ oVaWer7aMmWOtXH7f7/eJK8NkhjoUTFw8dVpqZBglW7buXDS3/ZMWANsIn8b55P53Y23Oye5WSa G2bEYzc8dJTF97arMQCKWcnHdQjt+X+Z6ColKZCZttXv0/SvONGNWyEe/XSwFfYxQJvVAb19ZDo mESKCgNNTFfeEordKWZVwLc4oMRbSIxh5sSVzB0q7xMlztnlbal9Cx9D0rr2+1whD04W X-Google-Smtp-Source: AGHT+IEIQRBwIq1zJupZM2ZmjQoYn9aJD2zfrbvCC9m1DvpQqf14GnwNuvINidc+Q2dVfuiLZH7o7A== X-Received: by 2002:a17:902:c945:b0:220:d5a4:3ac with SMTP id d9443c01a7336-220d5a404a4mr52353285ad.45.1739481729373; Thu, 13 Feb 2025 13:22:09 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-adb57c5de85sm1615822a12.10.2025.02.13.13.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 13:22:08 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v7 7/7] test: update to latencystats tests Date: Thu, 13 Feb 2025 13:20:36 -0800 Message-ID: <20250213212151.1693506-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250213212151.1693506-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250213212151.1693506-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),