Skip to contentSkip to conversation

net/mlx5: fix indexed pool fetch overlap issue

PATCH In review Suanming Mou 2 participants 2 messages Feb 23, 2022 – Mar 2, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix indexed pool fetch overlap issue

For indexed pool with local cache, when a new trunk is allocated, half of the trunk's index was fetched to the local cache. In case of local cache size was less then half of the trunk size, memory overlap happened.

This commit adds the check of the fetch size, if local cache size is less than fetch size, adjust the fetch size to be local cache size.

Fixes d15c0946beea ("net/mlx5: add indexed pool local cache")
---
 drivers/net/mlx5/mlx5_utils.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/mlx5/mlx5_utils.c +2 -0
index be33af96fe..4115a2ad77 100644
@@ -340,6 +340,8 @@ mlx5_ipool_allocate_from_global(struct mlx5_indexed_pool *pool, int cidx)
 	/* Enqueue half of the index to global. */
 	ts_idx = mlx5_trunk_idx_offset_get(pool, trunk_idx) + 1;
 	fetch_size = trunk->free >> 1;
+	if (fetch_size > pool->cfg.per_core_cache)
+		fetch_size = trunk->free - pool->cfg.per_core_cache;
 	for (i = 0; i < fetch_size; i++)
 		lc->idx[i] = ts_idx + i;
 	lc->len = fetch_size;
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 18 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, February 23, 2022 8:26 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: Raslan Darawsheh <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] net/mlx5: fix indexed pool fetch overlap issue

For indexed pool with local cache, when a new trunk is allocated, half of the trunk's index was fetched to the local cache. In case of local cache size was less then half of the trunk size, memory overlap happened.

This commit adds the check of the fetch size, if local cache size is less than fetch size, adjust the fetch size to be local cache size.

Quoted 5 lines
Fixes d15c0946beea ("net/mlx5: add indexed pool local cache")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh