Skip to content

Commit b6f957f

Browse files
Guofeng Yuesshaulnv
authored andcommitted
Perftest: Add support for TD lock-free mode
Add support for TD lock-free mode New option: --no_lock Usage example: ib_send_bw -d hns_0 --no_lock ib_send_bw -d hns_0 --no_lock 192.168.100.100 Signed-off-by: Guofeng Yue <[email protected]> Signed-off-by: Junxian Huang <[email protected]>
1 parent 2e88853 commit b6f957f

File tree

5 files changed

+138
-2
lines changed

5 files changed

+138
-2
lines changed

configure.ac

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,20 @@ if [test $HAVE_HNSDV = yes]; then
416416
AC_SUBST([LIBHNS])
417417
fi
418418

419+
AC_TRY_LINK([#include <infiniband/verbs.h>],
420+
[ibv_cq_ex_to_cq], [HAVE_CQ_EX=yes], [HAVE_CQ_EX=no])
421+
AM_CONDITIONAL([HAVE_CQ_EX], [test "x$HAVE_CQ_EX" = "xyes"])
422+
if [test $HAVE_CQ_EX = yes]; then
423+
AC_DEFINE([HAVE_CQ_EX], [1], [Have CQ EX API support])
424+
fi
425+
426+
AC_TRY_LINK([#include <infiniband/verbs.h>],
427+
[ibv_alloc_td], [HAVE_TD_API=yes], [HAVE_TD_API=no])
428+
AM_CONDITIONAL([HAVE_TD_API], [test "x$HAVE_TD_API" = "xyes"])
429+
if [test $HAVE_TD_API = yes]; then
430+
AC_DEFINE([HAVE_TD_API], [1], [Have TD API support])
431+
fi
432+
419433
CFLAGS="-g -Wall -D_GNU_SOURCE -O3 $CFLAGS"
420434
LDFLAGS="$LDFLAGS"
421435
LIBS=$LIBS" -lpthread"

src/perftest_parameters.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ static void usage(const char *argv0, VerbType verb, TestType tst, int connection
467467
printf(" Use a Shared Receive Queue. --rx-depth controls max-wr size of the SRQ \n");
468468
}
469469

470+
#ifdef HAVE_TD_API
471+
printf(" --no_lock ");
472+
printf(" No lock in IO, including post send, post recv, post srq recv and poll cq \n");
473+
#endif
474+
470475
if (connection_type != RawEth) {
471476
printf(" --ipv6 ");
472477
printf(" Use IPv6 GID. Default is IPv4\n");
@@ -879,6 +884,7 @@ static void init_perftest_params(struct perftest_parameters *user_param)
879884
user_param->has_source_ip = 0;
880885
user_param->use_write_with_imm = 0;
881886
user_param->congest_type = OFF;
887+
user_param->no_lock = OFF;
882888
}
883889

884890
static int open_file_write(const char* file_path)
@@ -2335,6 +2341,9 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
23352341
#ifdef HAVE_HNSDV
23362342
static int congest_type_flag = 0;
23372343
#endif
2344+
#ifdef HAVE_TD_API
2345+
static int no_lock_flag = 0;
2346+
#endif
23382347

23392348
char *server_ip = NULL;
23402349
char *client_ip = NULL;
@@ -2414,6 +2423,9 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
24142423
{ .name = "run_infinitely", .has_arg = 0, .flag = &run_inf_flag, .val = 1 },
24152424
{ .name = "report_gbits", .has_arg = 0, .flag = &report_fmt_flag, .val = 1},
24162425
{ .name = "use-srq", .has_arg = 0, .flag = &srq_flag, .val = 1},
2426+
#ifdef HAVE_TD_API
2427+
{ .name = "no_lock", .has_arg = 0, .flag = &no_lock_flag, .val = 1},
2428+
#endif
24172429
{ .name = "use-null-mr", .has_arg = 0, .flag = &use_null_mr_flag, .val = 1},
24182430
{ .name = "report-both", .has_arg = 0, .flag = &report_both_flag, .val = 1},
24192431
{ .name = "reversed", .has_arg = 0, .flag = &is_reversed_flag, .val = 1},
@@ -3165,6 +3177,12 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
31653177
user_param->use_srq = 1;
31663178
}
31673179

3180+
#ifdef HAVE_TD_API
3181+
if (no_lock_flag) {
3182+
user_param->no_lock = 1;
3183+
}
3184+
#endif
3185+
31683186
if (use_null_mr_flag) {
31693187
user_param->use_null_mr = 1;
31703188
}
@@ -3509,15 +3527,24 @@ void ctx_print_test_info(struct perftest_parameters *user_param)
35093527
printf(" Number of qps : %d\t\tTransport type : %s\n", user_param->num_of_qps, transport_str(user_param->transport_type));
35103528
printf(" Connection type : %s\t\tUsing SRQ : %s\n", connStr[user_param->connection_type], user_param->use_srq ? "ON" : "OFF");
35113529
#ifdef HAVE_RO
3512-
printf(" PCIe relax order: %s\n", user_param->disable_pcir ? "OFF" : "ON");
3530+
#ifdef HAVE_TD_API
3531+
printf(" PCIe relax order: %s\t\tLock-free : %s\n", user_param->disable_pcir ? "OFF" : "ON", user_param->no_lock ? "ON" : "OFF");
3532+
#else
3533+
printf(" PCIe relax order: %s\t\tLock-free : %s\n", user_param->disable_pcir ? "OFF" : "ON", "Unsupported");
3534+
#endif //HAVE_TD_API
35133535
if ((check_pcie_relaxed_ordering_compliant() == false) &&
35143536
(user_param->disable_pcir == 0)) {
35153537
printf(" WARNING: CPU is not PCIe relaxed ordering compliant.\n");
35163538
printf(" WARNING: You should disable PCIe RO with `--disable_pcie_relaxed` for both server and client.\n");
35173539
}
35183540
#else
3519-
printf(" PCIe relax order: %s\n", "Unsupported");
3541+
#ifdef HAVE_TD_API
3542+
printf(" PCIe relax order: %s\t\tLock-free : %s\n", "Unsupported", user_param->no_lock ? "ON" : "OFF");
3543+
#else
3544+
printf(" PCIe relax order: %s\t\tLock-free : %s\n", "Unsupported", "Unsupported");
3545+
#endif //HAVE_TD_API
35203546
#endif
3547+
35213548
printf(" ibv_wr* API : %s\n", user_param->use_old_post_send ? "OFF" : "ON");
35223549
if (user_param->machine == CLIENT || user_param->duplex) {
35233550
printf(" TX depth : %d\n",user_param->tx_depth);

src/perftest_parameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ struct perftest_parameters {
525525
int recv_post_list;
526526
int duration;
527527
int use_srq;
528+
int no_lock;
528529
int congest_type;
529530
int use_xrc;
530531
int use_rss;

src/perftest_resources.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,20 @@ int destroy_ctx(struct pingpong_context *ctx,
13171317
}
13181318
#endif
13191319

1320+
#ifdef HAVE_TD_API
1321+
if (user_param->no_lock) {
1322+
if (ibv_dealloc_pd(ctx->pad)) {
1323+
fprintf(stderr, "Failed to deallocate PAD - %s\n", strerror(errno));
1324+
test_result = 1;
1325+
}
1326+
1327+
if (ibv_dealloc_td(ctx->td)) {
1328+
fprintf(stderr, "Failed to deallocate TD - %s\n", strerror(errno));
1329+
test_result = 1;
1330+
}
1331+
}
1332+
#endif
1333+
13201334
if (ibv_dealloc_pd(ctx->pd)) {
13211335
fprintf(stderr, "Failed to deallocate PD - %s\n", strerror(errno));
13221336
test_result = 1;
@@ -1517,6 +1531,47 @@ int create_reg_cqs(struct pingpong_context *ctx,
15171531
struct perftest_parameters *user_param,
15181532
int tx_buffer_depth, int need_recv_cq)
15191533
{
1534+
#ifdef HAVE_CQ_EX
1535+
struct ibv_cq_init_attr_ex send_cq_attr = {
1536+
.cqe = tx_buffer_depth * user_param->num_of_qps,
1537+
.cq_context = NULL,
1538+
.channel = ctx->send_channel,
1539+
.comp_vector = user_param->eq_num,
1540+
};
1541+
1542+
#ifdef HAVE_TD_API
1543+
if (user_param->no_lock) {
1544+
send_cq_attr.parent_domain = ctx->pad;
1545+
send_cq_attr.comp_mask = IBV_CQ_INIT_ATTR_MASK_PD;
1546+
}
1547+
#endif
1548+
ctx->send_cq = ibv_cq_ex_to_cq(ibv_create_cq_ex(ctx->context, &send_cq_attr));
1549+
if (!ctx->send_cq) {
1550+
fprintf(stderr, "Couldn't create CQ\n");
1551+
return FAILURE;
1552+
}
1553+
1554+
if (need_recv_cq) {
1555+
struct ibv_cq_init_attr_ex recv_cq_attr = {
1556+
.cqe = user_param->rx_depth * user_param->num_of_qps,
1557+
.cq_context = NULL,
1558+
.channel = ctx->recv_channel,
1559+
.comp_vector = user_param->eq_num,
1560+
};
1561+
#ifdef HAVE_TD_API
1562+
if (user_param->no_lock) {
1563+
recv_cq_attr.parent_domain = ctx->pad;
1564+
recv_cq_attr.comp_mask = IBV_CQ_INIT_ATTR_MASK_PD;
1565+
}
1566+
#endif
1567+
ctx->recv_cq = ibv_cq_ex_to_cq(ibv_create_cq_ex(ctx->context, &recv_cq_attr));
1568+
if (!ctx->recv_cq) {
1569+
fprintf(stderr, "Couldn't create a receiver CQ\n");
1570+
return FAILURE;
1571+
}
1572+
}
1573+
return SUCCESS;
1574+
#else
15201575
ctx->send_cq = ibv_create_cq(ctx->context,tx_buffer_depth *
15211576
user_param->num_of_qps, NULL, ctx->send_channel, user_param->eq_num);
15221577
if (!ctx->send_cq) {
@@ -1534,6 +1589,7 @@ int create_reg_cqs(struct pingpong_context *ctx,
15341589
}
15351590

15361591
return SUCCESS;
1592+
#endif
15371593
}
15381594

15391595
/******************************************************************************
@@ -1941,6 +1997,30 @@ int ctx_init(struct pingpong_context *ctx, struct perftest_parameters *user_para
19411997
goto comp_channel;
19421998
}
19431999

2000+
#ifdef HAVE_TD_API
2001+
/* Allocating the Thread domain, Parent domain. */
2002+
if (user_param->no_lock) {
2003+
struct ibv_td_init_attr td_attr = {0};
2004+
ctx->td = ibv_alloc_td(ctx->context, &td_attr);
2005+
if (!ctx->td) {
2006+
fprintf(stderr, "Couldn't allocate TD\n");
2007+
goto pd;
2008+
}
2009+
2010+
struct ibv_parent_domain_init_attr pad_attr = {
2011+
.pd = ctx->pd,
2012+
.td = ctx->td,
2013+
.comp_mask = 0,
2014+
};
2015+
2016+
ctx->pad = ibv_alloc_parent_domain(ctx->context, &pad_attr);
2017+
if (!ctx->pad) {
2018+
fprintf(stderr, "Couldn't allocate PAD\n");
2019+
goto td;
2020+
}
2021+
}
2022+
#endif
2023+
19442024
#ifdef HAVE_AES_XTS
19452025
if(user_param->aes_xts){
19462026
struct mlx5dv_dek_init_attr dek_attr = {};
@@ -2126,6 +2206,16 @@ xrcd: __attribute__((unused))
21262206
mlx5dv_dek_destroy(ctx->dek[i]);
21272207
#endif
21282208

2209+
#ifdef HAVE_TD_API
2210+
if (user_param->no_lock)
2211+
ibv_dealloc_pd(ctx->pad);
2212+
2213+
td:
2214+
if (user_param->no_lock)
2215+
ibv_dealloc_td(ctx->td);
2216+
pd:
2217+
#endif
2218+
21292219
ibv_dealloc_pd(ctx->pd);
21302220

21312221
comp_channel:

src/perftest_resources.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ struct pingpong_context {
178178
struct ibv_comp_channel *recv_channel;
179179
struct ibv_comp_channel *send_channel;
180180
struct ibv_pd *pd;
181+
#ifdef HAVE_TD_API
182+
struct ibv_td *td;
183+
struct ibv_pd *pad;
184+
#endif
181185
struct ibv_mr **mr;
182186
struct ibv_mr *null_mr;
183187
struct ibv_cq *send_cq;

0 commit comments

Comments
 (0)