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

Function rte_malloc_heap_memory_remove

dpdk/lib/eal/common/rte_malloc.c:450–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448}
449
450int
451rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len)
452{
453 struct malloc_heap *heap = NULL;
454 struct rte_memseg_list *msl;
455 int ret;
456
457 if (heap_name == NULL || va_addr == NULL || len == 0 ||
458 strnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) == 0 ||
459 strnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) ==
460 RTE_HEAP_NAME_MAX_LEN) {
461 rte_errno = EINVAL;
462 return -1;
463 }
464 rte_mcfg_mem_write_lock();
465 /* find our heap */
466 heap = find_named_heap(heap_name);
467 if (heap == NULL) {
468 rte_errno = ENOENT;
469 ret = -1;
470 goto unlock;
471 }
472 if (heap->socket_id < RTE_MAX_NUMA_NODES) {
473 /* cannot remove memory from internal heaps */
474 rte_errno = EPERM;
475 ret = -1;
476 goto unlock;
477 }
478
479 msl = malloc_heap_find_external_seg(va_addr, len);
480 if (msl == NULL) {
481 ret = -1;
482 goto unlock;
483 }
484
485 rte_spinlock_lock(&heap->lock);
486 ret = malloc_heap_remove_external_memory(heap, va_addr, len);
487 rte_spinlock_unlock(&heap->lock);
488 if (ret != 0)
489 goto unlock;
490
491 ret = malloc_heap_destroy_external_seg(msl);
492
493unlock:
494 rte_mcfg_mem_write_unlock();
495
496 return ret;
497}
498
499static int
500sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)

Callers 4

test_malloc_basicFunction · 0.85
test_reallocFunction · 0.85

Calls 9

strnlenFunction · 0.85
rte_mcfg_mem_write_lockFunction · 0.85
find_named_heapFunction · 0.85
rte_spinlock_lockFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by 4

test_malloc_basicFunction · 0.68
test_reallocFunction · 0.68