From 9a7735ee77229cef7328d177b1d2bca5896e6700 Mon Sep 17 00:00:00 2001 From: Xinghai Cen Date: Wed, 4 Sep 2024 17:27:56 +0800 Subject: [PATCH] Perftest: Fix failure in creating cq when create cq ex is not The previous TD lock-free patch introduced ibv_create_cq_ex() to perftest, but it breaks the provider devices which do not support this API yet. For these devices calling this API leads to an errno of EOPNOTSUPP. So add a check of errno, and if it is EOPNOTSUPP, use ibv_create_cq() as a fallback. Fixes: b6f957f ("Perftest: Add support for TD lock-free mode") (cherry picked from commit c6e2261f2d5be0856a7e2be14ae794a0ef8649df) --- ...st-Add-support-for-TD-lock-free-mode.patch | 18 +++--- ...TD-lock-free-mode-not-working-for-QP.patch | 8 ++- ...lure-in-creating-cq-when-create-cq-e.patch | 64 +++++++++++++++++++ perftest.spec | 9 ++- 4 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 0014-Perftest-Fix-failure-in-creating-cq-when-create-cq-e.patch diff --git a/0012-Perftest-Add-support-for-TD-lock-free-mode.patch b/0012-Perftest-Add-support-for-TD-lock-free-mode.patch index 305bd62..09b2cf5 100644 --- a/0012-Perftest-Add-support-for-TD-lock-free-mode.patch +++ b/0012-Perftest-Add-support-for-TD-lock-free-mode.patch @@ -27,7 +27,7 @@ index 54fc2cc..d976663 100755 @@ -298,6 +298,20 @@ if [test $HAVE_HNSDV = yes]; then AC_SUBST([LIBHNS]) fi - + +AC_TRY_LINK([#include ], + [ibv_cq_ex_to_cq], [HAVE_CQ_EX=yes], [HAVE_CQ_EX=no]) +AM_CONDITIONAL([HAVE_CQ_EX], [test "x$HAVE_CQ_EX" = "xyes"]) @@ -52,7 +52,7 @@ index 16af503..4c6ba4f 100755 @@ -464,6 +464,11 @@ static void usage(const char *argv0, VerbType verb, TestType tst, int connection printf(" Use a Shared Receive Queue. --rx-depth controls max-wr size of the SRQ \n"); } - + + #ifdef HAVE_TD_API + printf(" --no_lock "); + printf(" No lock in IO, including post send, post recv, post srq recv and poll cq \n"); @@ -68,7 +68,7 @@ index 16af503..4c6ba4f 100755 + #ifdef HAVE_TD_API + static int no_lock_flag = 0; + #endif - + char *server_ip = NULL; char *client_ip = NULL; @@ -2300,6 +2308,9 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc) @@ -77,14 +77,14 @@ index 16af503..4c6ba4f 100755 { .name = "use-srq", .has_arg = 0, .flag = &srq_flag, .val = 1}, + #ifdef HAVE_TD_API + { .name = "no_lock", .has_arg = 0, .flag = &no_lock_flag, .val = 1}, -+ #endif ++ #endif { .name = "report-both", .has_arg = 0, .flag = &report_both_flag, .val = 1}, { .name = "reversed", .has_arg = 0, .flag = &is_reversed_flag, .val = 1}, { .name = "pkey_index", .has_arg = 1, .flag = &pkey_flag, .val = 1}, @@ -2944,6 +2955,12 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc) user_param->use_srq = 1; } - + + #ifdef HAVE_TD_API + if (no_lock_flag) { + user_param->no_lock = 1; @@ -140,7 +140,7 @@ index 451f11d..0e2b9a3 100755 @@ -1360,6 +1360,20 @@ int destroy_ctx(struct pingpong_context *ctx, } #endif - + + #ifdef HAVE_TD_API + if (user_param->no_lock) { + if (ibv_dealloc_pd(ctx->pad)) { @@ -208,11 +208,11 @@ index 451f11d..0e2b9a3 100755 if (!ctx->send_cq) { @@ -1519,6 +1574,7 @@ int create_reg_cqs(struct pingpong_context *ctx, } - + return SUCCESS; +#endif } - + /****************************************************************************** @@ -1906,6 +1962,31 @@ int ctx_init(struct pingpong_context *ctx, struct perftest_parameters *user_para fprintf(stderr, "Couldn't allocate PD\n"); @@ -261,6 +261,6 @@ index cf0502c..ba8630b 100755 struct ibv_mr **mr; struct ibv_cq *send_cq; struct ibv_cq *recv_cq; --- +-- 2.25.1 diff --git a/0013-Perftest-Fix-TD-lock-free-mode-not-working-for-QP.patch b/0013-Perftest-Fix-TD-lock-free-mode-not-working-for-QP.patch index 224e248..9dcc897 100644 --- a/0013-Perftest-Fix-TD-lock-free-mode-not-working-for-QP.patch +++ b/0013-Perftest-Fix-TD-lock-free-mode-not-working-for-QP.patch @@ -1,9 +1,11 @@ From f8f97b189e9af6cff8559b10c749ff289219b754 Mon Sep 17 00:00:00 2001 From: Xinghai Cen Date: Wed, 21 Aug 2024 20:06:50 +0800 -Subject: [PATCH] Perftest: Fix TD lock-free mode not working for QP When - creating QP in TD lock-free mode, set attr_ex.pd with ctx->pad instead of - ctx->pd, otherwise the lock-free won't work. +Subject: [PATCH] Perftest: Fix TD lock-free mode not working for QP + +Fix TD lock-free mode not working for QP When +creating QP in TD lock-free mode, set attr_ex.pd with ctx->pad instead of +ctx->pd, otherwise the lock-free won't work. Fixes: "Perftest: Add support for TD lock-free mode" Signed-off-by: Guofeng Yue diff --git a/0014-Perftest-Fix-failure-in-creating-cq-when-create-cq-e.patch b/0014-Perftest-Fix-failure-in-creating-cq-when-create-cq-e.patch new file mode 100644 index 0000000..d2334e3 --- /dev/null +++ b/0014-Perftest-Fix-failure-in-creating-cq-when-create-cq-e.patch @@ -0,0 +1,64 @@ +From 3ea6ea2490eb19e5951201804ab9df525338c799 Mon Sep 17 00:00:00 2001 +From: Ge Hu +Date: Mon, 2 Sep 2024 19:43:09 +0800 +Subject: [PATCH] Perftest: Fix failure in creating cq when create cq ex is not + supported by providers + +The previous TD lock-free patch introduced ibv_create_cq_ex() to +perftest, but it breaks the provider devices which do not support +this API yet. For these devices calling this API leads to an errno +of EOPNOTSUPP. So add a check of errno, and if it is EOPNOTSUPP, +use ibv_create_cq() as a fallback. + +Fixes: b6f957f6bc6c ("Perftest: Add support for TD lock-free mode") +Tested-By: Selvin Xavier +Signed-off-by: Junxian Huang +Signed-off-by: Xinghai Cen +--- + src/perftest_resources.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/src/perftest_resources.c b/src/perftest_resources.c +index 58dbdef..843c45f 100755 +--- a/src/perftest_resources.c ++++ b/src/perftest_resources.c +@@ -1516,7 +1516,7 @@ int create_reg_cqs(struct pingpong_context *ctx, + struct perftest_parameters *user_param, + int tx_buffer_depth, int need_recv_cq) + { +- #ifdef HAVE_CQ_EX ++#ifdef HAVE_CQ_EX + struct ibv_cq_init_attr_ex send_cq_attr = { + .cqe = tx_buffer_depth * user_param->num_of_qps, + .cq_context = NULL, +@@ -1532,6 +1532,8 @@ int create_reg_cqs(struct pingpong_context *ctx, + #endif + ctx->send_cq = ibv_cq_ex_to_cq(ibv_create_cq_ex(ctx->context, &send_cq_attr)); + if (!ctx->send_cq) { ++ if (!user_param->no_lock && errno == EOPNOTSUPP) ++ goto cq_ex_not_supported; + fprintf(stderr, "Couldn't create CQ\n"); + return FAILURE; + } +@@ -1556,7 +1558,9 @@ int create_reg_cqs(struct pingpong_context *ctx, + } + } + return SUCCESS; +-#else ++ ++cq_ex_not_supported: ++#endif + ctx->send_cq = ibv_create_cq(ctx->context,tx_buffer_depth * + user_param->num_of_qps, NULL, ctx->channel, user_param->eq_num); + if (!ctx->send_cq) { +@@ -1574,7 +1578,6 @@ int create_reg_cqs(struct pingpong_context *ctx, + } + + return SUCCESS; +-#endif + } + + /****************************************************************************** +-- +2.25.1 + diff --git a/perftest.spec b/perftest.spec index f3923f3..737c993 100644 --- a/perftest.spec +++ b/perftest.spec @@ -1,6 +1,6 @@ Name: perftest Version: 4.5 -Release: 10 +Release: 11 License: GPLv2 or BSD Summary: RDMA Performance Testing Tools Url: https://github.com/linux-rdma/perftest @@ -19,6 +19,7 @@ Patch10: 0010-Perftest-Support-selecting-congestion-control-algori.patch Patch11: 0011-Perftest-Fix-rx_depth-check-for-XRC.patch Patch12: 0012-Perftest-Add-support-for-TD-lock-free-mode.patch Patch13: 0013-Perftest-Fix-TD-lock-free-mode-not-working-for-QP.patch +Patch14: 0014-Perftest-Fix-failure-in-creating-cq-when-create-cq-e.patch BuildRequires: automake gcc libibverbs-devel >= 1.2.0 librdmacm-devel >= 1.0.21 libibumad-devel >= 1.3.10.2 BuildRequires: pciutils-devel libibverbs librdmacm libibumad @@ -46,6 +47,12 @@ done %_bindir/* %changelog +* Mon Sep 2 2024 Xinghai Cen - 4.5-11 +- Type: bugfix +- ID: NA +- SUG: NA +- DESC: Fix failure in creating cq when create cq ex is not + * Wed Aug 21 2024 Xinghai Cen - 4.5-10 - Type: feature - ID: NA -- Gitee