diff --git a/tools/urma_admin/admin_parameters.c b/tools/urma_admin/admin_parameters.c index cd1ac6fdcbff6482963e38eb7fff135fddfda426..c01506a109392a1f930189c4e509853aa34666ba 100644 --- a/tools/urma_admin/admin_parameters.c +++ b/tools/urma_admin/admin_parameters.c @@ -328,6 +328,7 @@ int admin_parse_args(int argc, char *argv[], tool_config_t *cfg) ret = admin_str_to_u32(optarg, &cfg->key.key_cnt); break; case 'h': + cfg->help = true; usage(argv[0]); return 0; case 'd': diff --git a/tools/urma_admin/admin_parameters.h b/tools/urma_admin/admin_parameters.h index 0117427d8cc5c85314751d2c6fb2c25336aded29..283d16a4f867a4ac2dd27569329a58ed09b3f46e 100644 --- a/tools/urma_admin/admin_parameters.h +++ b/tools/urma_admin/admin_parameters.h @@ -260,6 +260,7 @@ typedef struct tool_config { tool_cmd_type_t cmd; bool specify_device; bool whole_info; + bool help; char dev_name[URMA_ADMIN_MAX_DEV_NAME]; /* ubep device name */ urma_eid_t eid; bool dynamic_eid_mode; diff --git a/tools/urma_admin/urma_admin.c b/tools/urma_admin/urma_admin.c index 41b0b74b60e5b27607deca2d8d77f08afdf8a133..8f1a7719987f25e4f3bb4170923d96e53457db85 100644 --- a/tools/urma_admin/urma_admin.c +++ b/tools/urma_admin/urma_admin.c @@ -496,7 +496,7 @@ static void admin_log_cmd(int argc, char *argv[], int ret) int main(int argc, char *argv[]) { int ret; - tool_config_t tool_cfg; + tool_config_t tool_cfg = {0}; if (admin_check_cmd_len(argc, argv) != 0) { (void)printf("user: %s, cmd len out of range.\n", getlogin()); @@ -509,6 +509,10 @@ int main(int argc, char *argv[]) admin_log_cmd(argc, argv, ret); return ret; } + if (tool_cfg.help) { + /* Do not execute other operations for --help parameter */ + return 0; + } if (tool_cfg.cmd == TOOL_CMD_NUM) { admin_log_cmd(argc, argv, ret); return 0; diff --git a/tools/urma_perftest/perftest_parameters.c b/tools/urma_perftest/perftest_parameters.c index 709dc02d0005c0c3ded7e694f7e5a9635116c3f2..043b4e1e819965f278c0c641b909767a3d43a4eb 100644 --- a/tools/urma_perftest/perftest_parameters.c +++ b/tools/urma_perftest/perftest_parameters.c @@ -538,16 +538,20 @@ int perftest_parse_args(int argc, char *argv[], perftest_config_t *cfg) break; case 'j': if (ub_str_to_bool(optarg, &cfg->share_jfr) != 0) { - (void)fprintf(stderr, "Invalid parameter :%s.\n", optarg); + (void)fprintf(stderr, "Invalid parameter(share_jfr).\n"); return -1; } break; case 'J': - if (cfg->type != PERFTEST_BW) { + (void)ub_str_to_u32(optarg, &cfg->jettys); + if (cfg->jettys == 0) { + (void)fprintf(stderr, "Invalid parameter(jettys).\n"); + return -1; + } + if (cfg->type != PERFTEST_BW && cfg->jettys > 1) { (void)fprintf(stderr, "Multiple jettys only available on band width tests.\n"); return -1; } - (void)ub_str_to_u32(optarg, &cfg->jettys); break; case 'K': (void)ub_str_to_u32(optarg, &cfg->token_policy); diff --git a/tools/urma_perftest/perftest_parameters.h b/tools/urma_perftest/perftest_parameters.h index e594dd4234aeb6fb94fedb1c6a38d7669518a1cd..aefc187058c488aaaa31ff604c9d9d7b22a962af 100644 --- a/tools/urma_perftest/perftest_parameters.h +++ b/tools/urma_perftest/perftest_parameters.h @@ -152,7 +152,8 @@ enum perftest_opts { PERFTEST_OPT_ENABLE_CREDIT, PERFTEST_OPT_CREDIT_THRESHOLD, PERFTEST_OPT_CREDIT_NOTIFY_CNT, - PERFTEST_OPT_JETTYS_PRE_JFR + PERFTEST_OPT_JETTYS_PRE_JFR, + PERFTEST_OPT_SEG_PRE_JETTY, }; typedef enum perftest_rate_limiter_units { @@ -231,6 +232,7 @@ typedef struct perftest_config { /* valid for server side of send_bw using iteraion type */ int check_alive_exited; + bool seg_pre_jetty; } perftest_config_t; typedef struct perftest_value_range { diff --git a/tools/urma_perftest/perftest_resources.c b/tools/urma_perftest/perftest_resources.c index ed21f9c363af126dcdeac9617f2f43b7eaea140a..db8d2ab6801181615900d0e9e530f80e31eacd60 100644 --- a/tools/urma_perftest/perftest_resources.c +++ b/tools/urma_perftest/perftest_resources.c @@ -537,26 +537,35 @@ static void destroy_duplex_jettys(perftest_context_t *ctx, perftest_config_t *cf static inline void unregister_seg(perftest_context_t *ctx, const perftest_config_t *cfg, const int idx) { + uint32_t seg_num = (cfg->seg_pre_jetty == false) ? 1 : cfg->jettys; for (int k = 0; k < idx; k++) { - (void)urma_unregister_seg(ctx->local_tseg[k]); + if (k < seg_num) { + (void)urma_unregister_seg(ctx->local_tseg[k]); + } } free(ctx->local_tseg); ctx->local_tseg = NULL; } -static inline void free_token_id(perftest_context_t *ctx, const int idx) +static inline void free_token_id(perftest_context_t *ctx, const perftest_config_t *cfg, const int idx) { + uint32_t seg_num = (cfg->seg_pre_jetty == false) ? 1 : cfg->jettys; for (int k = 0; k < idx; k++) { - (void)urma_free_token_id(ctx->token_id[k]); + if (k < seg_num) { + (void)urma_free_token_id(ctx->token_id[k]); + } } free(ctx->token_id); ctx->token_id = NULL; } -static inline void free_memory(perftest_context_t *ctx, const int idx) +static inline void free_memory(perftest_context_t *ctx, const perftest_config_t *cfg, const int idx) { + uint32_t seg_num = (cfg->seg_pre_jetty == false) ? 1 : cfg->jettys; for (int j = 0; j < idx; j++) { - free(ctx->local_buf[j]); + if (j < seg_num) { + free(ctx->local_buf[j]); + } } free(ctx->local_buf); ctx->local_buf = NULL; @@ -570,17 +579,23 @@ static int register_mem(perftest_context_t *ctx, perftest_config_t *cfg) return -ENOMEM; } + uint32_t seg_num = (cfg->seg_pre_jetty == false) ? 1 : cfg->jettys; + ctx->page_size = cfg->page_size; // holds the size of maximum between cfg->size and page_size, aligned to cache line. uint64_t max_size = MAX(cfg->size, ctx->page_size); ctx->buf_size = PERFTEST_ALIGN_CACHELINE(max_size, cfg->cache_line_size); // Buff is divided into two parts, one for recv and the other for send - ctx->buf_len = ctx->buf_size * PERFTEST_BUF_NUM; + ctx->buf_len = ctx->buf_size * PERFTEST_BUF_NUM * + ((cfg->seg_pre_jetty == true) ? 1 : cfg->jettys); for (i = 0; i < (int)cfg->jettys; i++) { - // Buff is divided into two parts, one for recv and the other for send - ctx->local_buf[i] = memalign(ctx->page_size, ctx->buf_len); + if (i < seg_num) { + ctx->local_buf[i] = memalign(ctx->page_size, ctx->buf_len); + } else { + ctx->local_buf[i] = ctx->local_buf[0]; + } if (ctx->local_buf[i] == NULL) { (void)fprintf(stderr, "Failed to memalign local buff, loop:%d!\n", i); goto free_memory; @@ -593,7 +608,11 @@ static int register_mem(perftest_context_t *ctx, perftest_config_t *cfg) goto free_memory; } for (k = 0; k < (int)cfg->jettys; k++) { - ctx->token_id[k] = urma_alloc_token_id(ctx->urma_ctx); + if (k < seg_num) { + ctx->token_id[k] = urma_alloc_token_id(ctx->urma_ctx); + } else { + ctx->token_id[k] = ctx->token_id[0]; + } if (ctx->token_id[k] == NULL) { (void)fprintf(stderr, "Failed to alloc token id, loop:%d!\n", k); goto free_token_id; @@ -615,18 +634,22 @@ static int register_mem(perftest_context_t *ctx, perftest_config_t *cfg) }; urma_seg_cfg_t seg_cfg = { .va = 0, - .len = ctx->buf_size * PERFTEST_BUF_NUM, + .len = ctx->buf_len, .token_value = g_perftest_token, .flag = flag, .user_ctx = (uintptr_t)NULL, .iova = 0 }; for (j = 0; j < (int)cfg->jettys; j++) { - seg_cfg.va = (uint64_t)ctx->local_buf[j]; - if (ctx->urma_ctx->dev->type == URMA_TRANSPORT_UB) { - seg_cfg.token_id = ctx->token_id[j]; + if (j < seg_num) { + seg_cfg.va = (uint64_t)ctx->local_buf[j]; + if (ctx->urma_ctx->dev->type == URMA_TRANSPORT_UB) { + seg_cfg.token_id = ctx->token_id[j]; + } + ctx->local_tseg[j] = urma_register_seg(ctx->urma_ctx, &seg_cfg); + } else { + ctx->local_tseg[j] = ctx->local_tseg[0]; } - ctx->local_tseg[j] = urma_register_seg(ctx->urma_ctx, &seg_cfg); if (ctx->local_tseg[j] == NULL) { (void)fprintf(stderr, "Failed to register seg, loop:%d!\n", j); goto unregister_seg; @@ -639,10 +662,10 @@ unregister_seg: unregister_seg(ctx, cfg, j); free_token_id: if (ctx->urma_ctx->dev->type == URMA_TRANSPORT_UB) { - free_token_id(ctx, k); + free_token_id(ctx, cfg, k); } free_memory: - free_memory(ctx, i); + free_memory(ctx, cfg, i); return -1; } @@ -650,9 +673,9 @@ static void unregister_mem(perftest_context_t *ctx, const perftest_config_t *cfg { unregister_seg(ctx, cfg, (int)ctx->jetty_num); if (ctx->urma_ctx->dev->type == URMA_TRANSPORT_UB) { - free_token_id(ctx, (int)ctx->jetty_num); + free_token_id(ctx, cfg, (int)ctx->jetty_num); } - free_memory(ctx, (int)ctx->jetty_num); + free_memory(ctx, cfg, (int)ctx->jetty_num); } static inline void free_remote_seg(perftest_context_t *ctx, const int idx) diff --git a/tools/urma_perftest/perftest_run_test.c b/tools/urma_perftest/perftest_run_test.c index 986097c4e131b12525a98da557706ac70cead0b0..2d14eb80853b339d4b5fb021fe0fc6fbf32ad4db 100644 --- a/tools/urma_perftest/perftest_run_test.c +++ b/tools/urma_perftest/perftest_run_test.c @@ -387,7 +387,8 @@ static int run_once_send_lat(perftest_context_t *ctx, perftest_config_t *cfg) } if (cr.status != URMA_CR_SUCCESS) { - (void)fprintf(stderr, "Failed CR status %d, scnt: %lu, rcnt: %lu", (int)cr.status, scnt, rcnt); + (void)fprintf(stderr, "Failed CR status %d, scnt: %lu, rcnt: %lu.\n", + (int)cr.status, scnt, rcnt); return -1; } @@ -456,7 +457,7 @@ static int run_once_send_lat(perftest_context_t *ctx, perftest_config_t *cfg) return -1; } if (cr.status != URMA_CR_SUCCESS) { - (void)fprintf(stderr, "Failed CR status %d, scnt: %lu, rcnt: %lu", (int)cr.status, scnt, rcnt); + (void)fprintf(stderr, "Failed CR status %d, scnt: %lu, rcnt: %lu.\n", (int)cr.status, scnt, rcnt); return -1; } @@ -778,8 +779,12 @@ static void init_read_jfs_wr_sg(urma_jfs_wr_t *wr, perftest_context_t *ctx, perf uint32_t i, uint32_t j) { run_test_ctx_t *run_ctx = &ctx->run_ctx; - uint64_t lva = (uint64_t)ctx->local_buf[i] + ctx->buf_size; // Second half for local memory - uint64_t rva = (uint64_t)ctx->remote_seg[i]->ubva.va; + uint64_t lva = (cfg->seg_pre_jetty == false) ? + (uint64_t)ctx->local_buf[0] + (cfg->jettys + i) * ctx->buf_size : + (uint64_t)ctx->local_buf[i] + ctx->buf_size; // Second half for local memory + uint64_t rva = (cfg->seg_pre_jetty == false) ? + (uint64_t)ctx->remote_seg[0]->ubva.va + i * ctx->buf_size : + (uint64_t)ctx->remote_seg[i]->ubva.va; urma_sge_t *local_sge = &run_ctx->jfs_sge[(i * cfg->jfs_post_list + j) * PERFTEST_SGE_NUM_PRE_WR + 1]; urma_sge_t *remote_sge = &run_ctx->jfs_sge[(i * cfg->jfs_post_list + j) * PERFTEST_SGE_NUM_PRE_WR]; @@ -818,8 +823,13 @@ static void init_write_jfs_wr_sg(urma_jfs_wr_t *wr, perftest_context_t *ctx, per uint32_t i, uint32_t j) { run_test_ctx_t *run_ctx = &ctx->run_ctx; - uint64_t lva = (uint64_t)ctx->local_buf[i] + ctx->buf_size; // Second half for local memory - uint64_t rva = (uint64_t)ctx->remote_seg[i]->ubva.va; + + uint64_t lva = (cfg->seg_pre_jetty == false) ? + (uint64_t)ctx->local_buf[0] + (cfg->jettys + i) * ctx->buf_size : + (uint64_t)ctx->local_buf[i] + ctx->buf_size; // Second half for local memory + uint64_t rva = (cfg->seg_pre_jetty == false) ? + (uint64_t)ctx->remote_seg[0]->ubva.va + i * ctx->buf_size : + (uint64_t)ctx->remote_seg[i]->ubva.va; urma_sge_t *local_sge = &run_ctx->jfs_sge[(i * cfg->jfs_post_list + j) * PERFTEST_SGE_NUM_PRE_WR + 1]; urma_sge_t *remote_sge = &run_ctx->jfs_sge[(i * cfg->jfs_post_list + j) * PERFTEST_SGE_NUM_PRE_WR]; @@ -859,7 +869,9 @@ static void init_send_jfs_wr_sg(urma_jfs_wr_t *wr, perftest_context_t *ctx, perf uint32_t i, uint32_t j) { run_test_ctx_t *run_ctx = &ctx->run_ctx; - uint64_t lva = (uint64_t)ctx->local_buf[i] + ctx->buf_size; // Second half for local memory + uint64_t lva = (cfg->seg_pre_jetty == false) ? + (uint64_t)ctx->local_buf[0] + (cfg->jettys + i) * ctx->buf_size : + (uint64_t)ctx->local_buf[i] + ctx->buf_size; // Second half for local memory urma_sge_t *local_sge = &run_ctx->jfs_sge[(i * cfg->jfs_post_list + j) * PERFTEST_SGE_NUM_PRE_WR + 1]; // Step increased value @@ -894,8 +906,12 @@ static void init_atomic_jfs_wr(urma_jfs_wr_t *wr, perftest_context_t *ctx, perft uint32_t remainder = (ctx->page_size / PERFTEST_BUF_NUM >= align_size) ? (j % ((ctx->page_size / PERFTEST_BUF_NUM) / align_size)) : 0; - uint8_t *lva = (uint8_t *)ctx->local_buf[i] + ctx->buf_size + remainder * align_size; - uint8_t *rva = (uint8_t *)ctx->remote_seg[i]->ubva.va + remainder * align_size; + uint8_t *lva = (cfg->seg_pre_jetty == false) ? + (uint8_t *)ctx->local_buf[0] + (cfg->jettys + i) * ctx->buf_size + remainder * align_size : + (uint8_t *)ctx->local_buf[i] + ctx->buf_size + remainder * align_size; + uint8_t *rva = (cfg->seg_pre_jetty == false) ? + (uint8_t *)ctx->remote_seg[i]->ubva.va + i * ctx->buf_size + remainder * align_size : + (uint8_t *)ctx->remote_seg[i]->ubva.va + remainder * align_size; urma_sge_t *local_sge = &run_ctx->jfs_sge[(i * cfg->jfs_post_list + j) * PERFTEST_SGE_NUM_PRE_WR + 1]; urma_sge_t *remote_sge = &run_ctx->jfs_sge[(i * cfg->jfs_post_list + j) * PERFTEST_SGE_NUM_PRE_WR]; @@ -1070,7 +1086,9 @@ static void init_jfr_wr(urma_jfr_wr_t *wr, perftest_context_t *ctx, perftest_con run_test_ctx_t *run_ctx = &ctx->run_ctx; urma_sge_t *local_sge = &run_ctx->jfr_sge[(i * cfg->jfr_post_list + j) * PERFTEST_SGE_NUM_PRE_WR + 1]; - local_sge->addr = (uint64_t)ctx->local_buf[i]; + local_sge->addr = (cfg->seg_pre_jetty == false) ? + (uint64_t)ctx->local_buf[0] + (cfg->jettys + i) * ctx->buf_size : + (uint64_t)ctx->local_buf[i]; local_sge->len = cfg->size; local_sge->tseg = ctx->local_tseg[i]; @@ -1637,7 +1655,7 @@ static int run_once_jetty_send_lat(perftest_context_t *ctx, perftest_config_t *c return -1; } if (cr.status != URMA_CR_SUCCESS) { - (void)fprintf(stderr, "Failed CR status %d, scnt: %lu, rcnt: %lu", (int)cr.status, scnt, rcnt); + (void)fprintf(stderr, "Failed CR status %d, scnt: %lu, rcnt: %lu.\n", (int)cr.status, scnt, rcnt); return -1; } @@ -2023,7 +2041,7 @@ static int run_once_bw(perftest_context_t *ctx, perftest_config_t *cfg) for (int i = 0; i < cqe_cnt; i++) { cr_id = (int)cr[i].user_ctx; // todo jfs_id if (cr[i].status != URMA_CR_SUCCESS) { - (void)fprintf(stderr, "Failed CR status %d, tot_scnt: %lu, tot_ccnt: %lu", + (void)fprintf(stderr, "Failed CR status %d, tot_scnt: %lu, tot_ccnt: %lu.\n", (int)cr[i].status, tot_scnt, tot_ccnt); goto free_cr; } @@ -2182,7 +2200,7 @@ static int run_once_bw_recv(perftest_context_t *ctx, perftest_config_t *cfg) goto cleaning; } if (cr[i].status != URMA_CR_SUCCESS) { - (void)fprintf(stderr, "Failed CR status %d, rcnt: %lu\n", (int)cr[i].status, rcnt); + (void)fprintf(stderr, "Failed CR status %d, rcnt: %lu.\n", (int)cr[i].status, rcnt); ret = -1; goto cleaning; } @@ -2451,7 +2469,7 @@ static int run_once_bi_bw(perftest_context_t *ctx, perftest_config_t *cfg) goto cleaning; } if (cr_recv[i].status != URMA_CR_SUCCESS) { - (void)fprintf(stderr, "Failed CR status: %d, tot_scnt: %lu, tot_ccnt: %lu, tot_rcnt: %lu\n.", + (void)fprintf(stderr, "Failed CR status: %d, tot_scnt: %lu, tot_ccnt: %lu, tot_rcnt: %lu.\n", (int)cr_recv[i].status, tot_scnt, tot_ccnt, tot_rcnt); ret = -1; goto cleaning;