Perftest: Fix TD lock-free mode not working for SRQ/XRC QP

From: Guofeng Yue <yueguofeng@h-partners.com> When creating SRQ/XRC QP in TD lock-free mode, pass in ctx->pad instead of ctx->pd, otherwise the lock-free won't work. Besides, use ctx->pad directly when creating QP/SRQ since pad is designed to be interchangeable with the usual pd. When lock-free mode is disabled, pad is the exactly the usual pd. Fixes: b6f957f6bc6c ("Perftest: Add support for TD lock-free mode") Signed-off-by: Guofeng Yue <yueguofeng@h-partners.com> Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> --- src/perftest_resources.c | 21 ++++++++++++--------- src/perftest_resources.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/perftest_resources.c b/src/perftest_resources.c index 2d2e9f2..6543bc7 100755 --- a/src/perftest_resources.c +++ b/src/perftest_resources.c @@ -737,7 +737,8 @@ static int ctx_xrc_srq_create(struct pingpong_context *ctx, else srq_init_attr.cq = ctx->send_cq; - srq_init_attr.pd = ctx->pd; + srq_init_attr.pd = ctx->pad; + ctx->srq = ibv_create_srq_ex(ctx->context, &srq_init_attr); if (ctx->srq == NULL) { fprintf(stderr, "Couldn't open XRC SRQ\n"); @@ -780,7 +781,8 @@ static struct ibv_qp *ctx_xrc_qp_create(struct pingpong_context *ctx, qp_init_attr.cap.max_send_wr = user_param->tx_depth; qp_init_attr.cap.max_send_sge = 1; qp_init_attr.comp_mask = IBV_QP_INIT_ATTR_PD; - qp_init_attr.pd = ctx->pd; + qp_init_attr.pd = ctx->pad; + #ifdef HAVE_IBV_WR_API if (!user_param->use_old_post_send) qp_init_attr.comp_mask |= IBV_QP_INIT_ATTR_SEND_OPS_FLAGS; @@ -2037,9 +2039,14 @@ int ctx_init(struct pingpong_context *ctx, struct perftest_parameters *user_para fprintf(stderr, "Couldn't allocate PAD\n"); goto td; } + } else { + #endif + ctx->pad = ctx->pd; + #ifdef HAVE_TD_API } #endif + #ifdef HAVE_AES_XTS if(user_param->aes_xts){ struct mlx5dv_dek_init_attr dek_attr = {}; @@ -2127,7 +2134,7 @@ int ctx_init(struct pingpong_context *ctx, struct perftest_parameters *user_para attr.comp_mask = IBV_SRQ_INIT_ATTR_TYPE | IBV_SRQ_INIT_ATTR_PD; attr.attr.max_wr = user_param->rx_depth; attr.attr.max_sge = 1; - attr.pd = ctx->pd; + attr.pd = ctx->pad; attr.srq_type = IBV_SRQT_BASIC; ctx->srq = ibv_create_srq_ex(ctx->context, &attr); @@ -2148,7 +2155,7 @@ int ctx_init(struct pingpong_context *ctx, struct perftest_parameters *user_para .max_sge = 1 } }; - ctx->srq = ibv_create_srq(ctx->pd, &attr); + ctx->srq = ibv_create_srq(ctx->pad, &attr); if (!ctx->srq) { fprintf(stderr, "Couldn't create SRQ\n"); goto xrcd; @@ -2406,11 +2413,7 @@ struct ibv_qp* ctx_qp_create(struct pingpong_context *ctx, attr_ex.send_ops_flags |= IBV_QP_EX_WITH_RDMA_READ; } - #ifdef HAVE_TD_API - attr_ex.pd = user_param->no_lock ? ctx->pad : ctx->pd; - #else - attr_ex.pd = ctx->pd; - #endif + attr_ex.pd = ctx->pad; attr_ex.comp_mask |= IBV_QP_INIT_ATTR_SEND_OPS_FLAGS | IBV_QP_INIT_ATTR_PD; attr_ex.send_cq = attr.send_cq; diff --git a/src/perftest_resources.h b/src/perftest_resources.h index b28e136..25a7438 100755 --- a/src/perftest_resources.h +++ b/src/perftest_resources.h @@ -183,8 +183,8 @@ struct pingpong_context { struct ibv_pd *pd; #ifdef HAVE_TD_API struct ibv_td *td; - struct ibv_pd *pad; #endif + struct ibv_pd *pad; struct ibv_mr **mr; struct ibv_mr *null_mr; struct ibv_cq *send_cq; -- 2.33.0

From: Guofeng Yue <yueguofeng@h-partners.com> In perform_warm_up mode, if the length of post_list is 1 and the message size is less than or equal to 8192, all send_flags in WRs are 0 and CQEs will not be generated since IBV_SEND_SIGNALED is not set. As a result, the perform_warm_up process will stuck in an infinite poll-CQ loop. Set IBV_SEND_SIGNALED in this case to requiring CQE, and clear the flag after post_send_method to avoid affecting subsequent tests. Fixes: 56d025e4f19a ("Allow overriding CQ moderation on post list mode (#58)") Signed-off-by: Guofeng Yue <yueguofeng@h-partners.com> Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> --- src/perftest_resources.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/perftest_resources.c b/src/perftest_resources.c index 6543bc7..582d00b 100755 --- a/src/perftest_resources.c +++ b/src/perftest_resources.c @@ -3448,6 +3448,7 @@ int perform_warm_up(struct pingpong_context *ctx,struct perftest_parameters *use struct ibv_wc *wc_for_cleaning = NULL; int num_of_qps = user_param->num_of_qps; int return_value = 0; + int flag = 0; if(user_param->duplex && (user_param->use_xrc || user_param->connection_type == DC)) num_of_qps /= 2; @@ -3464,9 +3465,13 @@ int perform_warm_up(struct pingpong_context *ctx,struct perftest_parameters *use ne = ibv_poll_cq(ctx->send_cq,user_param->tx_depth,wc_for_cleaning); for (index=0 ; index < num_of_qps ; index++) { + /* ask for completion on this wr */ + if (user_param->post_list == 1 && !(ctx->wr[index].send_flags & IBV_SEND_SIGNALED)) { + ctx->wr[index].send_flags |= IBV_SEND_SIGNALED; + flag = 1; + } for (warmindex = 0 ;warmindex < warmupsession ;warmindex += user_param->post_list) { - err = post_send_method(ctx, index, user_param); if (err) { fprintf(stderr,"Couldn't post send during warm up: qp %d scnt=%d \n",index,warmindex); @@ -3475,6 +3480,12 @@ int perform_warm_up(struct pingpong_context *ctx,struct perftest_parameters *use } } + /* Clear the flag to avoid affecting subsequent tests. */ + if (flag) { + ctx->wr[index].send_flags &= ~IBV_SEND_SIGNALED; + flag = 0; + } + do { ne = ibv_poll_cq(ctx->send_cq,1,&wc); -- 2.33.0
participants (1)
-
Junxian Huang