From patchwork Fri Apr 19 17:28:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139547 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 B4D0443EB2; Fri, 19 Apr 2024 19:29:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C7193406B4; Fri, 19 Apr 2024 19:29:40 +0200 (CEST) Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) by mails.dpdk.org (Postfix) with ESMTP id 7023740689 for ; Fri, 19 Apr 2024 19:29:38 +0200 (CEST) Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5ad21f3e5dcso397363eaf.3 for ; Fri, 19 Apr 2024 10:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713547777; x=1714152577; 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=1iMXXGjOoTwNd9pOuzO/FsZahJFsBN6I19d6MX2wr/Q=; b=d19Og84AG4Zines8JX1JFDLRMDNe8v9d9q8gVJgvfzNJtcgTytesvQu17Fm+DrCmM8 R2hcsgv/Gi/NH/LRd+KmVLxhpBs2mfSB2Cwk79iGQDXtHX6IbEZHhAbQF6WC9KcQNLd5 U0FUibA4x54us6cWyoe7iJqs4orXrtXY4hbW8Lb3Z5APyv/GDx81DndIEr4t5lO6itA/ ZWYlh1MpKXFogAMfxHyQUhJ8QAZMgfX1ybMDvkHnY0bJBE/FpKwRrDIfajb2tYyv/Evi O+/plt3AHfqwhPCKyN+o0wpFwDLIBu7WicgbAdAjlpvASDyexPTEgZVxqA8zc2T2MCkk JTFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713547777; x=1714152577; 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=1iMXXGjOoTwNd9pOuzO/FsZahJFsBN6I19d6MX2wr/Q=; b=naoY8ajd7xPHuBsB54+5lvjz6dxoMfKjEk4Ug9H5Mp5F0h8nDvWsvN4Gar6BiX/FRS 7Rf7VXYYAEEusK0H1W8lM++aKvwumVbLMKIbxUHFO5XpMuGuHmEIHrUM4pNDGyQdHiWB X6zvmVMQk05KYUpN0dnn/Nm/vrnpJHcPZM7eHzwXppwjSFTJfMFuzYi3dP1Z8Lk0BB5z IDpiNHRhnLU0DSMhgzAZdnapJumzoFVvG5DnFoQ5liPW/3JTHkgj4DaqT67RbySkvnrv WqU3Dr2lTf4z6sx98S6n+PHMmC5OBPyEtUw8+VPTymifb1ZlHw78hyGn+9JNVHpLDAEP gDfA== X-Gm-Message-State: AOJu0YyThPeSaFBsUG8KZ7/unfnEGdOAF6VRgPoo9LLjfnD15mwN/Q58 kBlz5rrgRDJUMx4OTa663Ak/5k2Y86hPITBjWg2VnlgpqtdOii/6WdFTiN9L6KgCINpMOonD7SO 8 X-Google-Smtp-Source: AGHT+IFVteU+QkJvgt5Rl+XaOJb89OaONKtlhOBBbEY3wHeByCLpxRVo26NbTX6dcecBG+WrhmQEEw== X-Received: by 2002:a05:6870:e99:b0:222:1353:ad0f with SMTP id mm25-20020a0568700e9900b002221353ad0fmr3408676oab.24.1713547777603; Fri, 19 Apr 2024 10:29:37 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id h16-20020a632110000000b005f3c5cf33b5sm3383074pgh.37.2024.04.19.10.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:29:37 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?utf-8?q?Morten_Br?= =?utf-8?q?=C3=B8rup?= , Tyler Retzlaff , Reshma Pattan Subject: [PATCH v4 1/6] latencystats: replace use of VLA Date: Fri, 19 Apr 2024 10:28:21 -0700 Message-ID: <20240419172926.55447-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240419172926.55447-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240419172926.55447-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The temporary array latencystats is not needed if the algorithm is converted into one pass. Signed-off-by: Stephen Hemminger Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- lib/latencystats/rte_latencystats.c | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 4ea9b0d75b..9b345bfb33 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -157,9 +157,9 @@ calc_latency(uint16_t pid __rte_unused, uint16_t nb_pkts, void *_ __rte_unused) { - unsigned int i, cnt = 0; + unsigned int i; uint64_t now; - float latency[nb_pkts]; + float latency; static float prev_latency; /* * Alpha represents degree of weighting decrease in EWMA, @@ -169,13 +169,14 @@ calc_latency(uint16_t pid __rte_unused, const float alpha = 0.2; now = rte_rdtsc(); - for (i = 0; i < nb_pkts; i++) { - if (pkts[i]->ol_flags & timestamp_dynflag) - latency[cnt++] = now - *timestamp_dynfield(pkts[i]); - } rte_spinlock_lock(&glob_stats->lock); - for (i = 0; i < cnt; i++) { + for (i = 0; i < nb_pkts; i++) { + if (!(pkts[i]->ol_flags & timestamp_dynflag)) + continue; + + latency = now - *timestamp_dynfield(pkts[i]); + /* * The jitter is calculated as statistical mean of interpacket * delay variation. The "jitter estimate" is computed by taking @@ -187,22 +188,22 @@ calc_latency(uint16_t pid __rte_unused, * Reference: Calculated as per RFC 5481, sec 4.1, * RFC 3393 sec 4.5, RFC 1889 sec. */ - glob_stats->jitter += (fabsf(prev_latency - latency[i]) + glob_stats->jitter += (fabsf(prev_latency - latency) - glob_stats->jitter)/16; if (glob_stats->min_latency == 0) - glob_stats->min_latency = latency[i]; - else if (latency[i] < glob_stats->min_latency) - glob_stats->min_latency = latency[i]; - else if (latency[i] > glob_stats->max_latency) - glob_stats->max_latency = latency[i]; + glob_stats->min_latency = latency; + else if (latency < glob_stats->min_latency) + glob_stats->min_latency = latency; + else if (latency > glob_stats->max_latency) + glob_stats->max_latency = latency; /* * The average latency is measured using exponential moving * average, i.e. using EWMA * https://en.wikipedia.org/wiki/Moving_average */ glob_stats->avg_latency += - alpha * (latency[i] - glob_stats->avg_latency); - prev_latency = latency[i]; + alpha * (latency - glob_stats->avg_latency); + prev_latency = latency; } rte_spinlock_unlock(&glob_stats->lock); From patchwork Fri Apr 19 17:28:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139548 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 89B0043EB2; Fri, 19 Apr 2024 19:29:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BE1340691; Fri, 19 Apr 2024 19:29:42 +0200 (CEST) Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by mails.dpdk.org (Postfix) with ESMTP id 09DF340698 for ; Fri, 19 Apr 2024 19:29:39 +0200 (CEST) Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6eb93ec8804so1281766a34.2 for ; Fri, 19 Apr 2024 10:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713547778; x=1714152578; 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=sSasOgCHLIZFkxb9gF3dyAkJenIQv2QQ2b/rkOQt9Ps=; b=hsaRTQ3qE6Qrw2DTsG0L3/QPDztEncXNrRBCpsUGsIZbPBh056mm48O6H6mkSq8pBf AABrPm1zdbHGR2k0Zg6Dsv9QLsJmNVdkzVG/bTc5Dy6SCHUXTarMkyM+j+LuuxZnvh8G KmkJds/qUq0rlA9nHcjNK7JgCDYiGpOgmxMDJ8mi72gRlCKLyiIM9bjj6rMfWcAPADgd +pF7YwyXFpIdejtj8KcCKNyfV4mM66Al+gUdIIf6vtds3Gv6+7OGwSqLgxwF3x6DponB BLz9j9eeXo9DCyXO8Qxy4tKLi1xl+gcRs3C8QWSiKNdEWe4X3REIdI37FjT3uPjjsH8L d/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713547778; x=1714152578; 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=sSasOgCHLIZFkxb9gF3dyAkJenIQv2QQ2b/rkOQt9Ps=; b=kcOA8jfE92SpuoSVKRzJFe38NrUCrfzFg22p18z/DYAOeo10hbe1hvMzoZFrYOJkNc UwY1lHkNqpa8+swhcthhUTc3O1AkH1uSwpL6on6264cMnBf5GHJLWzCzFwt3iWFUOK7l 79Tw9Lu/4bDjoL7/RVFDAYjjhFWXh1hnQ3bl1ZrcBnNJGgPloAcvqc3owdhu/lSsO+T+ mPHDvTAMapP7JOq7qHpULD4jLILvNksaPfFuh3w3HDNHtBed6BIDAYx6/bTEXG0qku8d hepPRGBROBh9yQahNXZH1gnCiTFf4K3QE1mUmQFtUrvdY6KzCXhNojBoRb1j7REDSr4k BTyg== X-Gm-Message-State: AOJu0YwpnM/13vhjr/8ew7yPcO4aJI7+hfJJZVX92/wh9TBuZbHcwjbh /w3AcRaDDly6Zc6LH9NW0qBWcXA6qBt8Vuytj6CNRjX7EsHVY/PtQoowhiFXODvl9ZeKuAiZqLE F X-Google-Smtp-Source: AGHT+IGtHOAQZYIiYfqUzlefXLi1zgDTLT1yoI9ksZj6r87jKr41RkHfyjPV1w8aEglh7Eg/R19U3g== X-Received: by 2002:a05:6830:1208:b0:6eb:8435:60 with SMTP id r8-20020a056830120800b006eb84350060mr3374751otp.24.1713547778380; Fri, 19 Apr 2024 10:29:38 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id h16-20020a632110000000b005f3c5cf33b5sm3383074pgh.37.2024.04.19.10.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:29:38 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v4 2/6] latencystats: handle fractional cycles per ns Date: Fri, 19 Apr 2024 10:28:22 -0700 Message-ID: <20240419172926.55447-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240419172926.55447-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240419172926.55447-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 timer_hz 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 9b345bfb33..55a099c818 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_timer_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 Fri Apr 19 17:28:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139549 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 5276343EB2; Fri, 19 Apr 2024 19:29:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DFF8940A4B; Fri, 19 Apr 2024 19:29:43 +0200 (CEST) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id 509B04069F for ; Fri, 19 Apr 2024 19:29:40 +0200 (CEST) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6ecff9df447so2180758b3a.1 for ; Fri, 19 Apr 2024 10:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713547779; x=1714152579; 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=Kg2PCbwdtTsUQ6vMQSsIrhsnoQGMw7xVpkX+ByYWDrw=; b=gioeYdirxpikaShqd9mabqA16Ke2yHVq6jEsTDWC3j+6m+ibHdA08zMXUJI8klwMk4 zPZO+93lAK0mXyHRgomJdzyUo4jWyzwQTnPS8vo1yhQG/wDCakcepYnx8Z89EnOlDHp+ e2+oCFWbuXW2NMRA8Alodsz/7G8WjAw8D96NuhIWvm8wMG5LERkXEyLE47eXiewNy9tr EHYmHcehaagpCPPA2UicSjZxAtc3gvT61tTaHzzjm0JzfuLxeZqyiOUTpI9jtIqmyrI7 Cn9ZOYaPwyG6c6XAgxLXaOsFrkYbKZDeF/xrCnaFqfVx78FUFIjCItbCqe/8vwtsA/hJ VaJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713547779; x=1714152579; 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=Kg2PCbwdtTsUQ6vMQSsIrhsnoQGMw7xVpkX+ByYWDrw=; b=CaBs3NqmHjmcHMS3yVAtEDsWX8VVP0nSdeWLtzUfDaStcwSJtjPxRyQRg2RkC4p4AL MwUXTr2M+6y3k6ARyjQPsesmEbG6fiMjx9R1ER2j8LCdDK9g2KzENR27weGssjqGmRy4 InvzMtQ4QPhIxO4La91TaofEc6A6Gu0kflssgkISBoFfb/xm7acPv1BAKsY/jn6BbNdy f2SlN6gB2uyDsF0DwgbEPsUzYhze4i5S4B4akShKIuZ4tRcKKDMdUm5tK4wNTwyc12oE 5BLTwZGoc4X5rEueKdqERaCsTjvevf6n7uj1YCMx+crHKbSbXTcgFZrxGX7mEpHRzivO +M1Q== X-Gm-Message-State: AOJu0YzAn3SXY5F2Alj6J39SMbcV6yspDQZj0ksepKX8FafWA5+BLuU0 UeXvOiUplDoka0am1TrzMjD2Xg3A2S90EAD0Y56LVmiMp4aXDpMuyrqXsQklLniUr9itMoQqsrI p X-Google-Smtp-Source: AGHT+IHyf3vv+6yljEk7tl7msex6FdqSWnhGbtBjFk6GAHQCVUatqlNuZ4SdPWKXMnD4yhOr012Dvg== X-Received: by 2002:a05:6a21:1a9:b0:1a7:91b0:4f14 with SMTP id le41-20020a056a2101a900b001a791b04f14mr3488847pzb.23.1713547779242; Fri, 19 Apr 2024 10:29:39 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id h16-20020a632110000000b005f3c5cf33b5sm3383074pgh.37.2024.04.19.10.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:29:38 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , Reshma Pattan Subject: [PATCH v4 3/6] latencystats: do not use floating point Date: Fri, 19 Apr 2024 10:28:23 -0700 Message-ID: <20240419172926.55447-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240419172926.55447-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240419172926.55447-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. Change Exponential Weighted Moving Average weight from .2 to .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: Morten Brørup --- lib/latencystats/rte_latencystats.c | 88 +++++++++++++++-------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 55a099c818..6ef8e344bf 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -42,10 +43,10 @@ static uint64_t timer_tsc; static uint64_t prev_tsc; 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 */ }; @@ -77,13 +78,12 @@ int32_t rte_latencystats_update(void) { unsigned int i; - float *stats_ptr = NULL; uint64_t values[NUM_LATENCY_STATS] = {0}; int ret; for (i = 0; i < NUM_LATENCY_STATS; i++) { - stats_ptr = RTE_PTR_ADD(glob_stats, - lat_stats_strings[i].offset); + const uint64_t *stats_ptr + = RTE_PTR_ADD(glob_stats, lat_stats_strings[i].offset); values[i] = floor(*stats_ptr / cycles_per_ns); } @@ -100,11 +100,10 @@ static void rte_latencystats_fill_values(struct rte_metric_value *values) { unsigned int i; - float *stats_ptr = NULL; for (i = 0; i < NUM_LATENCY_STATS; i++) { - stats_ptr = RTE_PTR_ADD(glob_stats, - lat_stats_strings[i].offset); + const uint64_t *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); } @@ -151,15 +150,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.2; + uint64_t now, latency; + static uint64_t prev_latency; + static bool first_sample = true; now = rte_rdtsc(); @@ -170,32 +163,41 @@ calc_latency(uint16_t pid __rte_unused, latency = now - *timestamp_dynfield(pkts[i]); - /* - * The jitter is calculated as statistical mean of interpacket - * delay variation. The "jitter estimate" is computed by taking - * the absolute values of the ipdv sequence and applying an - * exponential filter with parameter 1/16 to generate the - * estimate. i.e J=J+(|D(i-1,i)|-J)/16. Where J is jitter, - * D(i-1,i) is difference in latency of two consecutive packets - * i-1 and i. - * Reference: Calculated as per RFC 5481, sec 4.1, - * RFC 3393 sec 4.5, RFC 1889 sec. - */ - glob_stats->jitter += (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; + glob_stats->jitter = latency / 2; + } else { + /* + * The jitter is calculated as statistical mean of interpacket + * delay variation. The "jitter estimate" is computed by taking + * the absolute values of the ipdv sequence and applying an + * exponential filter with parameter 1/16 to generate the + * estimate. i.e J=J+(|D(i-1,i)|-J)/16. Where J is jitter, + * D(i-1,i) is difference in latency of two consecutive packets + * i-1 and i. + * Reference: Calculated as per RFC 5481, sec 4.1, + * RFC 3393 sec 4.5, RFC 1889 sec. + */ + glob_stats->jitter += ((prev_latency - latency) + - glob_stats->jitter) / 16; + if (latency < glob_stats->min_latency) + glob_stats->min_latency = latency; + if (latency > glob_stats->max_latency) + glob_stats->max_latency = latency; + /* + * The average latency is measured using exponential moving + * average, i.e. using EWMA + * https://en.wikipedia.org/wiki/Moving_average + * + * Alpha is .25 + */ + glob_stats->avg_latency += (latency - glob_stats->avg_latency) / 4; + } + prev_latency = latency; } rte_spinlock_unlock(&glob_stats->lock); From patchwork Fri Apr 19 17:28:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139550 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 16EC243EB2; Fri, 19 Apr 2024 19:30:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B00A40A77; Fri, 19 Apr 2024 19:29:46 +0200 (CEST) Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) by mails.dpdk.org (Postfix) with ESMTP id B1C7040698 for ; Fri, 19 Apr 2024 19:29:40 +0200 (CEST) Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-22efc6b8dc5so1397477fac.0 for ; Fri, 19 Apr 2024 10:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713547780; x=1714152580; 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=rD+AnQQVFckf+DeZeU85+tMHpx0KOMG8lHuLZS0zp18=; b=BlfLk3hChM9rrHVPdO5Kz+/lQq6ZsRmmX+f2/4TRlvDIG7PZdQMgfCC4hKAcU/WIx7 n4ar+MJogghphKHCO2tq0SDcDbalbomQJ/YhRZ/HBqoq7bCgYq2BQ58ZEAGhM/xBfqTv zvQTedlF68YRGw9VgIJWGOQk6wXwoawHPGmADcP+jF4CZWXHpAUxcK9srQyp/Md6D8F/ fMwbt6zPwbRAObKRr+va6hWvyni1ew2AebgeagutNvLtxIdjf2Hlwcl7Hh/oFqaikwgD NxXMRBgIWpERtvX2VTMrdCv6qZl3+tDjXPjt/7r9q1clMLZfoLDoUNsn+oQf4NPTxCua 3APw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713547780; x=1714152580; 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=rD+AnQQVFckf+DeZeU85+tMHpx0KOMG8lHuLZS0zp18=; b=Cu8b7x/P6lYYQTFGFdZ0TWd1FBpjiAB3WDsLTKVB14MrhNcg0PQdI0wbCbVcxgvYeU q2WF2H5UoBVWIYTPmSie8nCvUEmqw+96yidUYD+a7P/6Bc24QlsliX1/FHCC3Sth2CpI KRDQezNSFWdCg99m01fUTfm973nRUNuFvkEDH4QvDLSOnwAOpBtpkjgwZEfhQ+BA8MA1 7XwBy918Yr95Wr6W/xFeR6Fj7G5eH0YqrXjHDq3HX21vd8Wgw8YY7LzJ+M9cggWQwwMX Xb000ZBFn6r9+/p8t33XB+sgYlzKjR/ELVo6rptJzjTwz5+HY1DPh/iuAP+IJMHxIlpd k9Ug== X-Gm-Message-State: AOJu0YzbrFoxe1nVXTjRAyTzh/km8oCN3iguTfVd+dd/bqvKqJr0Xu8R Yv8f7G1iVQLGBI5DO7Dw+HohVH3jc2FVEFHk2E+xmsXu9e9y9dcle6P8YVzGJvEy4c+abFNa248 v X-Google-Smtp-Source: AGHT+IFOslDQAeGOPkjtK9uBhxb5SIhGCbJpL0acvBvju7AqPt1g2fiuRV6G3yq1Xg101k6KCDD1tQ== X-Received: by 2002:a05:6870:231a:b0:220:8bd2:cd09 with SMTP id w26-20020a056870231a00b002208bd2cd09mr3087473oao.32.1713547780054; Fri, 19 Apr 2024 10:29:40 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id h16-20020a632110000000b005f3c5cf33b5sm3383074pgh.37.2024.04.19.10.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:29:39 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff , Reshma Pattan Subject: [PATCH v4 4/6] latencystats: fix log messages Date: Fri, 19 Apr 2024 10:28:24 -0700 Message-ID: <20240419172926.55447-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240419172926.55447-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240419172926.55447-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. Signed-off-by: Stephen Hemminger Acked-by: Tyler Retzlaff --- lib/latencystats/rte_latencystats.c | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 6ef8e344bf..8aff96a449 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -243,7 +243,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; } @@ -263,7 +263,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, ret = rte_eth_dev_info_get(pid, &dev_info); if (ret != 0) { - LATENCY_STATS_LOG(INFO, + LATENCY_STATS_LOG(NOTICE, "Error during getting device (port %u) info: %s", pid, strerror(-ret)); @@ -275,18 +275,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; @@ -307,7 +307,7 @@ rte_latencystats_uninit(void) ret = rte_eth_dev_info_get(pid, &dev_info); if (ret != 0) { - LATENCY_STATS_LOG(INFO, + LATENCY_STATS_LOG(NOTICE, "Error during getting device (port %u) info: %s", pid, strerror(-ret)); @@ -318,17 +318,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 Fri Apr 19 17:28:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139551 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 D2A1243EB2; Fri, 19 Apr 2024 19:30:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D948440A7F; Fri, 19 Apr 2024 19:29:47 +0200 (CEST) Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by mails.dpdk.org (Postfix) with ESMTP id 77641406B8 for ; Fri, 19 Apr 2024 19:29:41 +0200 (CEST) Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-36a0d09e6ffso9783255ab.0 for ; Fri, 19 Apr 2024 10:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713547781; x=1714152581; 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=XrOjJKmlEYwv4J5ARAAGCWNRW3ihtndAXEJ5NIAUJF0=; b=jJOcJLxXdIYKoZyNw65OeT8vcrBiJKpllYtQmfAaxCVmsuqokILkHm/fhsGWfUqFw5 PLv8WE7WIP3UjrCOIUagkxwMai4BMqGQxsXf7ThVv2+ivcUvNOewemtR9xrcZDgHQjss eSXbpwRbhXtQnR2EJbOZaPpp4Hkf8scJMeQVIJdSoeaQptfctE/Q8IUZ40ApbjdUkHzF 0A6srfJzIMY2szR6FJ9YnnnQBFB5ay7nX09pSKRDqI//MD8K3s0JFSjVKVHu00WNAHDQ WO8QzRgUOrYjbA6wBhxJcj+wup48uQ3dEN1Mt9MR30oIn824Qio5b/HyEn4vu5fFWkhF fmRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713547781; x=1714152581; 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=XrOjJKmlEYwv4J5ARAAGCWNRW3ihtndAXEJ5NIAUJF0=; b=gJPhOIJzEqP+qFWF6eUHDNe+a1AsAuG//d/dv/L+Sfp+nH+4ZbMDUxu6G1s2w3L5E4 A0DJa2CEmjdrNuLKYdD59l5+QA/778zLY2UbES3XOL8/y/qjz4JTeYGo7S8p5DVtMAOm dy+Pi7g19CStek1sR/dzzGLzCOhBejINebk0FRUPfRDBSJ5LcymtzTxoL7vb10Ft/MVn rrG5oyeccfC0yMapTS9pLKSTTIUjALVk/w4OccpfKKWxRkBiYjCQIKxfWYgrTh5SiDEK G4U9ITLIX4Yt9QizGQDXgTB8zcB7nqlQX8EpZDnfiMwlGvrwMiFuYI7Hi8TybQzBg+EF pAEw== X-Gm-Message-State: AOJu0YwtYaEs8CNfw+vNv8TiQtLmZHnamEEXsAeZ2qes3+G5Q1WlW48P 2ZYaUud0rxAFiGG2ITQkYgNno6E380wM7A57tK7BW4Y1415Tno5n1gMMbulTfko9HiQGPJW0fyx h X-Google-Smtp-Source: AGHT+IHErq2K9hM1oRYGHShJQNvjXACLJgtuRsfEG4S2wJcBiKnXHzg5tmEHCQSXr3oZPSM/t6x4/w== X-Received: by 2002:a92:ca46:0:b0:36b:3bca:a9a3 with SMTP id q6-20020a92ca46000000b0036b3bcaa9a3mr3245452ilo.19.1713547780785; Fri, 19 Apr 2024 10:29:40 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id h16-20020a632110000000b005f3c5cf33b5sm3383074pgh.37.2024.04.19.10.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:29:40 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v4 5/6] latencystats: update include files Date: Fri, 19 Apr 2024 10:28:25 -0700 Message-ID: <20240419172926.55447-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240419172926.55447-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240419172926.55447-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 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 8aff96a449..5db896ac7b 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -2,17 +2,25 @@ * Copyright(c) 2018 Intel Corporation */ +#include #include +#include +#include +#include #include -#include -#include -#include #include +#include +#include #include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include #include "rte_latencystats.h" From patchwork Fri Apr 19 17:28:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139552 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 BFD5F43EB2; Fri, 19 Apr 2024 19:30:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A02CB40A80; Fri, 19 Apr 2024 19:29:49 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id 8A303406FF for ; Fri, 19 Apr 2024 19:29:42 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6eddff25e4eso1949413b3a.3 for ; Fri, 19 Apr 2024 10:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713547782; x=1714152582; 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=muSGKLb11y4nDDcZMd/T5iJvMOH0Me1KjJrkvR0Bvuk=; b=BqAfy1Ugz+XnmQgpit/Y19ckl0VP8DGcx53ZXmWJ7hzYIP+fXFc1LU9pNCB59scM6I gwKyuILQQWDaf0U020sDG9BTYgelnDnXGVg/PW3Lzot0x8oM55aYzIFPjIJUlSTwVleC dgX1xnA8ga4cyJbYfoW4wHcFApWOvQMGezj+PL218JpESRtb10BoYwDcp8JivspzjNxm PKKMFLKqotD4Ppoy4T6zgXe4jFWgIP8F1qasTskS/8ytoXoxHVv8HCS06bSgYFU6eKPg 7pZvC+sRZBP/UIP3Q9x1HzjwSPF34M5TW90eWBIeZzw5XLBsI+K/aPucAwwZ78WhoSX4 we8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713547782; x=1714152582; 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=muSGKLb11y4nDDcZMd/T5iJvMOH0Me1KjJrkvR0Bvuk=; b=P/3Y1j0BAAtK5EvQy+8HWq7l+Dn5tgjuA3IMz+beoTWk7dbfcy1mAjCBxQLHDpOqkv k3+OVL20MBJzOPiQDRk/J0XVc+iwGC8yp0Qlp9Jp142pH9XxDFvychW3HNdJ5DusI8j6 IA6PY+aJ7t7wNBdD4DeASCJAcxZ8Rn10aObwyQ8oeiX8z3TMilFo2Xc/JPfKQRI/s9Tv IjPJ7ko7Sdm8MkBLSuaMulg8x+2lc4ejFeH1SLNciUHJokI3OmSH3Z3D74fe+m1He0qd eSM2eno+nrAZROc9iZuBYLRVDkYB7LNlc9rvfrp1FUfpsKqAeIfQsTJqe3285w3DrU1f VjuQ== X-Gm-Message-State: AOJu0YwT2ySH6y7WKZKkUD1y18Z9b7w6LZKlChgmaOO45i37O9e+csGm 5qhEA/caeLoXUOfZuDANtl65SfGWPPXNKDbWwOg3CHmJavQPSwc/fd8jIbSXtnNY1oUl4ngyq9g m X-Google-Smtp-Source: AGHT+IFXVGoARxnc8sOGVi5lMe3ODeb31tY+p6uUoi7S0/kULZkby1ahkRmtV82wfIRWFnsDiJLSCA== X-Received: by 2002:a05:6a00:2e85:b0:6ed:4f2e:ef22 with SMTP id fd5-20020a056a002e8500b006ed4f2eef22mr3378121pfb.31.1713547781717; Fri, 19 Apr 2024 10:29:41 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id h16-20020a632110000000b005f3c5cf33b5sm3383074pgh.37.2024.04.19.10.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:29:41 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v4 6/6] latencystats: fix for pedantic warnings Date: Fri, 19 Apr 2024 10:28:26 -0700 Message-ID: <20240419172926.55447-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240419172926.55447-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240419172926.55447-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 RTE_LOG_REGISTER_DEFAULT alread has a semicolon. So adding one here causes a warning if compiler is set to pedantic. 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 5db896ac7b..f60c893199 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -29,7 +29,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__) @@ -229,6 +229,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); @@ -281,7 +285,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", @@ -290,7 +294,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",