Skip to content

Commit

Permalink
RC/IFACE: added lock on rc_iface->eps access
Browse files Browse the repository at this point in the history
- added lock on access rc_iface->eps access
  • Loading branch information
Sergey Oblomov authored and evgeny-leksikov committed Dec 15, 2020
1 parent 34f62cd commit 68dc78f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/uct/ib/rc/base/rc_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ void uct_rc_iface_add_qp(uct_rc_iface_t *iface, uct_rc_ep_t *ep,
{
uct_rc_ep_t ***ptr, **memb;

ucs_spin_lock(&iface->eps_lock);
ptr = &iface->eps[qp_num >> UCT_RC_QP_TABLE_ORDER];
if (*ptr == NULL) {
*ptr = ucs_calloc(UCS_BIT(UCT_RC_QP_TABLE_MEMB_ORDER), sizeof(**ptr),
Expand All @@ -259,16 +260,19 @@ void uct_rc_iface_add_qp(uct_rc_iface_t *iface, uct_rc_ep_t *ep,
memb = &(*ptr)[qp_num & UCS_MASK(UCT_RC_QP_TABLE_MEMB_ORDER)];
ucs_assert(*memb == NULL);
*memb = ep;
ucs_spin_unlock(&iface->eps_lock);
}

void uct_rc_iface_remove_qp(uct_rc_iface_t *iface, unsigned qp_num)
{
uct_rc_ep_t **memb;

ucs_spin_lock(&iface->eps_lock);
memb = &iface->eps[qp_num >> UCT_RC_QP_TABLE_ORDER]
[qp_num & UCS_MASK(UCT_RC_QP_TABLE_MEMB_ORDER)];
ucs_assert(*memb != NULL);
*memb = NULL;
ucs_spin_unlock(&iface->eps_lock);
}

ucs_status_t uct_rc_iface_flush(uct_iface_h tl_iface, unsigned flags,
Expand Down Expand Up @@ -586,11 +590,16 @@ UCS_CLASS_INIT_FUNC(uct_rc_iface_t, uct_rc_iface_ops_t *ops, uct_md_h md,
goto err;
}

status = ucs_spinlock_init(&self->eps_lock, 0);
if (status != UCS_OK) {
goto err;
}

/* Create RX buffers mempool */
status = uct_ib_iface_recv_mpool_init(&self->super, &config->super,
"rc_recv_desc", &self->rx.mp);
if (status != UCS_OK) {
goto err;
goto err_destroy_eps_lock;
}

/* Create TX buffers mempool */
Expand Down Expand Up @@ -672,6 +681,8 @@ UCS_CLASS_INIT_FUNC(uct_rc_iface_t, uct_rc_iface_ops_t *ops, uct_md_h md,
ucs_mpool_cleanup(&self->tx.mp, 1);
err_destroy_rx_mp:
ucs_mpool_cleanup(&self->rx.mp, 1);
err_destroy_eps_lock:
ucs_spinlock_destroy(&self->eps_lock);
err:
return status;
}
Expand Down Expand Up @@ -709,6 +720,7 @@ static UCS_CLASS_CLEANUP_FUNC(uct_rc_iface_t)

UCS_STATS_NODE_FREE(self->stats);

ucs_spinlock_destroy(&self->eps_lock);
ops->cleanup_rx(self);
uct_rc_iface_tx_ops_cleanup(self);
ucs_mpool_cleanup(&self->tx.mp, 1);
Expand Down
1 change: 1 addition & 0 deletions src/uct/ib/rc/base/rc_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ struct uct_rc_iface {
UCS_STATS_NODE_DECLARE(stats)

uct_rc_ep_t **eps[UCT_RC_QP_TABLE_SIZE];
ucs_spinlock_t eps_lock;
ucs_list_link_t ep_list;
ucs_list_link_t ep_gc_list;
ucs_spinlock_t ep_list_lock;
Expand Down

0 comments on commit 68dc78f

Please sign in to comment.