Skip to content

Commit f995879

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Remove rpcrdma_sendctx::sc_xprt
Micro-optimization: Save eight bytes in a frequently allocated structure. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 15d9b01 commit f995879

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

net/sunrpc/xprtrdma/verbs.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
/*
7575
* internal functions
7676
*/
77-
static void rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc);
77+
static void rpcrdma_sendctx_put_locked(struct rpcrdma_xprt *r_xprt,
78+
struct rpcrdma_sendctx *sc);
7879
static void rpcrdma_reqs_reset(struct rpcrdma_xprt *r_xprt);
7980
static void rpcrdma_reps_destroy(struct rpcrdma_buffer *buf);
8081
static void rpcrdma_mrs_create(struct rpcrdma_xprt *r_xprt);
@@ -124,7 +125,7 @@ rpcrdma_qp_event_handler(struct ib_event *event, void *context)
124125

125126
/**
126127
* rpcrdma_wc_send - Invoked by RDMA provider for each polled Send WC
127-
* @cq: completion queue (ignored)
128+
* @cq: completion queue
128129
* @wc: completed WR
129130
*
130131
*/
@@ -137,7 +138,7 @@ rpcrdma_wc_send(struct ib_cq *cq, struct ib_wc *wc)
137138

138139
/* WARNING: Only wr_cqe and status are reliable at this point */
139140
trace_xprtrdma_wc_send(sc, wc);
140-
rpcrdma_sendctx_put_locked(sc);
141+
rpcrdma_sendctx_put_locked((struct rpcrdma_xprt *)cq->cq_context, sc);
141142
}
142143

143144
/**
@@ -518,7 +519,7 @@ int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
518519
init_waitqueue_head(&ep->rep_connect_wait);
519520
ep->rep_receive_count = 0;
520521

521-
sendcq = ib_alloc_cq_any(ia->ri_id->device, NULL,
522+
sendcq = ib_alloc_cq_any(ia->ri_id->device, r_xprt,
522523
ep->rep_attr.cap.max_send_wr + 1,
523524
IB_POLL_WORKQUEUE);
524525
if (IS_ERR(sendcq)) {
@@ -840,7 +841,6 @@ static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt)
840841
if (!sc)
841842
return -ENOMEM;
842843

843-
sc->sc_xprt = r_xprt;
844844
buf->rb_sc_ctxs[i] = sc;
845845
}
846846

@@ -903,17 +903,18 @@ struct rpcrdma_sendctx *rpcrdma_sendctx_get_locked(struct rpcrdma_xprt *r_xprt)
903903

904904
/**
905905
* rpcrdma_sendctx_put_locked - Release a send context
906+
* @r_xprt: controlling transport instance
906907
* @sc: send context to release
907908
*
908909
* Usage: Called from Send completion to return a sendctxt
909910
* to the queue.
910911
*
911912
* The caller serializes calls to this function (per transport).
912913
*/
913-
static void
914-
rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc)
914+
static void rpcrdma_sendctx_put_locked(struct rpcrdma_xprt *r_xprt,
915+
struct rpcrdma_sendctx *sc)
915916
{
916-
struct rpcrdma_buffer *buf = &sc->sc_xprt->rx_buf;
917+
struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
917918
unsigned long next_tail;
918919

919920
/* Unmap SGEs of previously completed but unsignaled
@@ -931,7 +932,7 @@ rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc)
931932
/* Paired with READ_ONCE */
932933
smp_store_release(&buf->rb_sc_tail, next_tail);
933934

934-
xprt_write_space(&sc->sc_xprt->rx_xprt);
935+
xprt_write_space(&r_xprt->rx_xprt);
935936
}
936937

937938
static void

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,10 @@ enum {
218218
/* struct rpcrdma_sendctx - DMA mapped SGEs to unmap after Send completes
219219
*/
220220
struct rpcrdma_req;
221-
struct rpcrdma_xprt;
222221
struct rpcrdma_sendctx {
223222
struct ib_send_wr sc_wr;
224223
struct ib_cqe sc_cqe;
225224
struct ib_device *sc_device;
226-
struct rpcrdma_xprt *sc_xprt;
227225
struct rpcrdma_req *sc_req;
228226
unsigned int sc_unmap_count;
229227
struct ib_sge sc_sges[];

0 commit comments

Comments
 (0)