From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EBBBB455AD for ; Mon, 15 Jul 2024 17:28:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E113F40B9C; Mon, 15 Jul 2024 17:28:35 +0200 (CEST) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mails.dpdk.org (Postfix) with ESMTP id 0D82D402DD for ; Mon, 15 Jul 2024 17:28:35 +0200 (CEST) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-42726d6eca5so32379655e9.1 for ; Mon, 15 Jul 2024 08:28:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721057315; x=1721662115; 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=rrpHUAdYlDuQprRMGXdzq4f6tYUpCGoAwHPuTxLMNXE=; b=c1KIKB2wltfm9F1POz1dYE9uXY0R5jl111YZDLP7EuHvwsMDZjLc6OpenwBEox4H72 uY4JPW16PRU04qtR3aEA7bAbYGNUZ84pjIJrwipSAua2R8vmuQbLD068qUzpTrlGWb0A GrEKRpgFK4Vtw+RR/bDA514ldT5D30X8EsC70PJD/F/DAIluBVdaliuXNjGS25JLkTlb tqdmVzsD2wmptTbKyUXnc36FYXHCwzt4ZfwTQb+mL5/Kn0qQRxjAZFOfcnIfcLWbprr8 8oxhWMAFntYnhjY5k7ShanAmy9ncuw3ABztM/SrgqHe/kJwo1PyxrOITw23FhcBvswNK lYZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721057315; x=1721662115; 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=rrpHUAdYlDuQprRMGXdzq4f6tYUpCGoAwHPuTxLMNXE=; b=OScGTgaZMadX5eWbdVTpBBUvmKRV6U8XU9uZPKrNe3mBsACJdWEP1Z84XyeSIObn98 zOpqO+RGPUf6s1rnBkf3ESxOCM/ixNRB95w7Flmz4gdxWbOibGww9hk1lk9+cGXUwpdN RTYccyqh1ENJqyoXUWzKFwxVHz3GKo9T2XsfOHZhsCkcZpJuj6vMCii6OjaH0E3/5spk se6bH/mxqTmvaxmO0dgClYLE7hWvxduW2IO2tsXkFz4d6AN2yOVLBqeC/pQQjjBm5nGi RSbz+Wska3OiA+zTsbXqKqbibOpxK90/U0uziRfR63s6zD6fA7P0RchkVPOK4RwKsdTt wIlg== X-Forwarded-Encrypted: i=1; AJvYcCXcJYfd/JazgT1bqXV4Apc4sP83s9TgcdUuDbNyi/nUeLrCAeQ7xwnQdG2+s4oNI1U3yLADSlfiRru7ic3pFcM= X-Gm-Message-State: AOJu0YyaOLyWCbMDILwdP3l49QVSBrI9MUYVljKjGQL7oPpMQA5/ernC ig5rZhSL6Q03VDiAsb4IvYsBaBIjnf/RVGVWXb121PhXb1AEScAk X-Google-Smtp-Source: AGHT+IF/hq4UaBxhJsk612z8DIQeO5o/tlDlDMKPmRZstL6I/CmMnXlEXqdjAchSiSUQuVga+7yk9A== X-Received: by 2002:a05:600c:48aa:b0:426:6e95:78d6 with SMTP id 5b1f17b1804b1-426706c62d9mr129900505e9.4.1721057314679; Mon, 15 Jul 2024 08:28:34 -0700 (PDT) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77b0bsm90961225e9.1.2024.07.15.08.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:28:34 -0700 (PDT) From: luca.boccassi@gmail.com To: Anatoly Burakov Cc: Vipin Padmam Ramesh , dpdk stable Subject: patch 'fbarray: fix incorrect lookbehind behavior' has been queued to stable release 22.11.6 Date: Mon, 15 Jul 2024 16:26:06 +0100 Message-Id: <20240715152704.2229503-28-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240715152704.2229503-1-luca.boccassi@gmail.com> References: <20240624235907.885628-81-luca.boccassi@gmail.com> <20240715152704.2229503-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/17/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/8f3876f8666456adebafd3a60b3378a96019ba1b Thanks. Luca Boccassi --- >From 8f3876f8666456adebafd3a60b3378a96019ba1b Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Mon, 8 Jul 2024 17:07:33 +0100 Subject: [PATCH] fbarray: fix incorrect lookbehind behavior [ upstream commit 8e3712928716a1deb8857c971865aa15dc436b04 ] Currently, whenever first bit of current index mask is set (meaning, there is potentially a run starting at the start of the mask), lookbehind loop is entered. In that loop, if the last bit of lookbehind mask is not set, the lookbehind is stopped, and the current lookbehind mask index is assigned to current index mask. However, because at that point we are inside a while-loop that decrements current index mask after each iteration, this results in erroneous mask index decrement. Fix lookbehind to avoid erroneous decrement, and add corresponding unit test. Fixes: e1ca5dc86226 ("fbarray: add reverse finding of chunk") Signed-off-by: Vipin Padmam Ramesh Signed-off-by: Anatoly Burakov --- app/test/test_fbarray.c | 24 ++++++++++++++++++++++++ lib/eal/common/eal_common_fbarray.c | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c index fff44816a1..f448d4f196 100644 --- a/app/test/test_fbarray.c +++ b/app/test/test_fbarray.c @@ -111,6 +111,14 @@ static int lookahead_test_setup(void) return init_array(); } +static int lookbehind_test_setup(void) +{ + /* set index 63 as used */ + param.start = 63; + param.end = 63; + return init_array(); +} + static int test_invalid(void) { struct rte_fbarray dummy; @@ -732,6 +740,21 @@ static int test_lookahead(void) return TEST_SUCCESS; } +static int test_lookbehind(void) +{ + int ret, free_len = 2; + + /* run regular test first */ + ret = test_find(); + if (ret != TEST_SUCCESS) + return ret; + + /* test if we can find free chunk while crossing mask boundary */ + TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(¶m.arr, param.start + 1, free_len), + param.start - free_len, "Free chunk index is wrong\n"); + return TEST_SUCCESS; +} + static struct unit_test_suite fbarray_test_suite = { .suite_name = "fbarray autotest", .setup = autotest_setup, @@ -746,6 +769,7 @@ static struct unit_test_suite fbarray_test_suite = { TEST_CASE_ST(full_msk_test_setup, reset_array, test_find), TEST_CASE_ST(empty_msk_test_setup, reset_array, test_empty), TEST_CASE_ST(lookahead_test_setup, reset_array, test_lookahead), + TEST_CASE_ST(lookbehind_test_setup, reset_array, test_lookbehind), TEST_CASES_END() } }; diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c index 842073ae1c..374103dc15 100644 --- a/lib/eal/common/eal_common_fbarray.c +++ b/lib/eal/common/eal_common_fbarray.c @@ -512,7 +512,8 @@ find_prev_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n, * as well, so skip that on next iteration. */ ignore_msk = UINT64_MAX << need; - msk_idx = lookbehind_idx; + /* outer loop will decrement msk_idx so add 1 */ + msk_idx = lookbehind_idx + 1; break; } -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-15 16:19:36.145663955 +0100 +++ 0028-fbarray-fix-incorrect-lookbehind-behavior.patch 2024-07-15 16:19:34.520205439 +0100 @@ -1 +1 @@ -From 8e3712928716a1deb8857c971865aa15dc436b04 Mon Sep 17 00:00:00 2001 +From 8f3876f8666456adebafd3a60b3378a96019ba1b Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 8e3712928716a1deb8857c971865aa15dc436b04 ] + @@ -20 +21,0 @@ -Cc: stable@dpdk.org @@ -30 +31 @@ -index bf89b99e5b..147d6e2a07 100644 +index fff44816a1..f448d4f196 100644 @@ -79 +80 @@ -index 2680b34823..b4f0b0b0c3 100644 +index 842073ae1c..374103dc15 100644