Skip to contentSkip to conversation

mlx5 updates 2022-10-24

GIT PULL Applied Saeed Mahameed 2 participants 16 messages Oct 27, 2022 – Oct 29, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

From: Saeed Mahameed <[email protected]>

v1-v2:
- fix 32bit x86 -Wframe-larger-than

This series provides optimizations to mlx5 SW steering. For more information please see tag log below.

Please pull and let me know if there is any problem.

Thanks,
Saeed.

The following changes since commit 12d6c1d3a2ad0c199ec57c201cdc71e8e157a232:

skbuff: Proactively round up to kmalloc bucket size (2022-10-27 15:48:19 +0200)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2022-10-24

for you to fetch changes up to edaea001442a792e4b14c7523072b9687700585e:

net/mlx5: DR, Remove the buddy used_list (2022-10-27 15:50:40 +0100)

----------------------------------------------------------------
mlx5-updates-2022-10-24

SW steering updates from Yevgeny Kliteynik:

1) 1st Four patches: small fixes / optimizations for SW steering:

- Patch 1: Don't abort destroy flow if failed to destroy table - continue and free everything else.
- Patches 2 and 3 deal with fast teardown:
+ Skip sync during fast teardown, as PCI device is not there any more.
+ Check device state when polling CQ - otherwise SW steering keeps polling the CQ forever, because nobody is there to flush it.
- Patch 4: Removing unneeded function argument.

2) Deal with the hiccups that we get during rules insertion/deletion, which sometimes reach 1/4 of a second. While insertion/deletion rate improvement was not the focus here, it still is a by-product of removing these hiccups.

Another by-product is the reduced standard deviation in measuring the duration of rules insertion/deletion bursts.

In the testing we add K rules (warm-up phase), and then continuously do insertion/deletion bursts of N rules.
During the test execution, the driver measures hiccups (amount and duration) and total time for insertion/deletion of a batch of rules.

Here are some numbers, before and after these patches:

+--------------------------------------------+-----------------+----------------+
|                                            |   Create rules  |  Delete rules  |
|                                            +--------+--------+--------+-------+
|                                            | Before |  After | Before | After |
+--------------------------------------------+--------+--------+--------+-------+
| Max hiccup [msec]                          |    253 |     42 |    254 |    68 |
+--------------------------------------------+--------+--------+--------+-------+
| Avg duration of 10K rules add/remove [msec]| 140.07 | 124.32 | 106.99 | 99.51 |
+--------------------------------------------+--------+--------+--------+-------+
| Num of hiccups per 100K rules add/remove   |   7.77 |   7.97 |  12.60 | 11.57 |
+--------------------------------------------+--------+--------+--------+-------+
| Avg hiccup duration [msec]                 |  36.92 |  33.25 |  36.15 | 33.74 |
+--------------------------------------------+--------+--------+--------+-------+

- Patch 5: Allocate a short array on stack instead of dynamically- it is destroyed at the end of the function.
- Patch 6: Rather than cleaning the corresponding chunk's section of ste_arrays on chunk deletion, initialize these areas upon chunk creation. Chunk destruction tend to come in large batches (during pool syncing), so instead of doing huge memory initialization during pool sync, we amortize this by doing small initsializations on chunk creation.
- Patch 7: In order to simplifies error flow and allows cleaner addition of new pools, handle creation/destruction of all the domain's memory pools and other memory-related fields in a separate init/uninit functions.
- Patch 8: During rehash, write each table row immediately instead of waiting for the whole table to be ready and writing it all - saves allocations of ste_send_info structures and improves performance.
- Patch 9: Instead of allocating/freeing send info objects dynamically, manage them in pool. The number of send info objects doesn't depend on number of rules, so after pre-populating the pool with an initial batch of send info objects, the pool is not expected to grow.
This way we save alloc/free during writing STEs to ICM, which by itself can sometimes take up to 40msec.
- Patch 10: Allocate icm_chunks from their own slab allocator, which lowered the alloc/free "hiccups" frequency.
- Patch 11: Similar to patch 9, allocate htbl from its own slab allocator.
- Patch 12: Lower sync threshold for ICM hot memory - set the threshold for sync to 1/4 of the pool instead of 1/2 of the pool. Although we will have
more syncs, each sync will be shorter and will help with insertion rate
stability. Also, notice that the overall number of hiccups wasn't increased due to all the other patches.
- Patch 13: Keep track of hot ICM chunks in an array instead of list. After steering sync, we traverse the hot list and finally free all the chunks. It appears that traversing a long list takes unusually long time due to cache misses on many entries, which causes a big "hiccup" during rule insertion. This patch replaces the list with pre-allocated array that stores only the bookkeeping information that is needed to later free the chunks in its buddy allocator.
- Patch 14: Remove the unneeded buddy used_list - we don't need to have the list of used chunks, we only need the total amount of used memory.

----------------------------------------------------------------
Yevgeny Kliteynik (14):
net/mlx5: DR, In destroy flow, free resources even if FW command failed net/mlx5: DR, Fix the SMFS sync_steering for fast teardown net/mlx5: DR, Check device state when polling CQ
net/mlx5: DR, Remove unneeded argument from dr_icm_chunk_destroy net/mlx5: DR, For short chains of STEs, avoid allocating ste_arr dynamically net/mlx5: DR, Initialize chunk's ste_arrays at chunk creation net/mlx5: DR, Handle domain memory resources init/uninit separately net/mlx5: DR, In rehash write the line in the entry immediately net/mlx5: DR, Manage STE send info objects in pool
net/mlx5: DR, Allocate icm_chunks from their own slab allocator net/mlx5: DR, Allocate htbl from its own slab allocator net/mlx5: DR, Lower sync threshold for ICM hot memory
net/mlx5: DR, Keep track of hot ICM chunks in an array instead of list net/mlx5: DR, Remove the buddy used_list

 .../mellanox/mlx5/core/steering/dr_buddy.c         |   2 -
 .../ethernet/mellanox/mlx5/core/steering/dr_cmd.c  |   7 +
 .../mellanox/mlx5/core/steering/dr_domain.c        |  89 ++++++++---
 .../mellanox/mlx5/core/steering/dr_icm_pool.c      | 174 ++++++++++++---------
 .../ethernet/mellanox/mlx5/core/steering/dr_rule.c |  92 +++++++----
 .../ethernet/mellanox/mlx5/core/steering/dr_send.c | 141 ++++++++++++++++-
 .../ethernet/mellanox/mlx5/core/steering/dr_ste.c  |  12 +-
 .../mellanox/mlx5/core/steering/dr_table.c         |   2 +-
 .../mellanox/mlx5/core/steering/dr_types.h         |  16 +-
 .../ethernet/mellanox/mlx5/core/steering/mlx5dr.h  |   9 +-
 10 files changed, 406 insertions(+), 138 deletions(-)
#1 lore raw

PATCH v2 1/14 net/mlx5: DR, In destroy flow, free resources even if FW command failed

From: Yevgeny Kliteynik <[email protected]>

Otherwise resources will never be freed and refcount will not be decreased.

---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c +1 -1
index 31d443dd8386..eb81759244d5 100644
@@ -292,7 +292,7 @@ int mlx5dr_table_destroy(struct mlx5dr_table *tbl)
 	mlx5dr_dbg_tbl_del(tbl);
 	ret = dr_table_destroy_sw_owned_tbl(tbl);
 	if (ret)
-		return ret;
+		mlx5dr_err(tbl->dmn, "Failed to destoy sw owned table\n");
 
 	dr_table_uninit(tbl);
 
Signature · 1 line
2.37.3
#3 lore raw

PATCH v2 2/14 net/mlx5: DR, Fix the SMFS sync_steering for fast teardown

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

If sync happens when the device is in fast teardown, just bail and don't do anything, because the PCI device is not there any more.

---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c +7 -0
index 16d65fe4f654..b4739eafc180 100644
@@ -271,6 +271,13 @@ int mlx5dr_cmd_sync_steering(struct mlx5_core_dev *mdev)
 {
 	u32 in[MLX5_ST_SZ_DW(sync_steering_in)] = {};
 
+	/* Skip SYNC in case the device is internal error state.
+	 * Besides a device error, this also happens when we're
+	 * in fast teardown
+	 */
+	if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
+		return 0;
+
 	MLX5_SET(sync_steering_in, in, opcode, MLX5_CMD_OP_SYNC_STEERING);
 
 	return mlx5_cmd_exec_in(mdev, sync_steering, in);
Signature · 1 line
2.37.3
#4 lore raw

PATCH v2 3/14 net/mlx5: DR, Check device state when polling CQ

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Calling fast teardown as part of the normal unloading caused a problem with SW steering - SW steering still needs to clear its tables, write to ICM and poll for completions. When teardown has been done, SW steering keeps polling the CQ forever, because nobody flushes it.

This patch fixes the issue by checking the device state in cases where no CQE was returned.

---
 .../net/ethernet/mellanox/mlx5/core/steering/dr_send.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c +9 -1
index ef19a66f5233..6ad026123b16 100644
@@ -78,8 +78,15 @@ static int dr_cq_poll_one(struct mlx5dr_cq *dr_cq)
 	int err;
 
 	cqe64 = mlx5_cqwq_get_cqe(&dr_cq->wq);
-	if (!cqe64)
+	if (!cqe64) {
+		if (unlikely(dr_cq->mdev->state ==
+			     MLX5_DEVICE_STATE_INTERNAL_ERROR)) {
+			mlx5_core_dbg_once(dr_cq->mdev,
+					   "Polling CQ while device is shutting down\n");
+			return CQ_POLL_ERR;
+		}
 		return CQ_EMPTY;
+	}
 
 	mlx5_cqwq_pop(&dr_cq->wq);
 	err = dr_parse_cqe(dr_cq, cqe64);
@@ -833,6 +840,7 @@ static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev,
 
 	cq->mcq.vector = 0;
 	cq->mcq.uar = uar;
+	cq->mdev = mdev;
 
 	return cq;
 
Signature · 1 line
2.37.3
#5 lore raw

PATCH v2 4/14 net/mlx5: DR, Remove unneeded argument from dr_icm_chunk_destroy

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Remove an argument that can be extracted in the function.

---
 .../mellanox/mlx5/core/steering/dr_icm_pool.c         | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +5 -6
index 4ca67fa24cc6..4cdc9e9a54e1 100644
@@ -203,12 +203,11 @@ get_chunk_icm_type(struct mlx5dr_icm_chunk *chunk)
 	return chunk->buddy_mem->pool->icm_type;
 }
 
-static void dr_icm_chunk_destroy(struct mlx5dr_icm_chunk *chunk,
-				 struct mlx5dr_icm_buddy_mem *buddy)
+static void dr_icm_chunk_destroy(struct mlx5dr_icm_chunk *chunk)
 {
 	enum mlx5dr_icm_type icm_type = get_chunk_icm_type(chunk);
 
-	buddy->used_memory -= mlx5dr_icm_pool_get_chunk_byte_size(chunk);
+	chunk->buddy_mem->used_memory -= mlx5dr_icm_pool_get_chunk_byte_size(chunk);
 	list_del(&chunk->chunk_list);
 
 	if (icm_type == DR_ICM_TYPE_STE)
@@ -299,10 +298,10 @@ static void dr_icm_buddy_destroy(struct mlx5dr_icm_buddy_mem *buddy)
 	struct mlx5dr_icm_chunk *chunk, *next;
 
 	list_for_each_entry_safe(chunk, next, &buddy->hot_list, chunk_list)
-		dr_icm_chunk_destroy(chunk, buddy);
+		dr_icm_chunk_destroy(chunk);
 
 	list_for_each_entry_safe(chunk, next, &buddy->used_list, chunk_list)
-		dr_icm_chunk_destroy(chunk, buddy);
+		dr_icm_chunk_destroy(chunk);
 
 	dr_icm_pool_mr_destroy(buddy->icm_mr);
 
@@ -376,7 +375,7 @@ static int dr_icm_pool_sync_all_buddy_pools(struct mlx5dr_icm_pool *pool)
 			num_entries = mlx5dr_icm_pool_get_chunk_num_of_entries(chunk);
 			mlx5dr_buddy_free_mem(buddy, chunk->seg, ilog2(num_entries));
 			pool->hot_memory_size -= mlx5dr_icm_pool_get_chunk_byte_size(chunk);
-			dr_icm_chunk_destroy(chunk, buddy);
+			dr_icm_chunk_destroy(chunk);
 		}
 
 		if (!buddy->used_memory && pool->icm_type == DR_ICM_TYPE_STE)
Signature · 1 line
2.37.3
#6 lore raw

PATCH v2 5/14 net/mlx5: DR, For short chains of STEs, avoid allocating ste_arr dynamically

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

While creating rule, ste_arr is an array that is allocated at the start of the function and freed at the end.
This memory allocation can sometimes lead to "hiccups" of up to 10ms. However, the common use case is short chains of STEs. For such cases, we can use a local buffer on stack instead.

Changes in v2:
Use small local array for short rules, allocate dynamically for long rules

---
 .../mellanox/mlx5/core/steering/dr_rule.c     | 40 +++++++++++++------
 1 file changed, 27 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c +27 -13
index ddfaf7891188..6cbc444ad791 100644
@@ -3,7 +3,8 @@
 
 #include "dr_types.h"
 
-#define DR_RULE_MAX_STE_CHAIN (DR_RULE_MAX_STES + DR_ACTION_MAX_STES)
+#define DR_RULE_MAX_STES_OPTIMIZED 5
+#define DR_RULE_MAX_STE_CHAIN_OPTIMIZED (DR_RULE_MAX_STES_OPTIMIZED + DR_ACTION_MAX_STES)
 
 static int dr_rule_append_to_miss_list(struct mlx5dr_ste_ctx *ste_ctx,
 				       struct mlx5dr_ste *new_last_ste,
@@ -1089,6 +1090,7 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 			size_t num_actions,
 			struct mlx5dr_action *actions[])
 {
+	u8 hw_ste_arr_optimized[DR_RULE_MAX_STE_CHAIN_OPTIMIZED * DR_STE_SIZE] = {};
 	struct mlx5dr_ste_send_info *ste_info, *tmp_ste_info;
 	struct mlx5dr_matcher *matcher = rule->matcher;
 	struct mlx5dr_domain *dmn = matcher->tbl->dmn;
@@ -1098,6 +1100,7 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 	struct mlx5dr_ste_htbl *cur_htbl;
 	struct mlx5dr_ste *ste = NULL;
 	LIST_HEAD(send_ste_list);
+	bool hw_ste_arr_is_opt;
 	u8 *hw_ste_arr = NULL;
 	u32 new_hw_ste_arr_sz;
 	int ret, i;
@@ -1109,9 +1112,23 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 			 rule->flow_source))
 		return 0;
 
-	hw_ste_arr = kzalloc(DR_RULE_MAX_STE_CHAIN * DR_STE_SIZE, GFP_KERNEL);
-	if (!hw_ste_arr)
-		return -ENOMEM;
+	ret = mlx5dr_matcher_select_builders(matcher,
+					     nic_matcher,
+					     dr_rule_get_ipv(&param->outer),
+					     dr_rule_get_ipv(&param->inner));
+	if (ret)
+		return ret;
+
+	hw_ste_arr_is_opt = nic_matcher->num_of_builders <= DR_RULE_MAX_STES_OPTIMIZED;
+	if (likely(hw_ste_arr_is_opt)) {
+		hw_ste_arr = hw_ste_arr_optimized;
+	} else {
+		hw_ste_arr = kzalloc((nic_matcher->num_of_builders + DR_ACTION_MAX_STES) *
+				     DR_STE_SIZE, GFP_KERNEL);
+
+		if (!hw_ste_arr)
+			return -ENOMEM;
+	}
 
 	mlx5dr_domain_nic_lock(nic_dmn);
 
@@ -1119,13 +1136,6 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 	if (ret)
 		goto free_hw_ste;
 
-	ret = mlx5dr_matcher_select_builders(matcher,
-					     nic_matcher,
-					     dr_rule_get_ipv(&param->outer),
-					     dr_rule_get_ipv(&param->inner));
-	if (ret)
-		goto remove_from_nic_tbl;
-
 	/* Set the tag values inside the ste array */
 	ret = mlx5dr_ste_build_ste_arr(matcher, nic_matcher, param, hw_ste_arr);
 	if (ret)
@@ -1187,7 +1197,8 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 
 	mlx5dr_domain_nic_unlock(nic_dmn);
 
-	kfree(hw_ste_arr);
+	if (unlikely(!hw_ste_arr_is_opt))
+		kfree(hw_ste_arr);
 
 	return 0;
 
@@ -1204,7 +1215,10 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
 
 free_hw_ste:
 	mlx5dr_domain_nic_unlock(nic_dmn);
-	kfree(hw_ste_arr);
+
+	if (unlikely(!hw_ste_arr_is_opt))
+		kfree(hw_ste_arr);
+
 	return ret;
 }
 
Signature · 1 line
2.37.3
#7 lore raw

PATCH v2 6/14 net/mlx5: DR, Initialize chunk's ste_arrays at chunk creation

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Rather than cleaning the corresponding chunk's section of ste_arrays on chunk deletion, initialize these areas upon chunk creation.

Chunk destruction tend to come in large batches (during pool syncing). To reduce the "hiccup" in such cases, moving ste_arrays init from chunk destruction to initialization.

---
 .../mellanox/mlx5/core/steering/dr_icm_pool.c | 25 +++----------------
 1 file changed, 4 insertions(+), 21 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +4 -21
index 4cdc9e9a54e1..7ca1ef073f55 100644
@@ -177,42 +177,25 @@ static int dr_icm_buddy_get_ste_size(struct mlx5dr_icm_buddy_mem *buddy)
 
 static void dr_icm_chunk_ste_init(struct mlx5dr_icm_chunk *chunk, int offset)
 {
+	int num_of_entries = mlx5dr_icm_pool_get_chunk_num_of_entries(chunk);
 	struct mlx5dr_icm_buddy_mem *buddy = chunk->buddy_mem;
+	int ste_size = dr_icm_buddy_get_ste_size(buddy);
 	int index = offset / DR_STE_SIZE;
 
 	chunk->ste_arr = &buddy->ste_arr[index];
 	chunk->miss_list = &buddy->miss_list[index];
-	chunk->hw_ste_arr = buddy->hw_ste_arr +
-			    index * dr_icm_buddy_get_ste_size(buddy);
-}
-
-static void dr_icm_chunk_ste_cleanup(struct mlx5dr_icm_chunk *chunk)
-{
-	int num_of_entries = mlx5dr_icm_pool_get_chunk_num_of_entries(chunk);
-	struct mlx5dr_icm_buddy_mem *buddy = chunk->buddy_mem;
+	chunk->hw_ste_arr = buddy->hw_ste_arr + index * ste_size;
 
-	memset(chunk->hw_ste_arr, 0,
-	       num_of_entries * dr_icm_buddy_get_ste_size(buddy));
+	memset(chunk->hw_ste_arr, 0, num_of_entries * ste_size);
 	memset(chunk->ste_arr, 0,
 	       num_of_entries * sizeof(chunk->ste_arr[0]));
 }
 
-static enum mlx5dr_icm_type
-get_chunk_icm_type(struct mlx5dr_icm_chunk *chunk)
-{
-	return chunk->buddy_mem->pool->icm_type;
-}
-
 static void dr_icm_chunk_destroy(struct mlx5dr_icm_chunk *chunk)
 {
-	enum mlx5dr_icm_type icm_type = get_chunk_icm_type(chunk);
-
 	chunk->buddy_mem->used_memory -= mlx5dr_icm_pool_get_chunk_byte_size(chunk);
 	list_del(&chunk->chunk_list);
 
-	if (icm_type == DR_ICM_TYPE_STE)
-		dr_icm_chunk_ste_cleanup(chunk);
-
 	kvfree(chunk);
 }
 
Signature · 1 line
2.37.3
#8 lore raw

PATCH v2 7/14 net/mlx5: DR, Handle domain memory resources init/uninit separately

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Handle creation/destruction of all the domain's memory pools and other memory-related fields in a separate init/uninit functions. This simplifies error flow and allows cleaner addition of new pools.

---
 .../mellanox/mlx5/core/steering/dr_domain.c   | 55 +++++++++++++------
 1 file changed, 37 insertions(+), 18 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +37 -18
index fc6ae49b5ecc..543d655ae3b6 100644
@@ -56,6 +56,36 @@ int mlx5dr_domain_get_recalc_cs_ft_addr(struct mlx5dr_domain *dmn,
 	return 0;
 }
 
+static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
+{
+	int ret;
+
+	dmn->ste_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_STE);
+	if (!dmn->ste_icm_pool) {
+		mlx5dr_err(dmn, "Couldn't get icm memory\n");
+		return -ENOMEM;
+	}
+
+	dmn->action_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_MODIFY_ACTION);
+	if (!dmn->action_icm_pool) {
+		mlx5dr_err(dmn, "Couldn't get action icm memory\n");
+		ret = -ENOMEM;
+		goto free_ste_icm_pool;
+	}
+
+	return 0;
+
+free_ste_icm_pool:
+	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
+	return ret;
+}
+
+static void dr_domain_uninit_mem_resources(struct mlx5dr_domain *dmn)
+{
+	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
+	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
+}
+
 static int dr_domain_init_resources(struct mlx5dr_domain *dmn)
 {
 	int ret;
@@ -79,32 +109,22 @@ static int dr_domain_init_resources(struct mlx5dr_domain *dmn)
 		goto clean_pd;
 	}
 
-	dmn->ste_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_STE);
-	if (!dmn->ste_icm_pool) {
-		mlx5dr_err(dmn, "Couldn't get icm memory\n");
-		ret = -ENOMEM;
+	ret = dr_domain_init_mem_resources(dmn);
+	if (ret) {
+		mlx5dr_err(dmn, "Couldn't create domain memory resources\n");
 		goto clean_uar;
 	}
 
-	dmn->action_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_MODIFY_ACTION);
-	if (!dmn->action_icm_pool) {
-		mlx5dr_err(dmn, "Couldn't get action icm memory\n");
-		ret = -ENOMEM;
-		goto free_ste_icm_pool;
-	}
-
 	ret = mlx5dr_send_ring_alloc(dmn);
 	if (ret) {
 		mlx5dr_err(dmn, "Couldn't create send-ring\n");
-		goto free_action_icm_pool;
+		goto clean_mem_resources;
 	}
 
 	return 0;
 
-free_action_icm_pool:
-	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
-free_ste_icm_pool:
-	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
+clean_mem_resources:
+	dr_domain_uninit_mem_resources(dmn);
 clean_uar:
 	mlx5_put_uars_page(dmn->mdev, dmn->uar);
 clean_pd:
@@ -116,8 +136,7 @@ static int dr_domain_init_resources(struct mlx5dr_domain *dmn)
 static void dr_domain_uninit_resources(struct mlx5dr_domain *dmn)
 {
 	mlx5dr_send_ring_free(dmn, dmn->send_ring);
-	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
-	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
+	dr_domain_uninit_mem_resources(dmn);
 	mlx5_put_uars_page(dmn->mdev, dmn->uar);
 	mlx5_core_dealloc_pd(dmn->mdev, dmn->pdn);
 }
Signature · 1 line
2.37.3
#9 lore raw

PATCH v2 8/14 net/mlx5: DR, In rehash write the line in the entry immediately

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Don't wait for the whole table to be ready - write each row immediately. This way we save allocations of the ste_send_info structure and improve performance.

---
 .../net/ethernet/mellanox/mlx5/core/steering/dr_rule.c   | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c +9 -0
index 6cbc444ad791..22878dcd7c8b 100644
@@ -358,6 +358,15 @@ static int dr_rule_rehash_copy_htbl(struct mlx5dr_matcher *matcher,
 						    update_list);
 		if (err)
 			goto clean_copy;
+
+		/* In order to decrease the number of allocated ste_send_info
+		 * structs, send the current table row now.
+		 */
+		err = dr_rule_send_update_list(update_list, matcher->tbl->dmn, false);
+		if (err) {
+			mlx5dr_dbg(matcher->tbl->dmn, "Failed updating table to HW\n");
+			goto clean_copy;
+		}
 	}
 
 clean_copy:
Signature · 1 line
2.37.3
#10 lore raw

PATCH v2 9/14 net/mlx5: DR, Manage STE send info objects in pool

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Instead of allocating/freeing send info objects dynamically, manage them in pool. The number of send info objects doesn't depend on rules, so after pre-populating the pool with an initial batch of send info objects, the pool is not expected to grow.
This way we save alloc/free during writing STEs to ICM, which can sometimes take up to 40msec.

---
 .../mellanox/mlx5/core/steering/dr_domain.c   |   9 ++
 .../mellanox/mlx5/core/steering/dr_rule.c     |  43 +++---
 .../mellanox/mlx5/core/steering/dr_send.c     | 131 ++++++++++++++++++
 .../mellanox/mlx5/core/steering/dr_types.h    |   9 ++
 4 files changed, 173 insertions(+), 19 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +9 -0
index 543d655ae3b6..3dc784b22741 100644
@@ -73,8 +73,16 @@ static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
 		goto free_ste_icm_pool;
 	}
 
+	ret = mlx5dr_send_info_pool_create(dmn);
+	if (ret) {
+		mlx5dr_err(dmn, "Couldn't create send info pool\n");
+		goto free_action_icm_pool;
+	}
+
 	return 0;
 
+free_action_icm_pool:
+	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
 free_ste_icm_pool:
 	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
 	return ret;
@@ -82,6 +90,7 @@ static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
 
 static void dr_domain_uninit_mem_resources(struct mlx5dr_domain *dmn)
 {
+	mlx5dr_send_info_pool_destroy(dmn);
 	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
 	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
 }
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c +24 -19

139 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c +131 -0

143 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +9 -0
index 1777a1e508e7..244685453a27 100644
@@ -146,6 +146,7 @@ struct mlx5dr_cmd_caps;
 struct mlx5dr_rule_rx_tx;
 struct mlx5dr_matcher_rx_tx;
 struct mlx5dr_ste_ctx;
+struct mlx5dr_send_info_pool;
 
 struct mlx5dr_ste {
 	/* refcount: indicates the num of rules that using this ste */
@@ -912,6 +913,8 @@ struct mlx5dr_domain {
 	refcount_t refcount;
 	struct mlx5dr_icm_pool *ste_icm_pool;
 	struct mlx5dr_icm_pool *action_icm_pool;
+	struct mlx5dr_send_info_pool *send_info_pool_rx;
+	struct mlx5dr_send_info_pool *send_info_pool_tx;
 	struct mlx5dr_send_ring *send_ring;
 	struct mlx5dr_domain_info info;
 	struct xarray csum_fts_xa;
@@ -1404,6 +1407,12 @@ int mlx5dr_send_postsend_formatted_htbl(struct mlx5dr_domain *dmn,
 int mlx5dr_send_postsend_action(struct mlx5dr_domain *dmn,
 				struct mlx5dr_action *action);
 
+int mlx5dr_send_info_pool_create(struct mlx5dr_domain *dmn);
+void mlx5dr_send_info_pool_destroy(struct mlx5dr_domain *dmn);
+struct mlx5dr_ste_send_info *mlx5dr_send_info_alloc(struct mlx5dr_domain *dmn,
+						    enum mlx5dr_domain_nic_type nic_type);
+void mlx5dr_send_info_free(struct mlx5dr_ste_send_info *ste_send_info);
+
 struct mlx5dr_cmd_ft_info {
 	u32 id;
 	u16 vport;
Signature · 1 line
2.37.3
#11 lore raw

PATCH v2 10/14 net/mlx5: DR, Allocate icm_chunks from their own slab allocator

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

SW steering allocates/frees lots of icm_chunk structs. To make this more efficiently, create a separate kmem_cache and allocate these chunks from this allocator.
By doing this we observe that the alloc/free "hiccups" frequency has become much lower, which allows for a more steady rule insersion rate.

---
 .../mellanox/mlx5/core/steering/dr_domain.c       | 15 ++++++++++++++-
 .../mellanox/mlx5/core/steering/dr_icm_pool.c     | 11 +++++++++--
 .../mellanox/mlx5/core/steering/dr_types.h        |  1 +
 3 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +14 -1
index 3dc784b22741..3fbcb2883a26 100644
@@ -60,10 +60,19 @@ static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
 {
 	int ret;
 
+	dmn->chunks_kmem_cache = kmem_cache_create("mlx5_dr_chunks",
+						   sizeof(struct mlx5dr_icm_chunk), 0,
+						   SLAB_HWCACHE_ALIGN, NULL);
+	if (!dmn->chunks_kmem_cache) {
+		mlx5dr_err(dmn, "Couldn't create chunks kmem_cache\n");
+		return -ENOMEM;
+	}
+
 	dmn->ste_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_STE);
 	if (!dmn->ste_icm_pool) {
 		mlx5dr_err(dmn, "Couldn't get icm memory\n");
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto free_chunks_kmem_cache;
 	}
 
 	dmn->action_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_MODIFY_ACTION);
@@ -85,6 +94,9 @@ static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
 	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
 free_ste_icm_pool:
 	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
+free_chunks_kmem_cache:
+	kmem_cache_destroy(dmn->chunks_kmem_cache);
+
 	return ret;
 }
 
@@ -93,6 +105,7 @@ static void dr_domain_uninit_mem_resources(struct mlx5dr_domain *dmn)
 	mlx5dr_send_info_pool_destroy(dmn);
 	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
 	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
+	kmem_cache_destroy(dmn->chunks_kmem_cache);
 }
 
 static int dr_domain_init_resources(struct mlx5dr_domain *dmn)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +9 -2
index 7ca1ef073f55..be02546a7de0 100644
@@ -9,6 +9,8 @@ struct mlx5dr_icm_pool {
 	enum mlx5dr_icm_type icm_type;
 	enum mlx5dr_icm_chunk_size max_log_chunk_sz;
 	struct mlx5dr_domain *dmn;
+	struct kmem_cache *chunks_kmem_cache;
+
 	/* memory management */
 	struct mutex mutex; /* protect the ICM pool and ICM buddy */
 	struct list_head buddy_mem_list;
@@ -193,10 +195,13 @@ static void dr_icm_chunk_ste_init(struct mlx5dr_icm_chunk *chunk, int offset)
 
 static void dr_icm_chunk_destroy(struct mlx5dr_icm_chunk *chunk)
 {
+	struct kmem_cache *chunks_cache =
+		chunk->buddy_mem->pool->chunks_kmem_cache;
+
 	chunk->buddy_mem->used_memory -= mlx5dr_icm_pool_get_chunk_byte_size(chunk);
 	list_del(&chunk->chunk_list);
 
-	kvfree(chunk);
+	kmem_cache_free(chunks_cache, chunk);
 }
 
 static int dr_icm_buddy_init_ste_cache(struct mlx5dr_icm_buddy_mem *buddy)
@@ -302,10 +307,11 @@ dr_icm_chunk_create(struct mlx5dr_icm_pool *pool,
 		    struct mlx5dr_icm_buddy_mem *buddy_mem_pool,
 		    unsigned int seg)
 {
+	struct kmem_cache *chunks_cache = buddy_mem_pool->pool->chunks_kmem_cache;
 	struct mlx5dr_icm_chunk *chunk;
 	int offset;
 
-	chunk = kvzalloc(sizeof(*chunk), GFP_KERNEL);
+	chunk = kmem_cache_alloc(chunks_cache, GFP_KERNEL);
 	if (!chunk)
 		return NULL;
 
@@ -482,6 +488,7 @@ struct mlx5dr_icm_pool *mlx5dr_icm_pool_create(struct mlx5dr_domain *dmn,
 	pool->dmn = dmn;
 	pool->icm_type = icm_type;
 	pool->max_log_chunk_sz = max_log_chunk_sz;
+	pool->chunks_kmem_cache = dmn->chunks_kmem_cache;
 
 	INIT_LIST_HEAD(&pool->buddy_mem_list);
 
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +1 -0
index 244685453a27..4f38f0f5b352 100644
@@ -915,6 +915,7 @@ struct mlx5dr_domain {
 	struct mlx5dr_icm_pool *action_icm_pool;
 	struct mlx5dr_send_info_pool *send_info_pool_rx;
 	struct mlx5dr_send_info_pool *send_info_pool_tx;
+	struct kmem_cache *chunks_kmem_cache;
 	struct mlx5dr_send_ring *send_ring;
 	struct mlx5dr_domain_info info;
 	struct xarray csum_fts_xa;
Signature · 1 line
2.37.3
#12 lore raw

PATCH v2 11/14 net/mlx5: DR, Allocate htbl from its own slab allocator

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

SW steering allocates/frees lots of htbl structs. Create a separate kmem_cache and allocate htbls from this allocator.

---
 .../mellanox/mlx5/core/steering/dr_domain.c        | 14 +++++++++++++-
 .../mellanox/mlx5/core/steering/dr_icm_pool.c      | 10 ++++++++++
 .../ethernet/mellanox/mlx5/core/steering/dr_ste.c  | 12 +++++++++---
 .../mellanox/mlx5/core/steering/dr_types.h         |  4 ++++
 4 files changed, 36 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +13 -1
index 3fbcb2883a26..9a9836218c8e 100644
@@ -68,11 +68,20 @@ static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
 		return -ENOMEM;
 	}
 
+	dmn->htbls_kmem_cache = kmem_cache_create("mlx5_dr_htbls",
+						  sizeof(struct mlx5dr_ste_htbl), 0,
+						  SLAB_HWCACHE_ALIGN, NULL);
+	if (!dmn->htbls_kmem_cache) {
+		mlx5dr_err(dmn, "Couldn't create hash tables kmem_cache\n");
+		ret = -ENOMEM;
+		goto free_chunks_kmem_cache;
+	}
+
 	dmn->ste_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_STE);
 	if (!dmn->ste_icm_pool) {
 		mlx5dr_err(dmn, "Couldn't get icm memory\n");
 		ret = -ENOMEM;
-		goto free_chunks_kmem_cache;
+		goto free_htbls_kmem_cache;
 	}
 
 	dmn->action_icm_pool = mlx5dr_icm_pool_create(dmn, DR_ICM_TYPE_MODIFY_ACTION);
@@ -94,6 +103,8 @@ static int dr_domain_init_mem_resources(struct mlx5dr_domain *dmn)
 	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
 free_ste_icm_pool:
 	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
+free_htbls_kmem_cache:
+	kmem_cache_destroy(dmn->htbls_kmem_cache);
 free_chunks_kmem_cache:
 	kmem_cache_destroy(dmn->chunks_kmem_cache);
 
@@ -105,6 +116,7 @@ static void dr_domain_uninit_mem_resources(struct mlx5dr_domain *dmn)
 	mlx5dr_send_info_pool_destroy(dmn);
 	mlx5dr_icm_pool_destroy(dmn->action_icm_pool);
 	mlx5dr_icm_pool_destroy(dmn->ste_icm_pool);
+	kmem_cache_destroy(dmn->htbls_kmem_cache);
 	kmem_cache_destroy(dmn->chunks_kmem_cache);
 }
 
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +10 -0
index be02546a7de0..ca91a0211a5c 100644
@@ -470,6 +470,16 @@ void mlx5dr_icm_free_chunk(struct mlx5dr_icm_chunk *chunk)
 	mutex_unlock(&pool->mutex);
 }
 
+struct mlx5dr_ste_htbl *mlx5dr_icm_pool_alloc_htbl(struct mlx5dr_icm_pool *pool)
+{
+	return kmem_cache_alloc(pool->dmn->htbls_kmem_cache, GFP_KERNEL);
+}
+
+void mlx5dr_icm_pool_free_htbl(struct mlx5dr_icm_pool *pool, struct mlx5dr_ste_htbl *htbl)
+{
+	kmem_cache_free(pool->dmn->htbls_kmem_cache, htbl);
+}
+
 struct mlx5dr_icm_pool *mlx5dr_icm_pool_create(struct mlx5dr_domain *dmn,
 					       enum mlx5dr_icm_type icm_type)
 {
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c +9 -3
index 09ebd3088857..9e19a8dc9022 100644
@@ -491,7 +491,7 @@ struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
 	u32 num_entries;
 	int i;
 
-	htbl = kzalloc(sizeof(*htbl), GFP_KERNEL);
+	htbl = mlx5dr_icm_pool_alloc_htbl(pool);
 	if (!htbl)
 		return NULL;
 
@@ -503,6 +503,9 @@ struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
 	htbl->lu_type = lu_type;
 	htbl->byte_mask = byte_mask;
 	htbl->refcount = 0;
+	htbl->pointing_ste = NULL;
+	htbl->ctrl.num_of_valid_entries = 0;
+	htbl->ctrl.num_of_collisions = 0;
 	num_entries = mlx5dr_icm_pool_get_chunk_num_of_entries(chunk);
 
 	for (i = 0; i < num_entries; i++) {
@@ -517,17 +520,20 @@ struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
 	return htbl;
 
 out_free_htbl:
-	kfree(htbl);
+	mlx5dr_icm_pool_free_htbl(pool, htbl);
 	return NULL;
 }
 
 int mlx5dr_ste_htbl_free(struct mlx5dr_ste_htbl *htbl)
 {
+	struct mlx5dr_icm_pool *pool = htbl->chunk->buddy_mem->pool;
+
 	if (htbl->refcount)
 		return -EBUSY;
 
 	mlx5dr_icm_free_chunk(htbl->chunk);
-	kfree(htbl);
+	mlx5dr_icm_pool_free_htbl(pool, htbl);
+
 	return 0;
 }
 
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +4 -0
index 4f38f0f5b352..b645c0ab9a72 100644
@@ -916,6 +916,7 @@ struct mlx5dr_domain {
 	struct mlx5dr_send_info_pool *send_info_pool_rx;
 	struct mlx5dr_send_info_pool *send_info_pool_tx;
 	struct kmem_cache *chunks_kmem_cache;
+	struct kmem_cache *htbls_kmem_cache;
 	struct mlx5dr_send_ring *send_ring;
 	struct mlx5dr_domain_info info;
 	struct xarray csum_fts_xa;
@@ -1162,6 +1163,9 @@ u32 mlx5dr_icm_pool_get_chunk_num_of_entries(struct mlx5dr_icm_chunk *chunk);
 u32 mlx5dr_icm_pool_get_chunk_byte_size(struct mlx5dr_icm_chunk *chunk);
 u8 *mlx5dr_ste_get_hw_ste(struct mlx5dr_ste *ste);
 
+struct mlx5dr_ste_htbl *mlx5dr_icm_pool_alloc_htbl(struct mlx5dr_icm_pool *pool);
+void mlx5dr_icm_pool_free_htbl(struct mlx5dr_icm_pool *pool, struct mlx5dr_ste_htbl *htbl);
+
 static inline int
 mlx5dr_icm_pool_dm_type_to_entry_size(enum mlx5dr_icm_type icm_type)
 {
Signature · 1 line
2.37.3
#13 lore raw

PATCH v2 12/14 net/mlx5: DR, Lower sync threshold for ICM hot memory

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

Instead of hiding the math in the code, define a value that sets the fraction of allowed hot memory of ICM pool.
Set the threshold for sync of ICM hot chunks to 1/4 of the pool instead of 1/2 of the pool. Although we will have more syncs, each sync will be shorter and will help with insertion rate stability.

---
 .../net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +4 -2
index ca91a0211a5c..286b7ce6bc0b 100644
@@ -4,6 +4,7 @@
 #include "dr_types.h"
 
 #define DR_ICM_MODIFY_HDR_ALIGN_BASE 64
+#define DR_ICM_POOL_HOT_MEMORY_FRACTION 4
 
 struct mlx5dr_icm_pool {
 	enum mlx5dr_icm_type icm_type;
@@ -337,10 +338,11 @@ static bool dr_icm_pool_is_sync_required(struct mlx5dr_icm_pool *pool)
 {
 	int allow_hot_size;
 
-	/* sync when hot memory reaches half of the pool size */
+	/* sync when hot memory reaches a certain fraction of the pool size */
 	allow_hot_size =
 		mlx5dr_icm_pool_chunk_size_to_byte(pool->max_log_chunk_sz,
-						   pool->icm_type) / 2;
+						   pool->icm_type) /
+		DR_ICM_POOL_HOT_MEMORY_FRACTION;
 
 	return pool->hot_memory_size > allow_hot_size;
 }
Signature · 1 line
2.37.3
#14 lore raw

PATCH v2 13/14 net/mlx5: DR, Keep track of hot ICM chunks in an array instead of list

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

When ICM chunk is freed, it might still be accessed by HW until we do sync with HW. This sync is expensive operation, so we don't do it often. Instead, when the chunk is freed, it is moved to the buddy's "hot memory" list. Once sync is done, we traverse the hot list and finally free all the chunks.

It appears that traversing a long list takes unusually long time due to cache misses on many entries, which causes a big "hiccup" during rule insertion.

This patch deals with this issue the following way:
- Move hot chunks list from buddy to pool, so that the pool will keep track of all its hot memory.
- Replace the list with pre-allocated array on the memory pool struct, and store only the information that is needed to later free this chunk in its buddy allocator.
This cost additional memory for the array that is dynamically allocated, but it allows not to save long list of hot chunks, so at peak times it actually saves memory due to the fact that each array entry is much smaller than the chunk struct.

This way an overhead of traversing the long list is virtually removed:
the loop of freeing hot chunks takes ~27 msec instead of ~70 msec, where most of it are the actual freeing activities.

---
 .../mellanox/mlx5/core/steering/dr_buddy.c    |  1 -
 .../mellanox/mlx5/core/steering/dr_icm_pool.c | 85 +++++++++++++++----
 .../mellanox/mlx5/core/steering/dr_types.h    |  1 +
 .../mellanox/mlx5/core/steering/mlx5dr.h      |  6 --
 4 files changed, 71 insertions(+), 22 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_buddy.c +0 -1
index 7df11a019df9..7e30dc64c10c 100644
@@ -16,7 +16,6 @@ int mlx5dr_buddy_init(struct mlx5dr_icm_buddy_mem *buddy,
 
 	INIT_LIST_HEAD(&buddy->list_node);
 	INIT_LIST_HEAD(&buddy->used_list);
-	INIT_LIST_HEAD(&buddy->hot_list);
 
 	buddy->bitmap = kcalloc(buddy->max_order + 1,
 				sizeof(*buddy->bitmap),
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +70 -15

151 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +1 -0
index b645c0ab9a72..bd2c3073591e 100644
@@ -147,6 +147,7 @@ struct mlx5dr_rule_rx_tx;
 struct mlx5dr_matcher_rx_tx;
 struct mlx5dr_ste_ctx;
 struct mlx5dr_send_info_pool;
+struct mlx5dr_icm_hot_chunk;
 
 struct mlx5dr_ste {
 	/* refcount: indicates the num of rules that using this ste */
drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +0 -6
index 226a0d7bb06d..674efb3607b1 100644
@@ -168,12 +168,6 @@ struct mlx5dr_icm_buddy_mem {
 	struct list_head	used_list;
 	u64			used_memory;
 
-	/* Hardware may be accessing this memory but at some future,
-	 * undetermined time, it might cease to do so.
-	 * sync_ste command sets them free.
-	 */
-	struct list_head	hot_list;
-
 	/* Memory optimisation */
 	struct mlx5dr_ste	*ste_arr;
 	struct list_head	*miss_list;
Signature · 1 line
2.37.3
#15 lore raw

PATCH v2 14/14 net/mlx5: DR, Remove the buddy used_list

In reply to Saeed Mahameed

From: Yevgeny Kliteynik <[email protected]>

No need to have the used_list - we don't need to keep track of the used chunks, we only need to know the amount of used memory.

---
 .../mellanox/mlx5/core/steering/dr_buddy.c    |  1 -
 .../mellanox/mlx5/core/steering/dr_icm_pool.c | 50 +++++--------------
 .../mellanox/mlx5/core/steering/dr_types.h    |  1 -
 .../mellanox/mlx5/core/steering/mlx5dr.h      |  3 +-
 4 files changed, 13 insertions(+), 42 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_buddy.c +0 -1
index 7e30dc64c10c..fe228d948b47 100644
@@ -15,7 +15,6 @@ int mlx5dr_buddy_init(struct mlx5dr_icm_buddy_mem *buddy,
 	buddy->max_order = max_order;
 
 	INIT_LIST_HEAD(&buddy->list_node);
-	INIT_LIST_HEAD(&buddy->used_list);
 
 	buddy->bitmap = kcalloc(buddy->max_order + 1,
 				sizeof(*buddy->bitmap),
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c +12 -38

93 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +0 -1
index bd2c3073591e..41a37b9ac98b 100644
@@ -1111,7 +1111,6 @@ int mlx5dr_rule_get_reverse_rule_members(struct mlx5dr_ste **ste_arr,
 
 struct mlx5dr_icm_chunk {
 	struct mlx5dr_icm_buddy_mem *buddy_mem;
-	struct list_head chunk_list;
 
 	/* indicates the index of this chunk in the whole memory,
 	 * used for deleting the chunk from the buddy
drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +1 -2
index 674efb3607b1..84ed77763b21 100644
@@ -164,8 +164,7 @@ struct mlx5dr_icm_buddy_mem {
 	struct mlx5dr_icm_mr	*icm_mr;
 	struct mlx5dr_icm_pool	*pool;
 
-	/* This is the list of used chunks. HW may be accessing this memory */
-	struct list_head	used_list;
+	/* Amount of memory in used chunks - HW may be accessing this memory */
 	u64			used_memory;
 
 	/* Memory optimisation */
Signature · 1 line
2.37.3
#2 lore raw

Re: [net-next V2 01/14] net/mlx5: DR, In destroy flow, free resources even if FW command failed

In reply to Saeed Mahameed
This series was applied to netdev/net-next.git (master) by Saeed Mahameed <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Saeed Mahameed <[email protected]>:

Quoted 10 lines · On Thu, 27 Oct 2022 15:56:30 +0100 you wrote:

From: Yevgeny Kliteynik <[email protected]>

Otherwise resources will never be freed and refcount will not be decreased.

[...]

Here is the summary with links:
- [net-next,V2,01/14] net/mlx5: DR, In destroy flow, free resources even if FW command failed

    https://git.kernel.org/netdev/net-next/c/14335d54e721
  - [net-next,V2,02/14] net/mlx5: DR, Fix the SMFS sync_steering for fast teardown
    https://git.kernel.org/netdev/net-next/c/c4193a1281ac
  - [net-next,V2,03/14] net/mlx5: DR, Check device state when polling CQ
    https://git.kernel.org/netdev/net-next/c/5fd08f653991
  - [net-next,V2,04/14] net/mlx5: DR, Remove unneeded argument from dr_icm_chunk_destroy
    https://git.kernel.org/netdev/net-next/c/d277b55f0fa8
  - [net-next,V2,05/14] net/mlx5: DR, For short chains of STEs, avoid allocating ste_arr dynamically
    https://git.kernel.org/netdev/net-next/c/b9b81e1e9382
  - [net-next,V2,06/14] net/mlx5: DR, Initialize chunk's ste_arrays at chunk creation
    https://git.kernel.org/netdev/net-next/c/06ab4a4089d4
  - [net-next,V2,07/14] net/mlx5: DR, Handle domain memory resources init/uninit separately
    https://git.kernel.org/netdev/net-next/c/183a6706a07e
  - [net-next,V2,08/14] net/mlx5: DR, In rehash write the line in the entry immediately
    https://git.kernel.org/netdev/net-next/c/1bea2dc7f4ff
  - [net-next,V2,09/14] net/mlx5: DR, Manage STE send info objects in pool
    https://git.kernel.org/netdev/net-next/c/17b56073a066
  - [net-next,V2,10/14] net/mlx5: DR, Allocate icm_chunks from their own slab allocator
    https://git.kernel.org/netdev/net-next/c/fd785e5213f0
  - [net-next,V2,11/14] net/mlx5: DR, Allocate htbl from its own slab allocator
    https://git.kernel.org/netdev/net-next/c/fb628b71fb2a
  - [net-next,V2,12/14] net/mlx5: DR, Lower sync threshold for ICM hot memory
    https://git.kernel.org/netdev/net-next/c/133ea373a043
  - [net-next,V2,13/14] net/mlx5: DR, Keep track of hot ICM chunks in an array instead of list
    https://git.kernel.org/netdev/net-next/c/4519fc45beeb
  - [net-next,V2,14/14] net/mlx5: DR, Remove the buddy used_list
    https://git.kernel.org/netdev/net-next/c/edaea001442a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html