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 0FC84428F8 for ; Sun, 9 Apr 2023 17:34:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09F1A406B8; Sun, 9 Apr 2023 17:34:00 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2086.outbound.protection.outlook.com [40.107.102.86]) by mails.dpdk.org (Postfix) with ESMTP id 3C4714067E for ; Sun, 9 Apr 2023 17:33:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cVFQBBMuMlxJWx6TX2Rn3FabYJkGbrd/qSeHeL3raTeKrn3K2V+L7qoU0hLZEYyae6761BnrK5sX9e0gKmFewmV0q3kZMn7pM0ZdsMzw/VL3CVXyInnRKBbfE9Xsxf+de6AQFE6H2wgEz7apLztX0VHA98k93JXl6Bauozih+udnZCpASIoDXayNMy0ft+C6zW+p9vu/axJmClFXhB33SPBIdqakxPif6vgwz1mcaFXow/RfSh5gsoOdCfKE+Rnum7UM1cPWHpWVnKN2lcWSnxDkRd2Id3gHj82EzdHJtJoZCMXCpZ7b+BmbexX8bLWhA8CnZEro7rndRl3svXhEkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=N3ZYRKA1e25Bh+dAs2HfaUjuT0R9bcaqmPIC7RcBivw=; b=nNyfqbJlhQLY7D1SWoOVTK1oB8joot12kSauKBtqL46eE07uhnffqnSf02CeWB3KPlwmPFdM0CwcMyOBrPlkSAGQU/Pr0M1B13s6wNiXGM/VR1Oc5RPpogxWi/BfsKGwKzZC3O/Lqp4HEO9Zlq4YKFGang+qGvbzg/8goj+z5m9GTw/QmuiQZ96pH118K+m0noK5wv3p/+WL7i3hSOvbqoipl3GpxODUHId8NfgEb+oCO8C3gM/RhfFGStlL6xKLYY2S220ZIShE1PdDsbQOCX8kVsxJGsmEudhvXLuIMTGcbCGQd1sJMfwr3J13eCkJZvmfnh44uVi+sAagZukErQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=marvell.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 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=N3ZYRKA1e25Bh+dAs2HfaUjuT0R9bcaqmPIC7RcBivw=; b=toJeGz4ACB9wbsDbg7dlbKh15+i6dqJu5mHS6mjxCt838VNWHTwEeH8sUIzoDrHyJ8Hrqs/DK+zLeBMXpYMQ7hThCB37uksgLcivjTgKb32DiTiMY4vKKoKSs8WPNwhVP9mcDBuO/vPFUx7sVvAO6UGMDj9wUwzCJrGxmZt5KUE6xwCRMsaBfQNt3MDwmT+MSkGLPb1o+ftQ07kP9ZxsDLagUkcsIq+wyvExPrpk3i8Cl02h7Y3LKxGX+yXN/BcwYQXPeDVy/pIeTjDcKsQDytuj/IWNvPbLTdx2ULQjsGCr4q8E0paKVoCAhyiCK/RmOQj93WhZxJFeBufFo2gPSA== Received: from MW4PR03CA0297.namprd03.prod.outlook.com (2603:10b6:303:b5::32) by DM4PR12MB5360.namprd12.prod.outlook.com (2603:10b6:5:39f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Sun, 9 Apr 2023 15:33:55 +0000 Received: from CO1NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::97) by MW4PR03CA0297.outlook.office365.com (2603:10b6:303:b5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Sun, 9 Apr 2023 15:33:55 +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 CO1NAM11FT041.mail.protection.outlook.com (10.13.174.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.25 via Frontend Transport; Sun, 9 Apr 2023 15:33:54 +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.986.5; Sun, 9 Apr 2023 08:33:54 -0700 Received: from nvidia.com (10.126.230.37) 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.986.37; Sun, 9 Apr 2023 08:33:52 -0700 From: Xueming Li To: Volodymyr Fialko CC: dpdk stable Subject: patch 'reorder: fix sequence number mbuf field register' has been queued to stable release 22.11.2 Date: Sun, 9 Apr 2023 23:24:45 +0800 Message-ID: <20230409152529.5308-98-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230409152529.5308-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230409152529.5308-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT041:EE_|DM4PR12MB5360:EE_ X-MS-Office365-Filtering-Correlation-Id: fc2ebd52-4a71-4fa4-f4ae-08db390fd3f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C9PXg30JdgV9qNrfX4r96JIr1Hty0zW1vwh+m8UPDooSXvOgwx6c/Mtqwp4JokzE7oakwfzcmDtbn8nQlfBDDiMFibHDbhlDX/JChlzPMdMaW2lmcRlECNFVF3HYHrXMC2cd1bRTHyl7n9PmA5799CaPV07U3U48lJLd7vAsP01Reb5Vd8g4FCKVbdqBNsuSUFFYQNaBrDqX3exexcC9WUjiWh7QyrOrAeI2pwOR0rMxxYQ/6jWr+o87dubBINmCZSKtnUvhdlSMvoNWHsgMQHSEnxmiaRnBeqO72RKtASixRpaH+qQ9KFdrC6F/zG5LzIi57fDcNubdOo+9qqo6W5Ngrgu771Nwnya5VRWxdgN9i/WIEiL4jGQi/dzFgrYQthYYngptVgIZccEo4PW8DDC1jFGzgRHpRsaUqQ8J+yh9SxofHRNtZHekODOun/BojHzrt5l1tCguGNXGtlHPfyMHWyScOgyeATVRBmoyh1ruH+V0thsQN+UwsUSC1nnXH2xAL5Z6oc/jiV0rkKXZLXtaNboU9e28US0o/gyUlcalu+vjUykQhzsOk01rdXe3ze+CMgdXbzCOVCGxEU6tqVMtekxxElwDXkLM5HzI1SJJfcuEnZpDlB/0XS+VaJinsQ9uY7Y4H1+boHTb/umN35b3VmW2rIFLGjZzXNbu0H7ut84/5V97qb2a/XbW2Hs34fwmpePoDerkc+Z/3WCzpvr2KXnePpUVngqBM430GHEJeEYb5DbBxJeQDL89ha9+PNXLi0YUI00ElKCDUAywEELUJFM9whXOA5l0PKSi8JsatuQA8lZgKc6Ag8zWxDqTcHt4zAkE6LR+H8i9Lag71A== 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:(13230028)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199021)(40470700004)(36840700001)(46966006)(316002)(966005)(5660300002)(478600001)(7696005)(8936002)(41300700001)(4326008)(70206006)(8676002)(6916009)(70586007)(83380400001)(26005)(6666004)(53546011)(1076003)(2906002)(186003)(6286002)(16526019)(40460700003)(426003)(336012)(356005)(7636003)(82740400003)(55016003)(47076005)(2616005)(40480700001)(36860700001)(36756003)(86362001)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2023 15:33:54.5942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc2ebd52-4a71-4fa4-f4ae-08db390fd3f9 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: CO1NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5360 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.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 04/11/23. 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=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging/commit/8f35765d1584ffa0ff205236a3c4ddacf43b581e Thanks. Xueming Li --- >From 8f35765d1584ffa0ff205236a3c4ddacf43b581e Mon Sep 17 00:00:00 2001 From: Volodymyr Fialko Date: Mon, 13 Mar 2023 14:04:28 +0100 Subject: [PATCH] reorder: fix sequence number mbuf field register Cc: Xueming Li [ upstream commit ec87595f4de01cb81878874d209fa03e6963b3e4 ] It's possible to initialize reorder buffer with user allocated memory via rte_reorder_init() function. In such case, rte_reorder_create() is not required and reorder dynamic field in rte_mbuf will not be registered. Both reorder lib and mbuf dynamic field are using `rte_mcfg_tailq` read/write lock for synchronization. To avoid deadlocking, move reorder buffer initialization before queue insertion. Fixes: 01f3496695b5 ("reorder: switch sequence number to dynamic mbuf field") Signed-off-by: Volodymyr Fialko --- lib/reorder/rte_reorder.c | 95 +++++++++++++++++++++++++-------------- lib/reorder/rte_reorder.h | 1 + 2 files changed, 62 insertions(+), 34 deletions(-) diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c index b38e71f460..bc85b83b14 100644 --- a/lib/reorder/rte_reorder.c +++ b/lib/reorder/rte_reorder.c @@ -60,6 +60,11 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, { const unsigned int min_bufsize = sizeof(*b) + (2 * size * sizeof(struct rte_mbuf *)); + static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = { + .name = RTE_REORDER_SEQN_DYNFIELD_NAME, + .size = sizeof(rte_reorder_seqn_t), + .align = __alignof__(rte_reorder_seqn_t), + }; if (b == NULL) { RTE_LOG(ERR, REORDER, "Invalid reorder buffer parameter:" @@ -86,6 +91,15 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, return NULL; } + rte_reorder_seqn_dynfield_offset = rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc); + if (rte_reorder_seqn_dynfield_offset < 0) { + RTE_LOG(ERR, REORDER, + "Failed to register mbuf field for reorder sequence number, rte_errno: %i\n", + rte_errno); + rte_errno = ENOMEM; + return NULL; + } + memset(b, 0, bufsize); strlcpy(b->name, name, sizeof(b->name)); b->memsize = bufsize; @@ -98,21 +112,45 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, return b; } +/* + * Insert new entry into global list. + * Returns pointer to already inserted entry if such exists, or to newly inserted one. + */ +static struct rte_tailq_entry * +rte_reorder_entry_insert(struct rte_tailq_entry *new_te) +{ + struct rte_reorder_list *reorder_list; + struct rte_reorder_buffer *b, *nb; + struct rte_tailq_entry *te; + + rte_mcfg_tailq_write_lock(); + + reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list); + /* guarantee there's no existing */ + TAILQ_FOREACH(te, reorder_list, next) { + b = (struct rte_reorder_buffer *) te->data; + nb = (struct rte_reorder_buffer *) new_te->data; + if (strncmp(nb->name, b->name, RTE_REORDER_NAMESIZE) == 0) + break; + } + + if (te == NULL) { + TAILQ_INSERT_TAIL(reorder_list, new_te, next); + te = new_te; + } + + rte_mcfg_tailq_write_unlock(); + + return te; +} + struct rte_reorder_buffer* rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) { struct rte_reorder_buffer *b = NULL; - struct rte_tailq_entry *te; - struct rte_reorder_list *reorder_list; + struct rte_tailq_entry *te, *te_inserted; const unsigned int bufsize = sizeof(struct rte_reorder_buffer) + (2 * size * sizeof(struct rte_mbuf *)); - static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = { - .name = RTE_REORDER_SEQN_DYNFIELD_NAME, - .size = sizeof(rte_reorder_seqn_t), - .align = __alignof__(rte_reorder_seqn_t), - }; - - reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list); /* Check user arguments. */ if (!rte_is_power_of_2(size)) { @@ -128,32 +166,12 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) return NULL; } - rte_reorder_seqn_dynfield_offset = - rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc); - if (rte_reorder_seqn_dynfield_offset < 0) { - RTE_LOG(ERR, REORDER, "Failed to register mbuf field for reorder sequence number\n"); - rte_errno = ENOMEM; - return NULL; - } - - rte_mcfg_tailq_write_lock(); - - /* guarantee there's no existing */ - TAILQ_FOREACH(te, reorder_list, next) { - b = (struct rte_reorder_buffer *) te->data; - if (strncmp(name, b->name, RTE_REORDER_NAMESIZE) == 0) - break; - } - if (te != NULL) - goto exit; - /* allocate tailq entry */ te = rte_zmalloc("REORDER_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { RTE_LOG(ERR, REORDER, "Failed to allocate tailq entry\n"); rte_errno = ENOMEM; - b = NULL; - goto exit; + return NULL; } /* Allocate memory to store the reorder buffer structure. */ @@ -162,14 +180,23 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) RTE_LOG(ERR, REORDER, "Memzone allocation failed\n"); rte_errno = ENOMEM; rte_free(te); + return NULL; } else { - rte_reorder_init(b, bufsize, name, size); + if (rte_reorder_init(b, bufsize, name, size) == NULL) { + rte_free(b); + rte_free(te); + return NULL; + } te->data = (void *)b; - TAILQ_INSERT_TAIL(reorder_list, te, next); } -exit: - rte_mcfg_tailq_write_unlock(); + te_inserted = rte_reorder_entry_insert(te); + if (te_inserted != te) { + rte_free(b); + rte_free(te); + return te_inserted->data; + } + return b; } diff --git a/lib/reorder/rte_reorder.h b/lib/reorder/rte_reorder.h index 5abdb258e2..79c758f450 100644 --- a/lib/reorder/rte_reorder.h +++ b/lib/reorder/rte_reorder.h @@ -82,6 +82,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size); * The initialized reorder buffer instance, or NULL on error * On error case, rte_errno will be set appropriately: * - EINVAL - invalid parameters + * - ENOMEM - not enough memory to register dynamic field */ struct rte_reorder_buffer * rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-04-09 21:45:41.247133500 +0800 +++ 0097-reorder-fix-sequence-number-mbuf-field-register.patch 2023-04-09 21:45:38.719042200 +0800 @@ -1 +1 @@ -From ec87595f4de01cb81878874d209fa03e6963b3e4 Mon Sep 17 00:00:00 2001 +From 8f35765d1584ffa0ff205236a3c4ddacf43b581e Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit ec87595f4de01cb81878874d209fa03e6963b3e4 ] @@ -15 +17,0 @@ -Cc: stable@dpdk.org @@ -24 +26 @@ -index 9026403ea6..4bf36f6df6 100644 +index b38e71f460..bc85b83b14 100644 @@ -27 +29 @@ -@@ -61,6 +61,11 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, +@@ -60,6 +60,11 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, @@ -39 +41 @@ -@@ -87,6 +92,15 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, +@@ -86,6 +91,15 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, @@ -55 +57 @@ -@@ -99,21 +113,45 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, +@@ -98,21 +112,45 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, @@ -110 +112 @@ -@@ -129,32 +167,12 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) +@@ -128,32 +166,12 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) @@ -144 +146 @@ -@@ -163,14 +181,23 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) +@@ -162,14 +180,23 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) @@ -173 +175 @@ -index 7ed5f66a2e..f1207f72a9 100644 +index 5abdb258e2..79c758f450 100644