Skip to content

Commit

Permalink
librdmacm/cmtime: Move small event hander functions inline
Browse files Browse the repository at this point in the history
To simplify reading the code, move the trivial event handler
functions into the main event handler call.  This helps
make it clear that the event thread should just process the
event directly, rather than queuing to a worker thread.

Signed-off-by: Sean Hefty <shefty@nvidia.com>
  • Loading branch information
shefty committed Apr 23, 2024
1 parent a7277c0 commit 405554d
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions librdmacm/examples/cmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,6 @@ static void connect_qp(struct node *n)
}
}

static void addr_handler(struct node *n)
{
end_perf(n, STEP_RESOLVE_ADDR);
completed[STEP_RESOLVE_ADDR]++;
}

static void route_handler(struct node *n)
{
end_perf(n, STEP_RESOLVE_ROUTE);
completed[STEP_RESOLVE_ROUTE]++;
}

static void conn_handler(struct node *n)
{
int ret;
Expand Down Expand Up @@ -339,12 +327,6 @@ static void conn_handler(struct node *n)
completed[STEP_CONNECT]++;
}

static void disc_handler(struct node *n)
{
end_perf(n, STEP_DISCONNECT);
completed[STEP_DISCONNECT]++;
}

static void req_handler(struct work_item *item)
{
struct node *n = container_of(item, struct node, work);
Expand Down Expand Up @@ -406,10 +388,12 @@ static void cma_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)

switch (event->event) {
case RDMA_CM_EVENT_ADDR_RESOLVED:
addr_handler(n);
end_perf(n, STEP_RESOLVE_ADDR);
completed[STEP_RESOLVE_ADDR]++;
break;
case RDMA_CM_EVENT_ROUTE_RESOLVED:
route_handler(n);
end_perf(n, STEP_RESOLVE_ROUTE);
completed[STEP_RESOLVE_ROUTE]++;
break;
case RDMA_CM_EVENT_CONNECT_REQUEST:
if (node_index == 0) {
Expand All @@ -435,7 +419,8 @@ static void cma_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
break;
}
printf("RDMA_CM_EVENT_ADDR_ERROR, error: %d\n", event->status);
addr_handler(n);
end_perf(n, STEP_RESOLVE_ADDR);
completed[STEP_RESOLVE_ADDR]++;
n->error = 1;
break;
case RDMA_CM_EVENT_ROUTE_ERROR:
Expand All @@ -444,7 +429,8 @@ static void cma_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
break;
}
printf("RDMA_CM_EVENT_ROUTE_ERROR, error: %d\n", event->status);
route_handler(n);
end_perf(n, STEP_RESOLVE_ROUTE);
completed[STEP_RESOLVE_ROUTE]++;
n->error = 1;
break;
case RDMA_CM_EVENT_CONNECT_ERROR:
Expand All @@ -457,7 +443,8 @@ static void cma_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
break;
case RDMA_CM_EVENT_DISCONNECTED:
if (is_client()) {
disc_handler(n);
end_perf(n, STEP_DISCONNECT);
completed[STEP_DISCONNECT]++;
} else {
if (disc_events == 0) {
printf("\tDisconnecting\n");
Expand Down

0 comments on commit 405554d

Please sign in to comment.