MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_realloc

Function mlx5_realloc

dpdk/drivers/common/mlx5/mlx5_malloc.c:208–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void *
209mlx5_realloc(void *addr, uint32_t flags, size_t size, unsigned int align,
210 int socket)
211{
212 void *new_addr;
213 bool rte_mem;
214
215 /* Allocate directly if old memory address is NULL. */
216 if (!addr)
217 return mlx5_malloc(flags, size, align, socket);
218 /* Get the memory type. */
219 if (flags & MLX5_MEM_RTE)
220 rte_mem = true;
221 else if (flags & MLX5_MEM_SYS)
222 rte_mem = false;
223 else
224 rte_mem = mlx5_sys_mem.enable ? false : true;
225 /* Check if old memory and to be allocated memory are the same type. */
226 if (rte_mem != mlx5_mem_is_rte(addr)) {
227 DRV_LOG(ERR, "Couldn't reallocate to different memory type.");
228 return NULL;
229 }
230 /* Allocate memory from rte memory. */
231 if (rte_mem) {
232 new_addr = rte_realloc_socket(addr, size, align, socket);
233 mlx5_mem_update_msl(new_addr);
234#ifdef RTE_LIBRTE_MLX5_DEBUG
235 if (new_addr)
236 __atomic_fetch_add(&mlx5_sys_mem.realloc_rte, 1,
237 __ATOMIC_RELAXED);
238#endif
239 return new_addr;
240 }
241 /* Align is not supported for system memory. */
242 if (align) {
243 DRV_LOG(ERR, "Couldn't reallocate with alignment");
244 return NULL;
245 }
246 new_addr = realloc(addr, size);
247#ifdef RTE_LIBRTE_MLX5_DEBUG
248 if (new_addr)
249 __atomic_fetch_add(&mlx5_sys_mem.realloc_sys, 1,
250 __ATOMIC_RELAXED);
251#endif
252 return new_addr;
253}
254
255void
256mlx5_free(void *addr)

Callers 4

mlx5_dev_configureFunction · 0.85
mlx5_rss_hash_updateFunction · 0.85
mr_btree_expandFunction · 0.85

Calls 5

mlx5_mallocFunction · 0.85
mlx5_mem_is_rteFunction · 0.85
rte_realloc_socketFunction · 0.85
mlx5_mem_update_mslFunction · 0.85
reallocFunction · 0.50

Tested by

no test coverage detected