* Release resources of detached MR having no online entry. * * @param share_cache * Pointer to a global shared MR cache. */
| 519 | * Pointer to a global shared MR cache. |
| 520 | */ |
| 521 | static void |
| 522 | mlx5_mr_garbage_collect(struct mlx5_mr_share_cache *share_cache) |
| 523 | { |
| 524 | struct mlx5_mr *mr_next; |
| 525 | struct mlx5_mr_list free_list = LIST_HEAD_INITIALIZER(free_list); |
| 526 | |
| 527 | /* Must be called from the primary process. */ |
| 528 | MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY); |
| 529 | /* |
| 530 | * MR can't be freed with holding the lock because rte_free() could call |
| 531 | * memory free callback function. This will be a deadlock situation. |
| 532 | */ |
| 533 | rte_rwlock_write_lock(&share_cache->rwlock); |
| 534 | /* Detach the whole free list and release it after unlocking. */ |
| 535 | free_list = share_cache->mr_free_list; |
| 536 | LIST_INIT(&share_cache->mr_free_list); |
| 537 | rte_rwlock_write_unlock(&share_cache->rwlock); |
| 538 | /* Release resources. */ |
| 539 | mr_next = LIST_FIRST(&free_list); |
| 540 | while (mr_next != NULL) { |
| 541 | struct mlx5_mr *mr = mr_next; |
| 542 | |
| 543 | mr_next = LIST_NEXT(mr, mr); |
| 544 | mlx5_mr_free(mr, share_cache->dereg_mr_cb); |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | /* Called during rte_memseg_contig_walk() by mlx5_mr_create(). */ |
| 549 | static int |
no test coverage detected