Skip to content

Commit

Permalink
librdmacm/cmtime: Separate cleanup of QPs and IDs
Browse files Browse the repository at this point in the history
Time the destruction of disconnect, destroy ID, and destroy QPs
separately.  This change adjusts the cleanup on the server side,
so that it can be timed as well.

Signed-off-by: Sean Hefty <shefty@nvidia.com>
  • Loading branch information
shefty committed Apr 9, 2024
1 parent 3d680b9 commit ef14aa4
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions librdmacm/examples/cmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ enum step {
STEP_CREATE_QP,
STEP_CONNECT,
STEP_DISCONNECT,
STEP_DESTROY,
STEP_DESTROY_ID,
STEP_DESTROY_QP,
STEP_CNT
};

Expand All @@ -74,7 +75,8 @@ static const char *step_str[] = {
"create qp",
"connect",
"disconnect",
"destroy"
"destroy id",
"destroy qp"
};

struct node {
Expand Down Expand Up @@ -282,9 +284,12 @@ static void req_work_handler(struct node *n)

static void disc_work_handler(struct node *n)
{
start_perf(n, STEP_DISCONNECT);
rdma_disconnect(n->id);
rdma_destroy_qp(n->id);
rdma_destroy_id(n->id);
end_perf(n, STEP_DISCONNECT);

if (disc_events >= connections)
end_time(STEP_DISCONNECT);
}

static void *wq_handler(void *arg)
Expand Down Expand Up @@ -356,10 +361,13 @@ static void cma_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
break;
case RDMA_CM_EVENT_DISCONNECTED:
disc_events++;
if (is_client())
if (is_client()) {
disc_handler(n);
else
} else {
if (disc_events == 1)
start_time(STEP_DISCONNECT);
wq_insert(&disc_wq, n);
}
break;
case RDMA_CM_EVENT_DEVICE_REMOVAL:
/* Cleanup will occur after test completes. */
Expand Down Expand Up @@ -398,14 +406,29 @@ static void destroy_ids(void)
int i;

printf("destroying id\n");
start_time(STEP_DESTROY);
start_time(STEP_DESTROY_ID);
for (i = 0; i < connections; i++) {
start_perf(&nodes[i], STEP_DESTROY);
start_perf(&nodes[i], STEP_DESTROY_ID);
if (nodes[i].id)
rdma_destroy_id(nodes[i].id);
end_perf(&nodes[i], STEP_DESTROY);
end_perf(&nodes[i], STEP_DESTROY_ID);
}
end_time(STEP_DESTROY_ID);
}

static void destroy_qps(void)
{
int i;

printf("destroying qp\n");
start_time(STEP_DESTROY_QP);
for (i = 0; i < connections; i++) {
start_perf(&nodes[i], STEP_DESTROY_QP);
if (nodes[i].id)
rdma_destroy_qp(nodes[i].id);
end_perf(&nodes[i], STEP_DESTROY_QP);
}
end_time(STEP_DESTROY);
end_time(STEP_DESTROY_QP);
}

static void *process_events(void *arg)
Expand Down Expand Up @@ -578,7 +601,6 @@ static int run_client(void)
continue;
start_perf(&nodes[i], STEP_DISCONNECT);
rdma_disconnect(nodes[i].id);
rdma_destroy_qp(nodes[i].id);
started[STEP_DISCONNECT]++;
}
while (started[STEP_DISCONNECT] != completed[STEP_DISCONNECT])
Expand Down Expand Up @@ -655,13 +677,15 @@ int main(int argc, char **argv)
if (ret)
goto freenodes;
ret = run_client();
destroy_ids();

show_perf();
} else {
ret = run_server();
}

destroy_qps();
destroy_ids();
show_perf();

freenodes:
free(nodes);
destchan:
Expand Down

0 comments on commit ef14aa4

Please sign in to comment.