Skip to content

Commit

Permalink
Merge pull request #9823 from yosefe/topic/uct-ib-check-srq-support-a…
Browse files Browse the repository at this point in the history
…nd-improve

UCT/IB: Check SRQ support and improve error messages
  • Loading branch information
yosefe authored Apr 18, 2024
2 parents 6170e54 + 4324246 commit 42b9f55
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 95 deletions.
8 changes: 8 additions & 0 deletions src/uct/ib/base/ib_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,14 @@ ucs_status_t uct_ib_device_port_check(uct_ib_device_t *dev, uint8_t port_num,
return UCS_ERR_UNREACHABLE;
}

if (flags & UCT_IB_DEVICE_FLAG_SRQ) {
if (IBV_DEV_ATTR(dev, max_srq) == 0) {
ucs_trace("%s:%d does not support SRQ", uct_ib_device_name(dev),
port_num);
return UCS_ERR_UNSUPPORTED;
}
}

if (!uct_ib_device_is_port_ib(dev, port_num) && (flags & UCT_IB_DEVICE_FLAG_LINK_IB)) {
ucs_debug("%s:%d is not IB link layer", uct_ib_device_name(dev),
port_num);
Expand Down
1 change: 1 addition & 0 deletions src/uct/ib/base/ib_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ enum {
UCT_IB_DEVICE_FLAG_MLX4_PRM = UCS_BIT(1), /* Device supports mlx4 PRM */
UCT_IB_DEVICE_FLAG_MLX5_PRM = UCS_BIT(2), /* Device supports mlx5 PRM */
UCT_IB_DEVICE_FLAG_MELLANOX = UCS_BIT(3), /* Mellanox device */
UCT_IB_DEVICE_FLAG_SRQ = UCS_BIT(4), /* Supports SRQ */
UCT_IB_DEVICE_FLAG_LINK_IB = UCS_BIT(5), /* Require only IB */
UCT_IB_DEVICE_FLAG_DC_V1 = UCS_BIT(6), /* Device supports DC ver 1 */
UCT_IB_DEVICE_FLAG_DC_V2 = UCS_BIT(7), /* Device supports DC ver 2 */
Expand Down
17 changes: 8 additions & 9 deletions src/uct/ib/base/ib_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,10 @@ ucs_status_t uct_ib_iface_create_qp(uct_ib_iface_t *iface,
#endif
if (qp == NULL) {
uct_ib_check_memlock_limit_msg(
UCS_LOG_LEVEL_ERROR,
"%s: iface %p failed to create %s QP "
dev->ibv_context, UCS_LOG_LEVEL_ERROR,
"iface %p failed to create %s QP "
"TX wr:%d sge:%d inl:%d resp:%d RX wr:%d sge:%d resp:%d",
uct_ib_device_name(dev), iface,
uct_ib_qp_type_str(attr->qp_type), attr->cap.max_send_wr,
iface, uct_ib_qp_type_str(attr->qp_type), attr->cap.max_send_wr,
attr->cap.max_send_sge, attr->cap.max_inline_data,
attr->max_inl_cqe[UCT_IB_DIR_TX], attr->cap.max_recv_wr,
attr->cap.max_recv_sge, attr->max_inl_cqe[UCT_IB_DIR_RX]);
Expand All @@ -1138,25 +1137,25 @@ ucs_status_t uct_ib_verbs_create_cq(uct_ib_iface_t *iface, uct_ib_dir_t dir,
const uct_ib_iface_init_attr_t *init_attr,
int preferred_cpu, size_t inl)
{
uct_ib_device_t *dev = uct_ib_iface_device(iface);
unsigned cq_size = uct_ib_cq_size(iface, init_attr, dir);
struct ibv_context *ibv_context = uct_ib_iface_device(iface)->ibv_context;
unsigned cq_size = uct_ib_cq_size(iface, init_attr, dir);
struct ibv_cq *cq;
#if HAVE_DECL_IBV_CREATE_CQ_EX
struct ibv_cq_init_attr_ex cq_attr = {};

uct_ib_fill_cq_attr(&cq_attr, init_attr, iface, preferred_cpu, cq_size);

cq = ibv_cq_ex_to_cq(ibv_create_cq_ex(dev->ibv_context, &cq_attr));
cq = ibv_cq_ex_to_cq(ibv_create_cq_ex(ibv_context, &cq_attr));
if (!cq && ((errno == EOPNOTSUPP) || (errno == ENOSYS)))
#endif
{
iface->config.max_inl_cqe[dir] = 0;
cq = ibv_create_cq(dev->ibv_context, cq_size, NULL, iface->comp_channel,
cq = ibv_create_cq(ibv_context, cq_size, NULL, iface->comp_channel,
preferred_cpu);
}

if (cq == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR,
uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_ERROR,
"ibv_create_cq(cqe=%d)", cq_size);
return UCS_ERR_IO_ERROR;
}
Expand Down
7 changes: 4 additions & 3 deletions src/uct/ib/base/ib_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ void __uct_ib_log_recv_completion(const char *file, int line, const char *functi
size_t length,
uct_log_data_dump_func_t packet_dump_cb);

#define uct_ib_check_memlock_limit_msg(level, _fmt, ...) \
#define uct_ib_check_memlock_limit_msg(_ibv_context, _level, _fmt, ...) \
({ \
UCS_STRING_BUFFER_ONSTACK(_msg, 256); \
int _tmp_errno = errno; \
ucs_string_buffer_appendf(&_msg, _fmt, ## __VA_ARGS__); \
ucs_string_buffer_appendf(&_msg, _fmt, ##__VA_ARGS__); \
ucs_string_buffer_appendf(&_msg, " failed: %s", strerror(_tmp_errno)); \
uct_ib_memlock_limit_msg(&_msg, _tmp_errno); \
ucs_log(level, "%s", ucs_string_buffer_cstr(&_msg)); \
ucs_log(_level, "%s: %s", ibv_get_device_name((_ibv_context)->device), \
ucs_string_buffer_cstr(&_msg)); \
})

#define uct_ib_log_post_send(_iface, _qp, _wr, _max_sge, _dump_cb) \
Expand Down
18 changes: 8 additions & 10 deletions src/uct/ib/base/ib_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,18 +1358,17 @@ void uct_ib_md_free(uct_ib_md_t *md)
void uct_ib_md_ece_check(uct_ib_md_t *md)
{
#if HAVE_DECL_IBV_SET_ECE
uct_ib_device_t *dev = &md->dev;
struct ibv_pd *pd = md->pd;
struct ibv_ece ece = {};
struct ibv_context *ibv_context = md->dev.ibv_context;
struct ibv_pd *pd = md->pd;
struct ibv_ece ece = {};
struct ibv_qp *dummy_qp;
struct ibv_cq *cq;
struct ibv_qp_init_attr qp_init_attr;

cq = ibv_create_cq(dev->ibv_context, 1, NULL, NULL, 0);
cq = ibv_create_cq(ibv_context, 1, NULL, NULL, 0);
if (cq == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG,
"%s: ibv_create_cq()",
uct_ib_device_name(dev));
uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_DEBUG,
"ibv_create_cq()");
return;
}

Expand All @@ -1384,9 +1383,8 @@ void uct_ib_md_ece_check(uct_ib_md_t *md)

dummy_qp = ibv_create_qp(pd, &qp_init_attr);
if (dummy_qp == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG,
"%s: ibv_create_qp()",
uct_ib_device_name(dev));
uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_DEBUG,
"ibv_create_qp(RC)");
goto free_cq;
}

Expand Down
25 changes: 12 additions & 13 deletions src/uct/ib/dc/dc_mlx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ static ucs_status_t uct_dc_mlx5_iface_create_dci(uct_dc_mlx5_iface_t *iface,
qp = UCS_PROFILE_CALL_ALWAYS(mlx5dv_create_qp, dev->ibv_context,
&attr.super.ibv, &dv_attr);
if (qp == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR,
"%s: mlx5dv_create_qp("UCT_IB_IFACE_FMT", DCI)",
uct_ib_device_name(dev),
uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_ERROR,
"mlx5dv_create_qp(" UCT_IB_IFACE_FMT
", DCI)",
UCT_IB_IFACE_ARG(ib_iface));
status = UCS_ERR_IO_ERROR;
goto err_put_res_domain;
Expand Down Expand Up @@ -593,9 +593,8 @@ uct_dc_mlx5_iface_create_dct(uct_dc_mlx5_iface_t *iface,
iface->rx.dct.verbs.qp = mlx5dv_create_qp(dev->ibv_context, &init_attr,
&dv_init_attr);
if (iface->rx.dct.verbs.qp == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR,
"%s: mlx5dv_create_qp(DCT)",
uct_ib_device_name(dev));
uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_ERROR,
"mlx5dv_create_qp(DCT)");
return UCS_ERR_INVALID_PARAM;
}

Expand Down Expand Up @@ -1352,7 +1351,7 @@ static uct_iface_ops_t uct_dc_mlx5_iface_tl_ops = {

static ucs_status_t uct_dc_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md)
{
uct_ib_device_t *dev = &md->super.dev;
struct ibv_context *ibv_context = md->super.dev.ibv_context;
uct_ib_qp_init_attr_t qp_init_attr = {};
struct mlx5dv_qp_init_attr dv_attr = {};
struct ibv_qp *dci_qp;
Expand All @@ -1363,7 +1362,7 @@ static ucs_status_t uct_dc_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md)
return UCS_OK;
}

status = uct_ib_mlx5dv_qp_tmp_objs_create(dev, md->super.pd, &qp_tmp_objs, 0);
status = uct_ib_mlx5dv_qp_tmp_objs_create(md->super.pd, &qp_tmp_objs, 0);
if (status != UCS_OK) {
goto out;
}
Expand All @@ -1372,12 +1371,11 @@ static ucs_status_t uct_dc_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md)
IBV_QPT_DRIVER, 0);
uct_ib_mlx5dv_dci_qp_init_attr(&qp_init_attr, &dv_attr);

dci_qp = UCS_PROFILE_CALL_ALWAYS(mlx5dv_create_qp, dev->ibv_context,
dci_qp = UCS_PROFILE_CALL_ALWAYS(mlx5dv_create_qp, ibv_context,
&qp_init_attr, &dv_attr);
if (dci_qp == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR,
"%s: mlx5dv_create_qp(DCI)",
uct_ib_device_name(dev));
uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_ERROR,
"mlx5dv_create_qp(DCI)");
status = UCS_ERR_IO_ERROR;
goto out_qp_tmp_objs_close;
}
Expand Down Expand Up @@ -1690,7 +1688,8 @@ uct_dc_mlx5_query_tl_devices(uct_md_h md, uct_tl_device_resource_t **tl_devices_
return UCS_ERR_NO_DEVICE;
}

flags = UCT_IB_DEVICE_FLAG_MLX5_PRM | UCT_IB_DEVICE_FLAG_DC |
flags = UCT_IB_DEVICE_FLAG_SRQ | UCT_IB_DEVICE_FLAG_MLX5_PRM |
UCT_IB_DEVICE_FLAG_DC |
(ib_md->config.eth_pause ? 0 : UCT_IB_DEVICE_FLAG_LINK_IB);
return uct_ib_device_query_ports(&ib_md->dev, flags, tl_devices_p,
num_tl_devices_p);
Expand Down
10 changes: 4 additions & 6 deletions src/uct/ib/mlx5/dv/ib_mlx5_dv.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,25 @@ void uct_ib_mlx5dv_dct_qp_init_attr(uct_ib_qp_init_attr_t *qp_attr,
}

ucs_status_t
uct_ib_mlx5dv_qp_tmp_objs_create(uct_ib_device_t *dev, struct ibv_pd *pd,
uct_ib_mlx5dv_qp_tmp_objs_create(struct ibv_pd *pd,
uct_ib_mlx5dv_qp_tmp_objs_t *qp_tmp_objs,
int silent)
{
struct ibv_srq_init_attr srq_attr = {};
ucs_log_level_t level = silent ? UCS_LOG_LEVEL_DEBUG :
UCS_LOG_LEVEL_ERROR;

qp_tmp_objs->cq = ibv_create_cq(dev->ibv_context, 1, NULL, NULL, 0);
qp_tmp_objs->cq = ibv_create_cq(pd->context, 1, NULL, NULL, 0);
if (qp_tmp_objs->cq == NULL) {
uct_ib_check_memlock_limit_msg(level, "%s: ibv_create_cq()",
uct_ib_device_name(dev));
uct_ib_check_memlock_limit_msg(pd->context, level, "ibv_create_cq()");
goto out;
}

srq_attr.attr.max_sge = 1;
srq_attr.attr.max_wr = 1;
qp_tmp_objs->srq = ibv_create_srq(pd, &srq_attr);
if (qp_tmp_objs->srq == NULL) {
uct_ib_check_memlock_limit_msg(level, "%s: ibv_create_srq()",
uct_ib_device_name(dev));
uct_ib_check_memlock_limit_msg(pd->context, level, "ibv_create_srq()");
goto out_destroy_cq;
}

Expand Down
2 changes: 1 addition & 1 deletion src/uct/ib/mlx5/dv/ib_mlx5_dv.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void uct_ib_mlx5dv_dct_qp_init_attr(uct_ib_qp_init_attr_t *qp_attr,
* Creates CQ and SRQ which are needed for creating QP.
*/
ucs_status_t
uct_ib_mlx5dv_qp_tmp_objs_create(uct_ib_device_t *dev, struct ibv_pd *pd,
uct_ib_mlx5dv_qp_tmp_objs_create(struct ibv_pd *pd,
uct_ib_mlx5dv_qp_tmp_objs_t *qp_tmp_objs,
int silent);

Expand Down
33 changes: 15 additions & 18 deletions src/uct/ib/mlx5/dv/ib_mlx5dv_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,9 +1168,8 @@ uct_ib_mlx5_devx_open_device(struct ibv_device *ibv_device)

cq = ibv_create_cq(ctx, 1, NULL, NULL, 0);
if (cq == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG,
"%s: ibv_create_cq()",
ibv_get_device_name(ibv_device));
uct_ib_check_memlock_limit_msg(ctx, UCS_LOG_LEVEL_DEBUG,
"ibv_create_cq()");
goto close_ctx;
}

Expand Down Expand Up @@ -1900,6 +1899,7 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num)
char out[UCT_IB_MLX5DV_ST_SZ_BYTES(query_qp_out)] = {};
struct ibv_qp_init_attr qp_init_attr = {};
struct ibv_qp_attr qp_attr = {};
uct_ib_device_t *dev = &md->super.dev;
uint8_t *counter_set_id;
struct ibv_qp *dummy_qp;
struct ibv_cq *dummy_cq;
Expand All @@ -1911,11 +1911,10 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num)
return *counter_set_id;
}

dummy_cq = ibv_create_cq(md->super.dev.ibv_context, 1, NULL, NULL, 0);
dummy_cq = ibv_create_cq(dev->ibv_context, 1, NULL, NULL, 0);
if (dummy_cq == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG,
"%s: ibv_create_cq()",
uct_ib_device_name(&md->super.dev));
uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_DEBUG,
"ibv_create_cq()");
goto err;
}

Expand All @@ -1929,9 +1928,8 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num)

dummy_qp = ibv_create_qp(md->super.pd, &qp_init_attr);
if (dummy_qp == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG,
"%s: ibv_create_qp()",
uct_ib_device_name(&md->super.dev));
uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_DEBUG,
"ibv_create_qp(RC)");
goto err_free_cq;
}

Expand All @@ -1943,8 +1941,7 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num)
IBV_QP_ACCESS_FLAGS);
if (ret) {
ucs_diag("failed to modify dummy QP 0x%x to INIT on %s:%d: %m",
dummy_qp->qp_num, uct_ib_device_name(&md->super.dev),
port_num);
dummy_qp->qp_num, uct_ib_device_name(dev), port_num);
goto err_destroy_qp;
}

Expand All @@ -1955,7 +1952,7 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num)
if (ret) {
ucs_diag("mlx5dv_devx_qp_query(%s:%d, DUMMY_QP, QPN=0x%x) failed, "
"syndrome 0x%x: %m",
uct_ib_device_name(&md->super.dev), port_num, dummy_qp->qp_num,
uct_ib_device_name(dev), port_num, dummy_qp->qp_num,
UCT_IB_MLX5DV_GET(query_qp_out, out, syndrome));
goto err_destroy_qp;
}
Expand All @@ -1965,8 +1962,8 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num)
ibv_destroy_qp(dummy_qp);
ibv_destroy_cq(dummy_cq);

ucs_debug("counter_set_id on %s:%d is 0x%x",
uct_ib_device_name(&md->super.dev), port_num, *counter_set_id);
ucs_debug("counter_set_id on %s:%d is 0x%x", uct_ib_device_name(dev),
port_num, *counter_set_id);
return *counter_set_id;

err_destroy_qp:
Expand All @@ -1975,8 +1972,8 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num)
ibv_destroy_cq(dummy_cq);
err:
*counter_set_id = 0;
ucs_debug("using zero counter_set_id on %s:%d",
uct_ib_device_name(&md->super.dev), port_num);
ucs_debug("using zero counter_set_id on %s:%d", uct_ib_device_name(dev),
port_num);
return 0;
}

Expand Down Expand Up @@ -2383,7 +2380,7 @@ static void uct_ib_mlx5dv_check_dc(uct_ib_device_t *dev)
goto out;
}

status = uct_ib_mlx5dv_qp_tmp_objs_create(dev, pd, &qp_tmp_objs, 1);
status = uct_ib_mlx5dv_qp_tmp_objs_create(pd, &qp_tmp_objs, 1);
if (status != UCS_OK) {
goto out_dealloc_pd;
}
Expand Down
5 changes: 2 additions & 3 deletions src/uct/ib/mlx5/ib_mlx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ uct_ib_mlx5_create_cq(uct_ib_iface_t *iface, uct_ib_dir_t dir,

cq = ibv_cq_ex_to_cq(mlx5dv_create_cq(dev->ibv_context, &cq_attr, &dv_attr));
if (cq == NULL) {
uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR,
"%s: mlx5dv_create_cq(cqe=%d)",
uct_ib_device_name(dev), cq_attr.cqe);
uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_ERROR,
"mlx5dv_create_cq(cqe=%d)", cq_attr.cqe);
return UCS_ERR_IO_ERROR;
}

Expand Down
12 changes: 8 additions & 4 deletions src/uct/ib/mlx5/ib_mlx5.h
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,9 @@ uct_ib_mlx5_md_buf_alloc(uct_ib_mlx5_md_t *md, size_t size, int silent,
void **buf_p, uct_ib_mlx5_devx_umem_t *mem,
int access_mode, char *name)
{
ucs_log_level_t level = silent ? UCS_LOG_LEVEL_DEBUG : UCS_LOG_LEVEL_ERROR;
struct ibv_context *ibv_context = md->super.dev.ibv_context;
const ucs_log_level_t level = silent ? UCS_LOG_LEVEL_DEBUG :
UCS_LOG_LEVEL_ERROR;
ucs_status_t status;
void *buf;
int ret;
Expand All @@ -904,10 +906,12 @@ uct_ib_mlx5_md_buf_alloc(uct_ib_mlx5_md_t *md, size_t size, int silent,
}

mem->size = size;
mem->mem = mlx5dv_devx_umem_reg(md->super.dev.ibv_context, buf, size,
access_mode);
mem->mem = mlx5dv_devx_umem_reg(ibv_context, buf, size, access_mode);
if (mem->mem == NULL) {
uct_ib_check_memlock_limit_msg(level, "mlx5dv_devx_umem_reg()");
uct_ib_check_memlock_limit_msg(
ibv_context, level,
"mlx5dv_devx_umem_reg(size=%zu access=0x%x)", size,
access_mode);
status = UCS_ERR_NO_MEMORY;
goto err_dofork;
}
Expand Down
5 changes: 3 additions & 2 deletions src/uct/ib/rc/accel/gga_mlx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ uct_gga_mlx5_query_tl_devices(uct_md_h md,
}

status = uct_ib_device_query_ports(&mlx5_md->super.dev,
UCT_IB_DEVICE_FLAG_MLX5_PRM, &tl_devices,
&num_tl_devices);
UCT_IB_DEVICE_FLAG_SRQ |
UCT_IB_DEVICE_FLAG_MLX5_PRM,
&tl_devices, &num_tl_devices);
if (status != UCS_OK) {
return status;
}
Expand Down
Loading

0 comments on commit 42b9f55

Please sign in to comment.