From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 554DAA034F; Fri, 15 May 2020 02:48:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 000881D9B4; Fri, 15 May 2020 02:48:28 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 4B05F1D9B1 for ; Fri, 15 May 2020 02:48:27 +0200 (CEST) From: Suanming Mou To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Cc: dev@dpdk.org, rasland@mellanox.com, dongz@mellanox.com, wisamm@mellanox.com Date: Fri, 15 May 2020 08:48:15 +0800 Message-Id: <1589503695-120616-1-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: fix Verbs counter pool allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When create the Verbs flows with counter, randomly SEGSEV will also comes. The reason is that the counter pool memory is not allocated sufficiently and initialized correctly in Verbs case. As the mlx5_flow_counter array member is moved out of the counter pool struct, the counter pool memory layout currently contain implicitly with mlx5_flow_counter, mlx5_age_param(if the pool is an age pool), mlx5_flow_counter_ext(if the pool is a none batch pool). When allocate the pool memory, the pool size should be calculated based on the pool type accordingly. Currently, for Verbs counter pool, both mlx5_flow_counter and mlx5_flow_counter_ext need to be taken into account in the pool size. And the pool type should also be initialized as CNT_POOL_TYPE_EXT. This patch add the missing size and type for the Verbs counter pool. Fixes: 8d93c830e450 ("net/mlx5: modify ext-counter memory allocation") Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 01eec31..c266e56 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -201,11 +201,12 @@ cont->n += MLX5_CNT_CONTAINER_RESIZE; } /* Allocate memory for new pool*/ - size = sizeof(*pool) + sizeof(*cnt_ext) * + size = sizeof(*pool) + (sizeof(*cnt_ext) + sizeof(*cnt)) * MLX5_COUNTERS_PER_POOL; pool = rte_calloc(__func__, 1, size, 0); if (!pool) return 0; + pool->type |= CNT_POOL_TYPE_EXT; for (i = 0; i < MLX5_COUNTERS_PER_POOL; ++i) { cnt = MLX5_POOL_GET_CNT(pool, i); TAILQ_INSERT_HEAD(&pool->counters, cnt, next); -- 1.8.3.1