| 448 | } |
| 449 | |
| 450 | int |
| 451 | rte_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 | |
| 493 | unlock: |
| 494 | rte_mcfg_mem_write_unlock(); |
| 495 | |
| 496 | return ret; |
| 497 | } |
| 498 | |
| 499 | static int |
| 500 | sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach) |