From patchwork Tue Jun 10 14:12:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 154277 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 A44C4468C9; Tue, 10 Jun 2025 16:14:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 72FB642EE0; Tue, 10 Jun 2025 16:14:02 +0200 (CEST) Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by mails.dpdk.org (Postfix) with ESMTP id 03F0E4026D for ; Tue, 10 Jun 2025 16:14:01 +0200 (CEST) Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-4a4323fe8caso38632001cf.2 for ; Tue, 10 Jun 2025 07:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1749564840; x=1750169640; 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=+3vxT434Waw+WMbBv/2GeWAw7DGha2x3sAI8Tb1kcdA=; b=BnXtr1DfOKlLghtu8DnlSohLN1lgkX9P7TV9ODgH0YceJVVRZOaEKz+dZrbSpKISXq TlcIixidYg1WY+wyU4/QZ+JLQMHX6LhnKluHJ/MLiXeMP56go82D6dyBsR9EX56jl0X1 iZ2rQeyxuVg53O1F2fitf/qchkF4vQq+RUzUUzrYkI09T3YNmcldaWOdNf6OLOsQDMcl wGBuf7wNsFOaM/1vwRDGhZPquqy6QuPpl2H+6Cve45mgeX0ffyMz/PA79f9Ng9YNNPfJ eUOA3g911sfI98JE7t4ljgGblLqJcbju5IFG4gb1spIWOSUANJXSgo6ZzMzqEAtjUWbD poIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749564840; x=1750169640; 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=+3vxT434Waw+WMbBv/2GeWAw7DGha2x3sAI8Tb1kcdA=; b=C0ejce8GkTjcm8GD/IRBpmAUgXpxVtcbmDX1s5ixdCsjzErhSCvgl1j+edAQ+FD7mO wiZJq5NuiNbCoQvXsBUYjdd1yAk1xno/UvfcTpQDf0dxugxadZAGLRDa5LNNKYlwaBOp 0XK6nRL+rHnvQPc9YutRTBhpAXFERt/4TbkUlW4H7PHAYLQKyJ89F4bg+46W1YTkurje ieSvW+pZ29xro5WJsofJ1Rzu1nLiU/g/GuMTzgS3/+mKWmq3Zd2MmXxmJomB0Kha9itr AGN5+ueYovcLl76yGiNuf2HL7xh83S8JmVAPPB4CXpfZNxk5uvdwlAqYauNPE3OYDy8s 3zyw== X-Gm-Message-State: AOJu0YxwZuTZg6Rap2QS4lVHNS+RMV8hEbk2Qq/J57l4PwQ+E7UkSVOG Ii+8ggwTiFYzQ2volIfHcodvqnaMHQ2LQRYU9KzFGFvhcbOu5R65Pfc/2EWRfOInqx2YRaHXvkl NmpD7 X-Gm-Gg: ASbGncvfTZqWECyprUfKBZm7nYoEQcMG7btReTscFRJFtADWkGIAjkMRAzLl0fxpJ+k kS28S4OilGgpLU9qBqIIc0wMqB4S1/Jb7owqrwTRsTvPRB7GI3PLrA9ALUX8Qg3DMBhPc5hi/Kb b2ycymM30to+APdWssP3xICQMhgaq/LceCg/cQroy9jez9wip7P5mnIpG2d4VJVX0cSXgmHZT65 aZ1xjMTD7NUNQVc6SKGYcwYV5cUQhD+2f5YVssG13DgyKjty+SzRKDIp+IUN0Pz7zCrfPfcN95I d4wDi4Ez/yZofXhBrBC3dIm4U61I5G3gPFJYoRiqnthVWkMeljhEzMMG2aXe4hM0s2V0xxLGiAh jKc3WAeWwW0e4fMVLFxqO0xtnVoqgenfvaL9+ X-Google-Smtp-Source: AGHT+IEmmhtcam+CZ4AZO7UGJ2jPrvfS1uMlx03xD77+HdhzU1gASnAbS08FtEWZJ/kpmUy5G0tvNg== X-Received: by 2002:a05:620a:2448:b0:7c5:9c12:fc8 with SMTP id af79cd13be357-7d2299b1806mr2341986285a.38.1749564840285; Tue, 10 Jun 2025 07:14:00 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d2669b573asm698525985a.110.2025.06.10.07.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 07:13:59 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v8 1/7] latencystats: handle fractional cycles per ns Date: Tue, 10 Jun 2025 07:12:40 -0700 Message-ID: <20250610141355.91759-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250610141355.91759-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250610141355.91759-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 19a6f580cd..949d3ff42c 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -19,12 +19,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 @@ -91,8 +86,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, @@ -114,8 +108,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); } } @@ -238,9 +231,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 Tue Jun 10 14:12:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 154278 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 44236468C9; Tue, 10 Jun 2025 16:14:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B4CD42EE9; Tue, 10 Jun 2025 16:14:03 +0200 (CEST) Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by mails.dpdk.org (Postfix) with ESMTP id 86FC042EE4 for ; Tue, 10 Jun 2025 16:14:02 +0200 (CEST) Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7d3939ecb7dso216474485a.3 for ; Tue, 10 Jun 2025 07:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1749564842; x=1750169642; 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=WuiemdpcJHhTY3JEEedNwwiaUPelO68Cu85LAtNYwEA=; b=WLGwTXBHAoJr1g1CyxtOSaeHqyVQ/UVgZWyG24Yw3gCQpJpLukcgIFIO8rgw+oskAd Y+vHJaiM7H1lWQfwno5dpa+n5LcFikUVWm+9T6U6BGf1Q41zpZI4U374iVroQHSmzwOc R2HxZtUGL1VLqgYBvJbe4m+2xCxiAY2hXSENXn5s3PQJHaeCx7VZE+JsWoljOiSXCFQt z1nw0Kj5NAKop3vQujjlnepnva0++R1uGGYYbEYkE6iTEUb2kYMS8DbqxImRZTYb62AV SmgogYAteFq3Wl2G0pTIwx1/37MS2dBP8/etC7KUo6rrHWow1fTDP12/aE+MD33rEpym eWsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749564842; x=1750169642; 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=WuiemdpcJHhTY3JEEedNwwiaUPelO68Cu85LAtNYwEA=; b=L6vGzf2MyWBttPfpnw8TN34wkbQt9TtIBaS4valKLhaUNhSdpajQ2ru3oP706EBxhd gSMESbjCc1gDb9A1uSonT/+Ff0gwiWBtisrjy5T1xffDcBCdyL9BonM3Apokr3GEompS 8PSM0URCt7FB2CWTij+roQ4RUpoz5kH/hEIbXP0OwszoEvOxJ1gMaoV65kttyqZ0TBYY lbmqAP0Hlm+OGWTZVezSCDl26hJ1AbRME4jC93VutLhWp6j8EjQNB5GHPtAVbKND9LW7 pF6O9Q5W6Jynxt5aA1o7ZgvaVsbTmHfsY/Tw8kJSIgXDj6JL2KRp8iicJbyklcpj/7CG SAVw== X-Gm-Message-State: AOJu0Yxfi6RIo+ABAGqUDWsyHzV8XaqIy/JxNNsu2ulpwbJU1uvlsHOL J2hCxS2tlh/iDoYOMJjVl9kHgXVFOY3e9nOYcDzPcapjhfzglPED5l756Y9nnNVBGKSXEMNnptb NwoDz X-Gm-Gg: ASbGncvUxV4Fk4N5yP+WuHXyterNAVfD4Ww+BFXm3QsskuGU1MFCAJ8c+dxei/itMTa JkzDNQ5yL3Z0k5uguvoV5xZjAZMJLEgLyqTl3s7m72xZDAj5i9k/ipiZMMQBj/P9keqKF7XsZjE YGZzEgp/DiHUKcLiIuPcbA8kvAvqotTVidY4slAYhhlZRZzCM7ftz3NLo/UktdxVcLanIBD5QDg fjt1PiO205HBxp2uIuF/NRHHeDmBanqH7eGVSajbfLw9C5emJSjreZPD1VXEp2Hmv72jGkF9+Mn 5S5cyt6G4YcGw5RW/ddtQm/PAMm4HyChM1uBOQawV3lOZYSqvz/o8NbEh89wORp7IjpM2FTXFCz QBjY1NPmAN0zX5IdJKUpN8Od5phgpAg6uothj X-Google-Smtp-Source: AGHT+IHP672apIgf+QVuSnZOLCuStQJB3c/5ZYPe+THCeroTi03+4UfwpoZ5rH4z9Zf4g1+oKqIMhg== X-Received: by 2002:a05:620a:20c6:b0:7d0:9f1e:40dc with SMTP id af79cd13be357-7d2299339bdmr2111971685a.56.1749564841805; Tue, 10 Jun 2025 07:14:01 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d2669b573asm698525985a.110.2025.06.10.07.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 07:14:01 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , =?utf-8?q?Morten_Br=C3=B8rup?= , Konstantin Ananyev , Reshma Pattan Subject: [PATCH v8 2/7] latencystats: do not use floating point Date: Tue, 10 Jun 2025 07:12:41 -0700 Message-ID: <20250610141355.91759-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250610141355.91759-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250610141355.91759-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 | 127 ++++++++++++++++------------ 1 file changed, 72 insertions(+), 55 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 949d3ff42c..9345f8c4de 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -42,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 */ }; @@ -62,32 +65,39 @@ 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])) +static void +latencystats_collect(uint64_t values[]) +{ + unsigned int i; + 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)); + } +} + RTE_EXPORT_SYMBOL(rte_latencystats_update) int32_t rte_latencystats_update(void) { - unsigned int i; - float *stats_ptr = NULL; - uint64_t values[NUM_LATENCY_STATS] = {0}; + uint64_t values[NUM_LATENCY_STATS]; int ret; - 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); - } + latencystats_collect(values); ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, latency_stats_index, @@ -99,16 +109,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]; } } @@ -153,15 +163,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(); @@ -172,32 +176,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 Tue Jun 10 14:12:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 154283 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 7D292468C9; Tue, 10 Jun 2025 16:14:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C69F842EF6; Tue, 10 Jun 2025 16:14:15 +0200 (CEST) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by mails.dpdk.org (Postfix) with ESMTP id CDEC842EF4 for ; Tue, 10 Jun 2025 16:14:14 +0200 (CEST) Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7d20f799fe9so505211985a.2 for ; Tue, 10 Jun 2025 07:14:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1749564854; x=1750169654; 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=mfSdz8p+HgLonLtQOEnNakhUn47ksVzeUjsOCiiqQ3E=; b=WmqSu6ONXOmp12p3TGue3RI0dvs9PdOxnds548P09bo0Gi/ItgIvpTcA7QEQ3x8ohG sACS4eGibTMespYWFmFVF+T427qeoZ5lJMSk0gutHxXXRt7pmXq82vg07jAw+Qkv3B/z kzySVsVqnNA73UsuU1jAMp3WX5Pu4CRTIiI2dJDhQjmQr9TqjTV9Ly5090xSfrolFVlf C6Jewj48SLgUp0j9z8EvA1XE9j0CfEJgm2uTGJZBKZM3M40Tyn6yDvb1t084noSXK2zs +4x3fQ1XGjLqogKvho/CJCHa9Vx7Dd52XMLuh5qUNVgQi7yoGACqutF/87PfrFVk2565 Vcxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749564854; x=1750169654; 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=mfSdz8p+HgLonLtQOEnNakhUn47ksVzeUjsOCiiqQ3E=; b=ltd4GiCvPoaOWWk5wIjy1RvVrXVRcMHn9PKAgsxJW4wDg2POLAU9gi4ThxpKjR/5Ws mdQ1l9SRc32AJFhvPoJtLuzZhS6+SiT9oAi8xp7r5+StinkM/HD74kcTgcMo+awd/ng+ Gw/s9NUgvofJVFqkrGfEN5I43EmNZVqHIMufRFmrW/mtD8c8tMoU4YduQfO583Hsbq/g f1dlmS0tvxRhV36K7p2sCAroJyJznJj8hibYs1B4KpIIJ6kuC7DbWneL+/vS8cK6lVMd e9NLVRPbAckYzHzGPeA3rGgbqwVWTwnQcR8rgm856PMoMHj3S5KSgsK1S7eEgbj9ID5o 4iHw== X-Gm-Message-State: AOJu0YwGvkoo37+weE0NqyU5u8NpfR8poLEssQC8pK4Kkh8kvG98yKOX 04idierGbc32/UJMlbUhAUE4HvYYR/DT1oRZ2jqXM7Xa6akXN90iHwB0c8f2N54EAB7lwsg2KhG 5MBmN X-Gm-Gg: ASbGncv264j+gjt3gWJyTKeNwy/kZNDUvXJ3MC481R+PIi1Hnxdv006lTt52RFwn/dt fW0V3TA696lbyqZncN00k9zjxPuaG9fKilXMF6dzHhuN/0Ii2MQvTuoo+jjVEWITUCnLDbcqzIo dRhTE0e34o0VekWlHgH1GX/WFlusov+Tnj4dTJZV2g4VbNMIWCVqsZQ72Ets9VjjhbgQ+TjlAiQ BT9PcQv3IMfY6Upl2w+Nfo1mnbXBwsLsijBeSzoLr5Nnmpmrxff532PLHb+0Ud9qhSTVX5omvDs /EmRFz9uQ3r9nNzHIFzod7fEAD8mpGShWLVorVbzm0xD455Iqn7D+AfzIVi7FpL8Qk13XXg6e7v d6HUHwKpjYTzqDVrRySMNa/6B4X8FA9CM8Lxa X-Google-Smtp-Source: AGHT+IHGhH5cvvdfiN8a2xIOtemRj1ubV7jsKMrKNUk8ATxDWHXwyPJL8XXalELKpMWnmMrKQAstBg== X-Received: by 2002:a05:620a:4484:b0:7d3:914b:abe6 with SMTP id af79cd13be357-7d3a7da9d77mr6060685a.23.1749564843124; Tue, 10 Jun 2025 07:14:03 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d2669b573asm698525985a.110.2025.06.10.07.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 07:14:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , Reshma Pattan Subject: [PATCH v8 3/7] latencystats: fix log messages Date: Tue, 10 Jun 2025 07:12:42 -0700 Message-ID: <20250610141355.91759-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250610141355.91759-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250610141355.91759-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 occur 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 9345f8c4de..50043aea72 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -261,7 +261,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; } @@ -281,8 +281,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; @@ -293,18 +293,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; @@ -326,10 +326,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; } @@ -337,17 +336,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 Tue Jun 10 14:12:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 154279 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 D9A36468C9; Tue, 10 Jun 2025 16:14:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 78CA642EDF; Tue, 10 Jun 2025 16:14:06 +0200 (CEST) Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by mails.dpdk.org (Postfix) with ESMTP id 4FAE84026D for ; Tue, 10 Jun 2025 16:14:05 +0200 (CEST) Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-7d3900f90f6so234838085a.1 for ; Tue, 10 Jun 2025 07:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1749564845; x=1750169645; 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=7477M+uuQljFjffGIN5OLiVcpHnKTTwgy+fR+eFyRc8=; b=r0+phN3MZ++laImKzVKuVK4Z5bUdaKOmbkxJTlLaEcqkYcoTKRvtamk1KSwcwRBR7O FBU8JSQzasZIvWlLkB+53V1a7Ebtn1nbwXFjF+jvVhD9ZyyE9U15KjHEUGXe9YkU2PZJ ausmPrmPyV3ANhelCu9v1EUYbot9kenuZEykeNiTJfwCgNjTSPraty4WX4JJbUtG007/ rBnJiXAFnw0D1lWGZYQSFRXYbd3xKuNohItAgxJcvW0g9dniSER2EWu06e+NqIDXPowg 9HtnRSvvF3V15kkaReoNlGlVwM5W6SW6FvBe/hdGfwlOjmUDOn0QzbiHAvYfmWQogyqa TLTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749564845; x=1750169645; 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=7477M+uuQljFjffGIN5OLiVcpHnKTTwgy+fR+eFyRc8=; b=AMD7TAgrCrImzTZBrTx2mBBH79/V9FcAeWpUO1cOwNOL0Jf6Xncj8wVc+HuKRVxSTd TsLpR5drdYBLpEbB61j86IKBNFhiq8NaQYjW8Y46y+MZtp4/GNcuAdOE6K7zA37jPR8h lnG64hCmH3QOamS/Dxas9h7QTy/uaOgyllwJmlDBv03YPJIsV9DJgYUSUu8iepPQXaKo xHahFJOL0lDJHr7Yrax/6A8WbimAwW9cQHLh8Q5C/sRtcZ/458nBtlRwo9+M5tLDVh8H QdMhToukyOr/NanP9Phil2zEK+4OsB/b0W/0Lfuvk3B5bAqca7J3lXppD8pbbqReSwKx W0Vg== X-Gm-Message-State: AOJu0YwYnMBQu6lbnUMX9AcJfR1xmKhol93Ai/kXlKDB/x+j7Fapp5fK wmBrGQIhHCvi4i8/S9En1wo9GuJinz8zQi0+UtfxPYh9BtHpU2SRApIS5GfTz6dabs3XNy+x2Xx Rv5aP X-Gm-Gg: ASbGncseFwXpAsH2Jq6kgwQDfXsiQoDd1bNWOdNsk9VeFuIf7/421m2AdH55wWmyOxB 8SkId4CwJLjCpId7Iw0/E7JosmZmU4JkmnBcAP0rg6UWN6PeCmzSHuJqhgUbBXqqH82PfXHSTP+ GW7JkKMXkIY/FGCm3TNOJxrr7mpLuLxNhZecxpxRkamfouppkH0EK7mavDhOiO1ZKjFlsXrWVsQ 1dBLe46DpdQdx4P4NRitnZcOMxnNYZIhMcO0IW10X4Ty0UFbhJGGfWaju39SkxnaUkrp33wYBNh AAEyIpc5I2L4+fc6B58ph3rrorgIgOjykPzaaKE7s0X7Wq0eS1BEu6Nsfoc7/RwyywVf23TcX1s a5mvc5bWNN1RgOr6axUPb5qd/PQSCr8y72ev6 X-Google-Smtp-Source: AGHT+IHo5jRbThjg3yTVzG63bIBzDv6M+Z7lHtqA8XFyOPWOcnkpQnpdt8m5wkkvBWJZdMi6ns92tg== X-Received: by 2002:a05:620a:4487:b0:7ce:bd05:83ed with SMTP id af79cd13be357-7d22987d994mr3030148985a.7.1749564844510; Tue, 10 Jun 2025 07:14:04 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d2669b573asm698525985a.110.2025.06.10.07.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 07:14:04 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v8 4/7] latencystats: update include files Date: Tue, 10 Jun 2025 07:12:43 -0700 Message-ID: <20250610141355.91759-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250610141355.91759-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250610141355.91759-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 50043aea72..1e176492f8 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 Tue Jun 10 14:12:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 154280 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 C2772468C9; Tue, 10 Jun 2025 16:14:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 61F8642EF0; Tue, 10 Jun 2025 16:14:07 +0200 (CEST) Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by mails.dpdk.org (Postfix) with ESMTP id 6BBD14026D for ; Tue, 10 Jun 2025 16:14:06 +0200 (CEST) Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-7d0976776dcso514558585a.2 for ; Tue, 10 Jun 2025 07:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1749564846; x=1750169646; 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=gYdCW+suCtSqBCcBxJmbNJAz0F0fXne+txrvYDTVPYo=; b=KVFm3OPgLfBZajg3yFO2ADDE61t5Q0nNfrd+GLqXXx4Egi61JJrnQnEltoiOC9LkEt U8MLQKJXp0KsINTE8sYTRI0djTOJf0NoKl/ld0qS/nc05KcFRidLrrbX0qxJ5Mj4GtDS IbyTLnFjDotpI6hacwi69TPF5UhDqyQAYc3M46eoXuCD0w76pph+NOASxxrin9Yq1q+A vg1auYnhNrc4W7pHw3GJLecqyOJgHxBHsrRwyIdSey/293hlPnl5rYzkxD8HqWBdmAX5 1/atr9mEbKQzu5beQYqiMRGhWRwdME/O06bmg2bOWyFd14ya5E2EP1MSApUNIdhLGGUW vGXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749564846; x=1750169646; 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=gYdCW+suCtSqBCcBxJmbNJAz0F0fXne+txrvYDTVPYo=; b=s2JrZ0teAX9vXkthNcyXXryhU5vJ+xDzQtX3yHHBCCW4PqDCRfxZ7KPyrgb8JTL5np 9a+b9nvKXW9t9Lw7AloaqkBrU3HP/nFWKt/AsqbeXAljsx1w3LQAZOzPRHebioQxi+Uj xrP+EacRZPxzQoIQnPqp67d3rr3iA4/Lwjshw0u+zJxezCn5YJV9YhJMWZc8Pq+fOaBl 2XKJPbV+09GjhW1h/2Yxe4StKK57xWbjNhhGfto8chYBmv9sN58TVooAVDt5EnAitsZc pSjUWKFwVPoVSDoWjMrbsnUlHgazC8n+v9B8kTf6Q39iDvjeqV4JMdIHFUEueYuXa5nu 3Ggg== X-Gm-Message-State: AOJu0YxKpzCqkXiA0XzTMgjsesl1qVQrgH24vHEV6Da2Pt0X86fiUEtd 5UfC2HEZjlVQkd2iHDDWmO2RBDXXkhQl+1q6Lql4BKGG4o5FPYxwBs6FBXJDfr51ow0+PdppMaN GOPVi X-Gm-Gg: ASbGncsiC703xYT9cT6x6ibogimeE+2j4jM8pu5EA0ay4TR+W9Xov0gmS6wrrwH2xkW yM8EkhF2Jv4uRI154PdlB5auVRnnG0yjO3ib+7BiKi06OzID8/NaRGN/wqNSAPj6noX6YlsR9JJ n2ziyw+z43jYCzT7mdX8E1i9RuR8ne2DHh9lVux2FEb6x7iKi6s2C+VBp+FMUg5qv0fPRWtKKih n5BxbQzY846PtHCYhsB74x/WFq7CT7QN+/E5v7X1rJkU5N9qURT5VGnB23kOxdXMRooLh39uFNZ N5qfjjDqSkvb3bEdYPB0ZF3VegGm/iLgp2Dv/+457qFuVL9OGpiN4yJk0QjxaIzxzIOuMqrKItg UgJPkEohruPaN02Y81ZDvubRJgzhN5ckkxjuk X-Google-Smtp-Source: AGHT+IGX7bg6zwmw9pi66B5ALveCy2U3oAcBVgIihg3aM4VhsjUO6nGjuKpevTpApcZi8CwIkB74Dw== X-Received: by 2002:a05:620a:454e:b0:7d3:9108:2f55 with SMTP id af79cd13be357-7d3910831e4mr1316321585a.50.1749564845769; Tue, 10 Jun 2025 07:14:05 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d2669b573asm698525985a.110.2025.06.10.07.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 07:14:05 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v8 5/7] latencystats: enforce that unused callback function is NULL Date: Tue, 10 Jun 2025 07:12:44 -0700 Message-ID: <20250610141355.91759-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250610141355.91759-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250610141355.91759-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 1e176492f8..46f1819082 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__) @@ -248,6 +248,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); @@ -300,7 +304,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", @@ -309,7 +313,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 Tue Jun 10 14:12:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 154281 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 780F5468C9; Tue, 10 Jun 2025 16:14:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AFBA542EFD; Tue, 10 Jun 2025 16:14:08 +0200 (CEST) Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by mails.dpdk.org (Postfix) with ESMTP id CA5FD42EF3 for ; Tue, 10 Jun 2025 16:14:07 +0200 (CEST) Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7cad6a4fae4so893340685a.2 for ; Tue, 10 Jun 2025 07:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1749564847; x=1750169647; 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=dMr9isvz6q1VYcjzv4VwRtHeYAyBVJBFryxaEs3/M8I=; b=ybRgiAdBeScFQ3C3xw7pXX9bWjK+jT2T+xci/qvfr3HslM3MNZNvqiUa0AMWF+aTOU hywvzYEx7p/qbU04/v2pfJTZyqzhJ/5wrG2TdGHWbhKO5J7JlUhjimcmR1DCwJulRj5m 37Mfs9g0YeBTd09tIglygvZytyjbNo1cBd871JPaPj3UbfZEgeYXb4KucMtNM6eglyVE abgr+pfIuerWM9TEHYM3OHhwiGIGLQdaF7pn31aDkbMQhLR3vTUCULU9QjtAuXt1RWNV aGGe3VWn8JmJDG5KYAJmCRA2aE8wh2yFROk0ZPISb1eiety07TCgaQ8oEsXKSn8PkuSs vY2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749564847; x=1750169647; 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=dMr9isvz6q1VYcjzv4VwRtHeYAyBVJBFryxaEs3/M8I=; b=tvq5YrwFpaQrQEYmFP0OCztORekqB8etXOZ8os4Z6KWdrnZd12dgEjZr2KpRuRmsCZ XnYyy6SO+3CVaFuk9c4qhPItI0b7C6MAfCjY7iWnKAi0X66Hnp18c+fT7CyRZTHZIKbH vt5ER8QfF9/SEIUF68cuLTk3+HvJbFNWwlAt//OQfE5K18rure6RLxfz1oWrOdXZ5JrI Ud0SQPoD8wI3aeDMEIq6O7bUSXz3sehnUACZvKpO81iYUVfxC2dSMLXl9GsUzyXDBO1c yrVx2G0hxIezpeGwP5USbhKhpKSI+7ze9nCG6+bO3GX1urAtQ26xlxYWEhpQowq4vavE aDBQ== X-Gm-Message-State: AOJu0YwXSmtltilaANUNIOTd1JmlYTK39DpOup20n+62Z5BoiR7xMCAr 9ecf8Qk3LyeKLzSWuiZTLXYgitDY9GXho3JThcwI02zlAB85AEpz2SVQDbLOue6AqY+cvlffT07 8+VzS X-Gm-Gg: ASbGnct/0Q8pikdXZoGr4DsKSeWeEDT4FKQPCdiwD6cxDwSoKzQdo92KzG3v43E076S F+1WAoQnDq7TgzFDeB0J5nmXi0cI2nWXAMMcUzpxSlH9MOxMzi03tzgMiED6opD71f3GMKdEe/z KY22SiALPsB6x5+cAfK/BFQ+YHLkhI6admzwW5ErMBVW/yAG2HLvsoHsmd70HVl/ZZ00GSxHY+c CqC+7hdN043PC6LjMRlL25gUPfhAjJfjjEv1vUTjf0XuPuoXtAJPrSwzKA4VH1r+AbqJ0uqCTUq MV+4duv8MxKfDlPM4Zgd0x+9NQ+b5/jMe8ZijtcXus5HWFYXkmGDge5UDF0eXXpfLIkR9vi+FZ7 YRF5xx9YKNyb0xkGU4HsE41pydN32QrzqR/M0 X-Google-Smtp-Source: AGHT+IFmyG0ZUQQeZKki3hB1YldPcBqt7dPDslFfKr+WQf6vnOaDuXQgzLc5fgZ6pac24Gjquuj08g== X-Received: by 2002:a05:620a:2894:b0:7d0:9909:ebe9 with SMTP id af79cd13be357-7d22987fdf0mr2454638985a.20.1749564846958; Tue, 10 Jun 2025 07:14:06 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d2669b573asm698525985a.110.2025.06.10.07.14.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 07:14:06 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v8 6/7] latencystats: add metric for number of samples Date: Tue, 10 Jun 2025 07:12:45 -0700 Message-ID: <20250610141355.91759-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250610141355.91759-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250610141355.91759-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 46f1819082..6873a44a92 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)); } } @@ -174,7 +181,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(); @@ -185,9 +191,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 Tue Jun 10 14:12:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 154282 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 16328468C9; Tue, 10 Jun 2025 16:14:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B478C42EFA; Tue, 10 Jun 2025 16:14:11 +0200 (CEST) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by mails.dpdk.org (Postfix) with ESMTP id D8D0B42EFF for ; Tue, 10 Jun 2025 16:14:08 +0200 (CEST) Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7d38d1eae03so226137985a.2 for ; Tue, 10 Jun 2025 07:14:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1749564848; x=1750169648; 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=shRdOqW6NSFFVg5XgaT3vwPO+Mo8Xi9jvhl1EdqSSdytMCQYDYWt5DGutF5F20LW7q YvW/Vl3Y9IFW38eJD6L4DfG1smcg0uzcfYGPvAVhCkhMMKbiDOt1PxBtd1WHCF1wHU5L +QNy+SlD/NJgHYommOXNidrLPzDy+jXximfSoSBbA5kPrndbsrs/G3sTSaVzYdeclcp1 EIiGHDP1BuJ0nigFjt/3jbwVud+dCozYmLkJFOCSIe495gA/lgTV3fZuGhkKv6ROZZ5c 8dBIrf+ibgo3W8Up3oQLCDh3w5blI3UXS3cgUe80UcW9btZbp9thEi4sQujZ0XB3QHLD SWgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749564848; x=1750169648; 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=h1NXKsq8wVUwT6/2gDVe3KJ0UjLWu59yx9eMTrap5pH5MkRg3bJ64/PBWTZf8uNJSW xOHMIxqhweVLrHyaTL2cAHVbKZYTqZ0Hew3odbWSzCqwvGbHhA+bpYJtpg+uc43X6+kX pqsDx3LozB4G4vzmt+b0pmbf7vveweoTWAqyQIsaDDgne33YVtW8WwqZocS/Z1EAWzu8 wb3u6xhbeDIn89HOjPl3/HxH9g7GjaCQQIZTW56jn3kicPWnxuvdGXLjrO1r74XGeyKj 8D+cYoesTa+2YMkPTtoIWf2vy8vnK0K547VmU0112o8XfvNZdmVYPddnWL2Vvd5fOJvk bIww== X-Gm-Message-State: AOJu0YzxMtIkTK1h6ndGafRmOkbNnYY64i4VKk5GCrxK8A76xqPrk72J jKlVcLU/zeRocemfgr54TwZ0A5MZjZk6+7Cmh3l7GQpJVrw31XLoz/HyY0mgxqo7y3kJTsj34rx 7KLXu X-Gm-Gg: ASbGnctGY8g76ZSwoAP0EPrTwEo86btvQ5lAa0Ri1Ei3Ndnbtk+MhyG/RSwhvWKzWcW gYqtiGNFBK3oNKqY3NTGEQhUD9CcYPntAgw0edsuZb8JcacqmeDbrJKFOt1SqDmEPl/nGTy7U8v eaFq05bqAVx44IYm4ugO5XVb62aOgitOwsZeDujkbuDaBBWrVlStEafgjxtu9Wr8fRk91Mr03uE qM9oxLk+2lGtQpsPP7KEMeaJE0Xosflye270AMNvXiYcWk6Hqr5i6Hnt1NKo9DK9wzuWaHORYeK ugi6nOefgIyCiB12G2k9YyhuI5UusJykKbez6HuJfU/dLLPennpGOF18E7s+K5BePTZ8toqRTQk +FGTEjOMSdjQXk76MAnqeug5ebSsVTuafZWOZ X-Google-Smtp-Source: AGHT+IF9Rs6R/5PpicjY2v926aoffoxeqIf7UOg6JL6yDXEb7QjL5nXBjNggD4KElwVMcZn8263Iyg== X-Received: by 2002:a05:620a:4487:b0:7ce:bd05:83ed with SMTP id af79cd13be357-7d22987d994mr3030179385a.7.1749564848205; Tue, 10 Jun 2025 07:14:08 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d2669b573asm698525985a.110.2025.06.10.07.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 07:14:07 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v8 7/7] test: update to latencystats tests Date: Tue, 10 Jun 2025 07:12:46 -0700 Message-ID: <20250610141355.91759-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250610141355.91759-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20250610141355.91759-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),