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 BDF9B457A1 for ; Mon, 12 Aug 2024 14:54:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F5DD402C3; Mon, 12 Aug 2024 14:54:35 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2071.outbound.protection.outlook.com [40.107.244.71]) by mails.dpdk.org (Postfix) with ESMTP id 4988C4029C for ; Mon, 12 Aug 2024 14:54:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f7spLpoq7BJazQ9Mg1zUofwP+aPYCv3WNiJywPskysytDJMcQjSJcjpmg9+3sEv2FW/AtQ4OHSK6NhP8nEDoFpmHLu0eMpTYFDHE9W4WGlaNxWP3xlotY+dP74wmCeGs3SzPkSc+QsVWcVYQnqHHkNFk4yNfGLWKLU3jFHjPC6srcBxnmGGONbNmeITivLtm9CJLYRIDpQkiKvzJ5eNjSUuawXHoibKU02zF+zLv5o7X2gOXHdeOsdgiMvIgpFosil840JE/qmJb/1gGw842usi1UhZCp1ZKe7eUUYwoh95i1UPldbDILyrRX2JLjKXbt5Py6fN5uww/ktMwrcfZSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AkFHM1zuABuHQZMJ46XJSIuVmlLVsL4topPVnEQyBBI=; b=ina3k2MjHiJx2pzi8PtbR8I2tU0yaLLJyG5x6KxS20iIh5jcgk+0lhcS2/UuuDmz7XzpQGAKkbdhpiZU52WXTbB5Uy0l0zucv8+h3GcF7XI3pom9b7KR/2bVLk/fc++aBgREG0Wr8yYGzp8PYTpmPHoxI6BVfRBoUbEKs+2c68q77xeg0wiF7p/vY74ry125et4QZetgDpg/Mh762jq2cwWDr03NKU2M7pWsCQjxNVD8pb1k8y6xXCbrB/Y7rQveMyLqCrP0NVR27uRMBHU6H6STH5Amq3fECx3caETUdSxYpRgzG9/1QV0ZY0+CjJJMtswcHbLW9xlvoUE/xjuIDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AkFHM1zuABuHQZMJ46XJSIuVmlLVsL4topPVnEQyBBI=; b=DckSyRrJJAxBKc3nsy2BPRyECUZFb+iceUTRE9qXSkI5wD8I99e9+SswjyuwvWPTkp4dnwT2HX3AoTvgPOq1Ccs/Ay6cwduWidRnxuVgNGyB4aJQDH+hfoUmiUM5BrAVEcVIhrUkA6O4+d6HHYTOJudIV9aqf8rmNiZCpiYBRSWOlXCp6u7H8R6bLQsjTJ/mrtbCv2T4WKDf64R8HrcnQb3sImE6/sgHQh6EAsJzGlAYd2nmYTlMlbxPnUYfdInlTPux7uxa/kzIiSJmM+zo9WqRAeWMJ1+xtjHKjwJ7Q25Yo87fIBihjrhGDdj78/7s4WQvkuNUKsixjz7SaJ3SeQ== Received: from DM6PR14CA0067.namprd14.prod.outlook.com (2603:10b6:5:18f::44) by DS0PR12MB6630.namprd12.prod.outlook.com (2603:10b6:8:d2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.17; Mon, 12 Aug 2024 12:54:30 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:5:18f:cafe::ba) by DM6PR14CA0067.outlook.office365.com (2603:10b6:5:18f::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.22 via Frontend Transport; Mon, 12 Aug 2024 12:54:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.19 via Frontend Transport; Mon, 12 Aug 2024 12:54:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 12 Aug 2024 05:54:18 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 12 Aug 2024 05:54:16 -0700 From: Xueming Li To: Anatoly Burakov CC: , Vipin Padmam Ramesh , "dpdk stable" Subject: patch 'fbarray: fix lookahead ignore mask handling' has been queued to stable release 23.11.2 Date: Mon, 12 Aug 2024 20:48:33 +0800 Message-ID: <20240812125035.389667-37-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240812125035.389667-1-xuemingl@nvidia.com> References: <20240712110153.309690-23-xuemingl@nvidia.com> <20240812125035.389667-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001708F:EE_|DS0PR12MB6630:EE_ X-MS-Office365-Filtering-Correlation-Id: 798f4d88-f64c-45fe-5a71-08dcbacde852 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?G/iSieXKWehlB4X1voxKOXU4xwEAAJP3dNj9b96l8mjF+3knf7wWgw5JLJKq?= =?us-ascii?Q?0Iz/cBHAzJ+u+FcCwhMUt1yKcS89cKJg3fUV6byxTj/jz7oLWRfPySs+SmKG?= =?us-ascii?Q?vFq6n9LhkmWzJPyWCznOsVE0q/Bc4EsMxlgeKkqWAyE0dzkg1V91830UZjJ2?= =?us-ascii?Q?QXy1xa6cvnxarRUl04YMZi/vrNPraA2bFXO5eo+vDE/ht5VjWuOB6WoF8TDt?= =?us-ascii?Q?AcnKxnPsNjUhVazc/E7yI1Rkm0kexZdY53wtV7Ku429rJFnYFKRk3UBtt+/a?= =?us-ascii?Q?y0Hk2pN1IKDUMctV4U/++QRAaQauAfg7Wae03Q3dJtQr4iiNbffBg6+7Ue7R?= =?us-ascii?Q?WHjItQoToI613KNXCVN08/1IhQi5cyyu1CAYCb0n4sllladexxq8WTNoAILk?= =?us-ascii?Q?RBQNoLErEIyedYR6WOCWJCQxSVQlWWyILoBqOjzMMoaOAT+d+LJlFy7ABVIy?= =?us-ascii?Q?1iVHQ+yAPLclhE2AERwjpS+pIhKgk9o1liz8HQ5DbEKrF+gxxZXO6tvnCr4Y?= =?us-ascii?Q?Xre+qj7XAHpa2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ascii?Q?XPCYcrU2UapNDtwKXl8lEQNB5BTToa2e?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2024 12:54:30.6978 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 798f4d88-f64c-45fe-5a71-08dcbacde852 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6630 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 23.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/14/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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=8baf37903248c80f512d33aa27c039b9a35bc195 Thanks. Xueming Li --- >From 8baf37903248c80f512d33aa27c039b9a35bc195 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Mon, 8 Jul 2024 17:07:34 +0100 Subject: [PATCH] fbarray: fix lookahead ignore mask handling Cc: Xueming Li [ upstream commit a344719c181aac28cb2ada0d2ddbfee8ad737a1a ] When lookahead mask does not have its first bit set, we can infer that we've lost our run. However, currently, we set ignore mask to ignore `need` number of bits, which is incorrect because while there is no *current* run within those bits, we might still be able to start a new run within those ignored bits later. This issue is fixed by counting how many shifts it took to lose the run, and this is the number of bits we should ignore (+1 to skip one we stopped on). Also, add unit tests to reproduce the problem. Fixes: c44d09811b40 ("eal: add shared indexed file-backed array") Signed-off-by: Vipin Padmam Ramesh Signed-off-by: Anatoly Burakov --- app/test/test_fbarray.c | 28 ++++++++++++++++++++++++++++ lib/eal/common/eal_common_fbarray.c | 13 ++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/test/test_fbarray.c b/app/test/test_fbarray.c index 147d6e2a07..4b17ef6be3 100644 --- a/app/test/test_fbarray.c +++ b/app/test/test_fbarray.c @@ -755,6 +755,32 @@ static int test_lookbehind(void) return TEST_SUCCESS; } +static int test_lookahead_mask(void) +{ + /* + * There is a certain type of lookahead behavior we want to test here, + * namely masking of bits that were scanned with lookahead but that we + * know do not match our criteria. This is achieved in following steps: + * + * 0. Look for a big enough chunk of free space (say, 62 elements) + * 1. Trigger lookahead by breaking a run somewhere inside mask 0 + * (indices 0-63) + * 2. Fail lookahead by breaking the run somewhere inside mask 1 + * (indices 64-127) + * 3. Ensure that we can still find free space in mask 1 afterwards + */ + + /* break run on first mask */ + rte_fbarray_set_used(¶m.arr, 61); + /* break run on second mask */ + rte_fbarray_set_used(¶m.arr, 70); + + /* we expect to find free space at 71 */ + TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(¶m.arr, 0, 62), + 71, "Free chunk index is wrong\n"); + return TEST_SUCCESS; +} + static struct unit_test_suite fbarray_test_suite = { .suite_name = "fbarray autotest", .setup = autotest_setup, @@ -770,6 +796,8 @@ static struct unit_test_suite fbarray_test_suite = { 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), + /* setup for these tests is more complex so do it in test func */ + TEST_CASE_ST(NULL, reset_array, test_lookahead_mask), TEST_CASES_END() } }; diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c index 6d9b95006c..13dc68207f 100644 --- a/lib/eal/common/eal_common_fbarray.c +++ b/lib/eal/common/eal_common_fbarray.c @@ -216,6 +216,8 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n, for (lookahead_idx = msk_idx + 1; lookahead_idx < msk->n_masks; lookahead_idx++) { unsigned int s_idx, need; + uint64_t first_bit = 1; + lookahead_msk = msk->data[lookahead_idx]; /* if we're looking for free space, invert the mask */ @@ -225,17 +227,22 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n, /* figure out how many consecutive bits we need here */ need = RTE_MIN(left, MASK_ALIGN); - for (s_idx = 0; s_idx < need - 1; s_idx++) + /* count number of shifts we performed */ + for (s_idx = 0; s_idx < need - 1; s_idx++) { lookahead_msk &= lookahead_msk >> 1ULL; + /* did we lose the run yet? */ + if ((lookahead_msk & first_bit) == 0) + break; + } /* if first bit is not set, we've lost the run */ - if ((lookahead_msk & 1) == 0) { + if ((lookahead_msk & first_bit) == 0) { /* * we've scanned this far, so we know there are * no runs in the space we've lookahead-scanned * as well, so skip that on next iteration. */ - ignore_msk = ~((1ULL << need) - 1); + ignore_msk = ~((1ULL << (s_idx + 1)) - 1); /* outer loop will increment msk_idx so add 1 */ msk_idx = lookahead_idx - 1; break; -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-08-12 20:44:03.693501606 +0800 +++ 0036-fbarray-fix-lookahead-ignore-mask-handling.patch 2024-08-12 20:44:02.005069277 +0800 @@ -1 +1 @@ -From a344719c181aac28cb2ada0d2ddbfee8ad737a1a Mon Sep 17 00:00:00 2001 +From 8baf37903248c80f512d33aa27c039b9a35bc195 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit a344719c181aac28cb2ada0d2ddbfee8ad737a1a ] @@ -19 +21,0 @@ -Cc: stable@dpdk.org @@ -75 +77 @@ -index b4f0b0b0c3..195f8394be 100644 +index 6d9b95006c..13dc68207f 100644