Skip to contentSkip to conversation

common/mlx5: fix memory allocation debug stats

PATCH In review Alexander Kozyrev 2 participants 2 messages Oct 28, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/mlx5: fix memory allocation debug stats

Fix compilation issue for memory allocation stats in case of the RTE_LIBRTE_MLX5_DEBUG is enabled. The mlx5_sys_mem is static and its members should be accessed via member operator, not a pointer.

Fixes 1f34e138f8 ("common/mlx5: use C11 atomics for memory allocation")
---
 drivers/common/mlx5/mlx5_malloc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/common/mlx5/mlx5_malloc.c +6 -6
index f64c15fceb..5a3267f730 100644
@@ -187,7 +187,7 @@ mlx5_malloc(uint32_t flags, size_t size, unsigned int align, int socket)
 		mlx5_mem_update_msl(addr);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 		if (addr)
-			__atomic_add_fetch(&mlx5_sys_mem->malloc_rte, 1,
+			__atomic_add_fetch(&mlx5_sys_mem.malloc_rte, 1,
 					   __ATOMIC_RELAXED);
 #endif
 		return addr;
@@ -201,7 +201,7 @@ mlx5_malloc(uint32_t flags, size_t size, unsigned int align, int socket)
 		addr = malloc(size);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 	if (addr)
-		__atomic_add_fetch(&mlx5_sys_mem->malloc_sys, 1,
+		__atomic_add_fetch(&mlx5_sys_mem.malloc_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
 	return addr;
@@ -235,7 +235,7 @@ mlx5_realloc(void *addr, uint32_t flags, size_t size, unsigned int align,
 		mlx5_mem_update_msl(new_addr);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 		if (new_addr)
-			__atomic_add_fetch(&mlx5_sys_mem->realloc_rte, 1,
+			__atomic_add_fetch(&mlx5_sys_mem.realloc_rte, 1,
 					   __ATOMIC_RELAXED);
 #endif
 		return new_addr;
@@ -248,7 +248,7 @@ mlx5_realloc(void *addr, uint32_t flags, size_t size, unsigned int align,
 	new_addr = realloc(addr, size);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 	if (new_addr)
-		__atomic_add_fetch(&mlx5_sys_mem->realloc_sys, 1,
+		__atomic_add_fetch(&mlx5_sys_mem.realloc_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
 	return new_addr;
@@ -261,13 +261,13 @@ mlx5_free(void *addr)
 		return;
 	if (!mlx5_mem_is_rte(addr)) {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-		__atomic_add_fetch(&mlx5_sys_mem->free_sys, 1,
+		__atomic_add_fetch(&mlx5_sys_mem.free_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
 		free(addr);
 	} else {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-		__atomic_add_fetch(&mlx5_sys_mem->free_rte, 1,
+		__atomic_add_fetch(&mlx5_sys_mem.free_rte, 1,
 				   __ATOMIC_RELAXED);
 #endif
 		rte_free(addr);
Signature · 1 line
2.24.1
#1 lore raw

Hi,

Quoted 84 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, October 28, 2020 8:21 PM
To: [email protected]
Cc: Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH] common/mlx5: fix memory allocation debug stats

Fix compilation issue for memory allocation stats in case of the RTE_LIBRTE_MLX5_DEBUG is enabled. The mlx5_sys_mem is static and its members should be accessed via member operator, not a pointer.

Fixes 1f34e138f8 ("common/mlx5: use C11 atomics for memory allocation")
---
 drivers/common/mlx5/mlx5_malloc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/common/mlx5/mlx5_malloc.c +1 -1
index f64c15fceb..5a3267f730 100644
@@ -187,7 +187,7 @@ mlx5_malloc(uint32_t flags, size_t size, unsigned int
 align, int socket)
 		mlx5_mem_update_msl(addr);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 		if (addr)
-			__atomic_add_fetch(&mlx5_sys_mem->malloc_rte,
 1,
+			__atomic_add_fetch(&mlx5_sys_mem.malloc_rte, 1,
 					   __ATOMIC_RELAXED);

#endif

drivers/common/mlx5/mlx5_malloc.c +1 -1
 		return addr;
@@ -201,7 +201,7 @@ mlx5_malloc(uint32_t flags, size_t size, unsigned int
 align, int socket)
 		addr = malloc(size);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 	if (addr)
-		__atomic_add_fetch(&mlx5_sys_mem->malloc_sys, 1,
+		__atomic_add_fetch(&mlx5_sys_mem.malloc_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
drivers/common/mlx5/mlx5_malloc.c +1 -1
 	return addr;
@@ -235,7 +235,7 @@ mlx5_realloc(void *addr, uint32_t flags, size_t size,
 unsigned int align,
 		mlx5_mem_update_msl(new_addr);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 		if (new_addr)
-			__atomic_add_fetch(&mlx5_sys_mem->realloc_rte,
 1,
+			__atomic_add_fetch(&mlx5_sys_mem.realloc_rte,
 1,
drivers/common/mlx5/mlx5_malloc.c +1 -1
 					   __ATOMIC_RELAXED);
 #endif
 		return new_addr;
@@ -248,7 +248,7 @@ mlx5_realloc(void *addr, uint32_t flags, size_t size,
 unsigned int align,
 	new_addr = realloc(addr, size);
 #ifdef RTE_LIBRTE_MLX5_DEBUG
 	if (new_addr)
-		__atomic_add_fetch(&mlx5_sys_mem->realloc_sys, 1,
+		__atomic_add_fetch(&mlx5_sys_mem.realloc_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
drivers/common/mlx5/mlx5_malloc.c +2 -3
 	return new_addr;
@@ -261,13 +261,13 @@ mlx5_free(void *addr)
 		return;
 	if (!mlx5_mem_is_rte(addr)) {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-		__atomic_add_fetch(&mlx5_sys_mem->free_sys, 1,
+		__atomic_add_fetch(&mlx5_sys_mem.free_sys, 1,
 				   __ATOMIC_RELAXED);
 #endif
 		free(addr);
 	} else {
 #ifdef RTE_LIBRTE_MLX5_DEBUG
-		__atomic_add_fetch(&mlx5_sys_mem->free_rte, 1,
+		__atomic_add_fetch(&mlx5_sys_mem.free_rte, 1,
 				   __ATOMIC_RELAXED);
 #endif
 		rte_free(addr);
--
Quoted 1 line

2.24.1

Patch squashed into relevant commit in next-net-mlx,

Kindest regards,
Raslan Darawsheh