From patchwork Tue May 7 02:53:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139960 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 3ECC143FAA; Tue, 7 May 2024 04:54:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 03CAC42E3F; Tue, 7 May 2024 04:54:10 +0200 (CEST) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 9AC464027B for ; Tue, 7 May 2024 04:54:08 +0200 (CEST) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6f44a2d1e3dso2228158b3a.3 for ; Mon, 06 May 2024 19:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1715050447; x=1715655247; 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=odpbCbPKJbNy9lq8M2bkJamESlxScMlSEJ/CG3ThLpM=; b=gR2QI5WYInlT0BCDH+IpyKC65PFvVXxzfWD+LRlMfFGwITNOKbEEldXeKK8q99xArq mLZD1kSVI1Ajp3jJF7NH9cSAj6nIM9g1x+RbbsjqiGXLjZgujggmr+I5rR0dU+68GleG ahlgehUopjGPg+Nk8+N6kADBlosMbEurVL+J4JUikQ8FLeRHYxfHufO3nK9+py4qfqVG hMIaN29n8+YDO58+7zmrDUX3PhQd3oCVe4wmauzeIqjzQ7QN0NcuGfN6rq4QEGLsg30b EoAPTJmwDsIEYKPBq4A0RoxXx2O3mb9UBEOWUMHOk8NLtUhFObYj/SAJqikxZmCHLV+V l8VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715050447; x=1715655247; 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=odpbCbPKJbNy9lq8M2bkJamESlxScMlSEJ/CG3ThLpM=; b=CUsm/6PsWprwh6RkFR8zBTprBpslSza60ZQgBKsU3+BLPbb1zpSShFfHfhPKi2Z/xr pGShZUX8uzOzF69EaGWBxTIPpLU6iCc0oYmetPu/HHbVACaOXDX9zZ2BB8hlqwVEvbTQ 0g0FQmeHCWBIj7U3Y/wRBKsgX/VKHPJ7TI7u8fZpWMN8oI54/Utbig1a4PwVqTlrQkpY CQwP9Z6CCsKvuhnsbQshIaG3ixaWVgnXf53GffQdTo2SdPIdaIbQaccRbvPLXMzgsjMg JRO+zhYXTLr9lEfzTMRtMs7tJeduI9LIMFUSDZzpEvmhP5QVbiJX/dM2vhZ+W2hwKwK8 t9OA== X-Gm-Message-State: AOJu0Yw0rrpLKWKiuVLMbKEMx85pOwFmvaOh3MNyZ11msihMi2oXsrQ3 42ivCBL+cPX1RKmDKpg99eK3dtPml9Rk+YGq6vLcQUTYXXVVeHkOXsom2hFEC6U= X-Google-Smtp-Source: AGHT+IG21uQ9pzXhSxoxXB5ptplB1BcfXWpD5GY8FRxanrGh535IfVZ0f5Him8bzDWdozXkECRXfzQ== X-Received: by 2002:a05:6a21:8887:b0:1a7:9812:3680 with SMTP id tb7-20020a056a21888700b001a798123680mr12800588pzc.40.1715050447559; Mon, 06 May 2024 19:54:07 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id v8-20020aa78508000000b006ead792b6f2sm8466108pfn.1.2024.05.06.19.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 19:54:07 -0700 (PDT) From: Stephen Hemminger To: roretzla@linux.microsoft.com Cc: dev@dpdk.org, Stephen Hemminger Subject: [PATCH 1/2] lpm: remove unnecessary temporary VLA Date: Mon, 6 May 2024 19:53:54 -0700 Message-ID: <20240507025355.7145-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <1715019531-22796-1-git-send-email-roretzla@linux.microsoft.com> References: <1715019531-22796-1-git-send-email-roretzla@linux.microsoft.com> 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 Do not need to recompute all the table indices. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- lib/lpm/rte_lpm.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 2888e5f4ca..9c6df311cb 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -337,7 +337,6 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t *ips, uint32_t *next_hops, const unsigned n) { unsigned i; - unsigned tbl24_indexes[n]; const uint32_t *ptbl; /* DEBUG: Check user input arguments. */ @@ -345,12 +344,10 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t *ips, (next_hops == NULL)), -EINVAL); for (i = 0; i < n; i++) { - tbl24_indexes[i] = ips[i] >> 8; - } + unsigned int tbl24_index = ips[i] >> 8; - for (i = 0; i < n; i++) { /* Simply copy tbl24 entry to output */ - ptbl = (const uint32_t *)&lpm->tbl24[tbl24_indexes[i]]; + ptbl = (const uint32_t *)&lpm->tbl24[tbl24_index]; next_hops[i] = *ptbl; /* Overwrite output with tbl8 entry if needed */ From patchwork Tue May 7 02:53:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 139961 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 9ED0843FAA; Tue, 7 May 2024 04:54:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5685D42E60; Tue, 7 May 2024 04:54:11 +0200 (CEST) Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) by mails.dpdk.org (Postfix) with ESMTP id 620284027B for ; Tue, 7 May 2024 04:54:09 +0200 (CEST) Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6f08df79b9bso370607a34.3 for ; Mon, 06 May 2024 19:54:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1715050448; x=1715655248; 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=MxDLqd32CjV3eICTNbPcFS8d6P/kSMUXSwZ0OZ2IVT087dUI6Ku04aAu3WnY0DChMN zCBn21ZOMBf3zgVVHIQUc+vnUUOuD611b7SmAZPWkkiUwdMnF2/MMwGGBd3lWuC7Roal y8IoMMyS7nVxo9IoY2QTtPg6d2IAaJj4Pun6jI4Y+a+XRrwcdPtzZZEM+S0IqISGKuIT Jwb3nfeCbFxaHJlFsKm00NervLChmDi/ngPBPPqS4xbarTAlxyaV+igdRoXGja1YoO3Y I+ouWTXI9c8m3+WVz2MlXJZ+wYnSXb4BlrvFRQ5CNeJoL8LJP87K5szSaw6mn38wl9hs TgDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715050448; x=1715655248; 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=X0iOSGgLnx2ms/9riyYmORqqsHvvTFXcjirnGQfMHJq0hMNCehASdAONzioz+skcVy NhUXSSJln4Wu9Pw7AL59jT5/1Ydpfh3kMgTja+5//6JvUcneA1/I6sMdZ+juDxYFW2KM oDObzZwnQSXl0vz78UWE8kvOT2V3IvBLfcPiXaHREMMg3MxZ84SUr1DQL+SyPZjopSWS 4jeNj3qiCdp4IpbczBsiUGk0YT0GZL/P4aIF4ElEAslSAMa7IqzaOQpa5uIihVbKaMle j4081ZJWplqwrWqejOAveLBR4MJCO73xqlmmFz84zpZXUdERDa4HfOjgNq2gARoEqN69 sONg== X-Gm-Message-State: AOJu0YyrBPGOcWKxFEKoiraI1gBkNv+sO2WJMyAguuc8mgLMaE54NsPa mF661Ys7vNyQl/M4I0znZm7CQNXijhDa5V8435Wb+7AbVYDsehmEzN74EJdrzkY= X-Google-Smtp-Source: AGHT+IHxO9wondI8SZE9uNn6S8DWEd3swY9vRfvNXZBE3CdifMfILWgn4gpMZ7oLQRnn9u8gvm1RKg== X-Received: by 2002:a05:6808:3021:b0:3c9:69e4:33c2 with SMTP id ay33-20020a056808302100b003c969e433c2mr6924075oib.4.1715050448545; Mon, 06 May 2024 19:54:08 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id v8-20020aa78508000000b006ead792b6f2sm8466108pfn.1.2024.05.06.19.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 19:54:07 -0700 (PDT) From: Stephen Hemminger To: roretzla@linux.microsoft.com Cc: dev@dpdk.org, Stephen Hemminger , =?utf-8?q?Morten_Br=C3=B8rup?= Subject: [PATCH 2/2] latencystats: replace use of VLA Date: Mon, 6 May 2024 19:53:55 -0700 Message-ID: <20240507025355.7145-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240507025355.7145-1-stephen@networkplumber.org> References: <1715019531-22796-1-git-send-email-roretzla@linux.microsoft.com> <20240507025355.7145-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);