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 86D0743B7D for ; Tue, 5 Mar 2024 10:57:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 81AC042D66; Tue, 5 Mar 2024 10:57:49 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2082.outbound.protection.outlook.com [40.107.237.82]) by mails.dpdk.org (Postfix) with ESMTP id 66BE94014F for ; Tue, 5 Mar 2024 10:57:48 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFLH3VSsFMB+EYUfCt2y3T102uiaodWydLU9gOZANe+zRwrpYbp8G6Eqr/NOgIgKYVJxeZg9UkXfaORd9XGJw5Ct9avMb6GL5AH2BZrm/zKRI0Ny3dKbMtwlJuUNVSmmztK1MrV1jMIEJpWqmyvISVOAu+GP+XxrlF3Loj2S4p30Gvz29oFB++Uj+vIXrNAoAwycJrgb4jEF6TNzuec86FsCdhJr1O7D8/1sMHXFdyNdPps//SyoGcNHEtaBG82eijTaFYvOcNsNnYr7VMt70myjQzkSpi3hhJfk6q2e50iyLfDU0FB0hCtK4Sz6755BAy1YpF6n60EzUk/WCMA2zg== 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=VrU88lNxoqUGfdwaBAWkIh/N0e9fPH2HSnTIHpI8zUY=; b=BdtQ0tlS5DjxnqPOd3Zys3jDJaEJTQwCZU50AcQA0G28KnzdDDL24ZTXui6jTcTbP1LhHhlYOJ8ITzcW0wVTB65li7Ax5KhoK0VHk+owdLChGdCLgXDymM7CSVlu+PT4SnytNBhR9DK6U2WJjFkJUPRt+R4R+uxBlP2qtKcYxy/ePwgDUC0/30gFUqFh9+oAe5/qpFK8NZg05oN0GJod8zybuLfxim067naCqh1LDctwfPIEf26TR6jkCLaXqAkl5HhbjB/xlqrJ+WUIxRH3jXPXuk3WbAtaB8kTBP7CIbeFvHCkPRezY9j3MSG1F0m5la6iPNUp3XnTKv4Tr7hnbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=microsoft.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=VrU88lNxoqUGfdwaBAWkIh/N0e9fPH2HSnTIHpI8zUY=; b=HK2P32IHIHHi1SkF/G1xcD0wuTsouqaNNrARNLCEb1L748FKfsv4pI+Q4+WGq+o7Ed2mxc8oF8mEIX4XwlRqDZz8fTyYRuYiEATUeoyj9vJHxfyXreF90sHy+PDw5BT3iu9OecFiSTzyMeddFiqXa63NxJhGkE6kyXCdlyu7bPuQQ4nPuRX2TXB8k0oTj92UY68nKddgr6KRz2GL5w7BmmY3DZdmGBqdSDXvPKuN0zdfyHR+PpRb7PfuhzCbs7lyp7pc5ccbjeF2dIU0YxxUYEQdxtw5OHrhLbcBccuqG8qxJBTgolnmn6VSB6t+i6GqUo2wW4hgGDx0pzW6Or4ing== Received: from BY5PR03CA0019.namprd03.prod.outlook.com (2603:10b6:a03:1e0::29) by IA0PR12MB8646.namprd12.prod.outlook.com (2603:10b6:208:489::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Tue, 5 Mar 2024 09:57:45 +0000 Received: from SJ5PEPF000001D5.namprd05.prod.outlook.com (2603:10b6:a03:1e0:cafe::a5) by BY5PR03CA0019.outlook.office365.com (2603:10b6:a03:1e0::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.34 via Frontend Transport; Tue, 5 Mar 2024 09:57:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ5PEPF000001D5.mail.protection.outlook.com (10.167.242.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Tue, 5 Mar 2024 09:57:45 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 5 Mar 2024 01:57:34 -0800 Received: from nvidia.com (10.126.231.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.1258.12; Tue, 5 Mar 2024 01:57:32 -0800 From: Xueming Li To: Long Li CC: dpdk stable Subject: patch 'net/mana: handle MR cache expansion failure' has been queued to stable release 23.11.1 Date: Tue, 5 Mar 2024 17:47:27 +0800 Message-ID: <20240305094757.439387-107-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305094757.439387-1-xuemingl@nvidia.com> References: <20240305094757.439387-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D5:EE_|IA0PR12MB8646:EE_ X-MS-Office365-Filtering-Correlation-Id: 6eeae8f1-d18c-4090-75a0-08dc3cfab4cd X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rSyxbgoua3FnESBJCWFoX3kq53Uuxtj3pt2ekiMYy4YvQF5cE5ti41Pd5SyhXK+ewtWkdbpYqWiuwfVXaUMRdS7cyu6dXILdHScmo6hVOpnrxzwmhK4GIjVeK4IHzSxr0eOYp7dA8ZtRQwbZz5xS6/9hBUysZA3fXO4CZbNWjugvbBNt/4y7nIYFOcKrs9+kdpJT2bGssoXhoBQOqXXGiGbbUE10vP86XdU2i2zEZmS8QlGrSD5F5QGXTUv10BcpaP7nCjtcv/w+skE23pIKfEfGEhRlrQUxcaAAmAv8U58fn5iNl2ys+mItOhyfeS4kJegOi+9Ml5geoJjpaHYMsIEXYWZBGkSvidBkmkkIsl0Ic5akY4xXwwmaSdBu+fk06iqasAwGrp0j9tqwgGWcdnh/UEP1zNFpXyw/4vculHPzxDfPK8o71aR8Yzv4fGvfaI04kKIL4u4xLyAKeGyeK1v8hVacpTwbhdL3nCnb/8mVBYa1lYsOhCSGXJNCAgqQFSjky9UG2+xGz0jFYz5fYQBtm1SD4Hi30qoexOnhzQjpuFeR/in407OFAEt1eAgMb8OzXXDrVAbe0TlYPhhId5Pq2YMiU18ZUOkoNrwGWdALDzq4n9tobXxqC3cF7CBeCLMxgPrXppCimzVc4lR+CRYg3MSuHipaqGo5N0OT2Yfkc83WX5Z2bD15w615ag7GNUC3hkt+55HtlprVc0Nj9jDadLNnwCG02QW9jjAzsSMZfcqN7lSnoltBGldG36vZ X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(82310400014)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 09:57:45.2465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6eeae8f1-d18c-4090-75a0-08dc3cfab4cd 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8646 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.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/31/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=216918c28c77c571c4e1f3bbcc6140df9062f2f5 Thanks. Xueming Li --- >From 216918c28c77c571c4e1f3bbcc6140df9062f2f5 Mon Sep 17 00:00:00 2001 From: Long Li Date: Thu, 8 Feb 2024 16:05:04 -0800 Subject: [PATCH] net/mana: handle MR cache expansion failure Cc: Xueming Li [ upstream commit 0c7bc26bb0b39bfe8999f422329bd52861b43a72 ] On MR cache expansion failure, the request should fail as there is no path to get a new MR into the tree. Attempting to insert a new MR to the cache tree will result in memory violation. Fixes: 0f5db3c68ba7 ("net/mana: implement memory registration") Signed-off-by: Long Li --- drivers/net/mana/mana.h | 6 +++--- drivers/net/mana/mr.c | 45 ++++++++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/drivers/net/mana/mana.h b/drivers/net/mana/mana.h index 6836872dc2..822b8a1f15 100644 --- a/drivers/net/mana/mana.h +++ b/drivers/net/mana/mana.h @@ -522,9 +522,9 @@ void mana_del_pmd_mr(struct mana_mr_cache *mr); void mana_mempool_chunk_cb(struct rte_mempool *mp, void *opaque, struct rte_mempool_memhdr *memhdr, unsigned int idx); -struct mana_mr_cache *mana_mr_btree_lookup(struct mana_mr_btree *bt, - uint16_t *idx, - uintptr_t addr, size_t len); +int mana_mr_btree_lookup(struct mana_mr_btree *bt, uint16_t *idx, + uintptr_t addr, size_t len, + struct mana_mr_cache **cache); int mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry); int mana_mr_btree_init(struct mana_mr_btree *bt, int n, int socket); void mana_mr_btree_free(struct mana_mr_btree *bt); diff --git a/drivers/net/mana/mr.c b/drivers/net/mana/mr.c index dfb2412834..eb6d073a95 100644 --- a/drivers/net/mana/mr.c +++ b/drivers/net/mana/mr.c @@ -137,8 +137,12 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, try_again: /* First try to find the MR in local queue tree */ - mr = mana_mr_btree_lookup(local_mr_btree, &idx, - (uintptr_t)mbuf->buf_addr, mbuf->buf_len); + ret = mana_mr_btree_lookup(local_mr_btree, &idx, + (uintptr_t)mbuf->buf_addr, mbuf->buf_len, + &mr); + if (ret) + return NULL; + if (mr) { DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIxPTR " len %zu", mr->lkey, mr->addr, mr->len); @@ -147,11 +151,14 @@ try_again: /* If not found, try to find the MR in global tree */ rte_spinlock_lock(&priv->mr_btree_lock); - mr = mana_mr_btree_lookup(&priv->mr_btree, &idx, - (uintptr_t)mbuf->buf_addr, - mbuf->buf_len); + ret = mana_mr_btree_lookup(&priv->mr_btree, &idx, + (uintptr_t)mbuf->buf_addr, + mbuf->buf_len, &mr); rte_spinlock_unlock(&priv->mr_btree_lock); + if (ret) + return NULL; + /* If found in the global tree, add it to the local tree */ if (mr) { ret = mana_mr_btree_insert(local_mr_btree, mr); @@ -227,22 +234,23 @@ mana_mr_btree_expand(struct mana_mr_btree *bt, int n) /* * Look for a region of memory in MR cache. */ -struct mana_mr_cache * -mana_mr_btree_lookup(struct mana_mr_btree *bt, uint16_t *idx, - uintptr_t addr, size_t len) +int mana_mr_btree_lookup(struct mana_mr_btree *bt, uint16_t *idx, + uintptr_t addr, size_t len, + struct mana_mr_cache **cache) { struct mana_mr_cache *table; uint16_t n; uint16_t base = 0; int ret; - n = bt->len; + *cache = NULL; + n = bt->len; /* Try to double the cache if it's full */ if (n == bt->size) { ret = mana_mr_btree_expand(bt, bt->size << 1); if (ret) - return NULL; + return ret; } table = bt->table; @@ -261,14 +269,16 @@ mana_mr_btree_lookup(struct mana_mr_btree *bt, uint16_t *idx, *idx = base; - if (addr + len <= table[base].addr + table[base].len) - return &table[base]; + if (addr + len <= table[base].addr + table[base].len) { + *cache = &table[base]; + return 0; + } DP_LOG(DEBUG, "addr 0x%" PRIxPTR " len %zu idx %u sum 0x%" PRIxPTR " not found", addr, len, *idx, addr + len); - return NULL; + return 0; } int @@ -313,14 +323,21 @@ mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry) struct mana_mr_cache *table; uint16_t idx = 0; uint16_t shift; + int ret; + + ret = mana_mr_btree_lookup(bt, &idx, entry->addr, entry->len, &table); + if (ret) + return ret; - if (mana_mr_btree_lookup(bt, &idx, entry->addr, entry->len)) { + if (table) { DP_LOG(DEBUG, "Addr 0x%" PRIxPTR " len %zu exists in btree", entry->addr, entry->len); return 0; } if (bt->len >= bt->size) { + DP_LOG(ERR, "Btree overflow detected len %u size %u", + bt->len, bt->size); bt->overflow = 1; return -1; } -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 17:39:34.177888506 +0800 +++ 0106-net-mana-handle-MR-cache-expansion-failure.patch 2024-03-05 17:39:30.893566497 +0800 @@ -1 +1 @@ -From 0c7bc26bb0b39bfe8999f422329bd52861b43a72 Mon Sep 17 00:00:00 2001 +From 216918c28c77c571c4e1f3bbcc6140df9062f2f5 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 0c7bc26bb0b39bfe8999f422329bd52861b43a72 ] @@ -11 +13,0 @@ -Cc: stable@dpdk.org @@ -20 +22 @@ -index 4c56e6f746..3626925871 100644 +index 6836872dc2..822b8a1f15 100644 @@ -23 +25 @@ -@@ -523,9 +523,9 @@ void mana_del_pmd_mr(struct mana_mr_cache *mr); +@@ -522,9 +522,9 @@ void mana_del_pmd_mr(struct mana_mr_cache *mr); @@ -37 +39 @@ -index c9d0f7ef5a..c4045141bc 100644 +index dfb2412834..eb6d073a95 100644 @@ -40 +42 @@ -@@ -138,8 +138,12 @@ mana_alloc_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, +@@ -137,8 +137,12 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, struct mana_priv *priv, @@ -55 +57 @@ -@@ -148,11 +152,14 @@ try_again: +@@ -147,11 +151,14 @@ try_again: @@ -73 +75 @@ -@@ -228,22 +235,23 @@ mana_mr_btree_expand(struct mana_mr_btree *bt, int n) +@@ -227,22 +234,23 @@ mana_mr_btree_expand(struct mana_mr_btree *bt, int n) @@ -102 +104 @@ -@@ -262,14 +270,16 @@ mana_mr_btree_lookup(struct mana_mr_btree *bt, uint16_t *idx, +@@ -261,14 +269,16 @@ mana_mr_btree_lookup(struct mana_mr_btree *bt, uint16_t *idx, @@ -122 +124 @@ -@@ -314,14 +324,21 @@ mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry) +@@ -313,14 +323,21 @@ mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry)