Skip to content

Commit 2a95ce4

Browse files
committed
svcrdma: Optimize svc_rdma_cc_init()
The atomic_inc_return() in svc_rdma_send_cid_init() is expensive. Some svc_rdma_chunk_ctxt's now reside in long-lived container structures. They don't need a fresh completion ID for every I/O operation. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 28ee0ec commit 2a95ce4

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ svc_rdma_recv_ctxt_alloc(struct svcxprt_rdma *rdma)
123123
dma_addr_t addr;
124124
void *buffer;
125125

126-
ctxt = kmalloc_node(sizeof(*ctxt), GFP_KERNEL, node);
126+
ctxt = kzalloc_node(sizeof(*ctxt), GFP_KERNEL, node);
127127
if (!ctxt)
128128
goto fail0;
129129
buffer = kmalloc_node(rdma->sc_max_req_size, GFP_KERNEL, node);

net/sunrpc/xprtrdma/svc_rdma_rw.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ static int svc_rdma_rw_ctx_init(struct svcxprt_rdma *rdma,
154154
void svc_rdma_cc_init(struct svcxprt_rdma *rdma,
155155
struct svc_rdma_chunk_ctxt *cc)
156156
{
157-
svc_rdma_send_cid_init(rdma, &cc->cc_cid);
157+
struct rpc_rdma_cid *cid = &cc->cc_cid;
158+
159+
if (unlikely(!cid->ci_completion_id))
160+
svc_rdma_send_cid_init(rdma, cid);
158161

159162
INIT_LIST_HEAD(&cc->cc_rwctxts);
160163
cc->cc_sqecount = 0;
@@ -221,15 +224,13 @@ svc_rdma_write_info_alloc(struct svcxprt_rdma *rdma,
221224
{
222225
struct svc_rdma_write_info *info;
223226

224-
info = kmalloc_node(sizeof(*info), GFP_KERNEL,
227+
info = kzalloc_node(sizeof(*info), GFP_KERNEL,
225228
ibdev_to_node(rdma->sc_cm_id->device));
226229
if (!info)
227230
return info;
228231

229232
info->wi_rdma = rdma;
230233
info->wi_chunk = chunk;
231-
info->wi_seg_off = 0;
232-
info->wi_seg_no = 0;
233234
svc_rdma_cc_init(rdma, &info->wi_cc);
234235
info->wi_cc.cc_cqe.done = svc_rdma_write_done;
235236
return info;

net/sunrpc/xprtrdma/svc_rdma_sendto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ svc_rdma_send_ctxt_alloc(struct svcxprt_rdma *rdma)
122122
void *buffer;
123123
int i;
124124

125-
ctxt = kmalloc_node(struct_size(ctxt, sc_sges, rdma->sc_max_send_sges),
125+
ctxt = kzalloc_node(struct_size(ctxt, sc_sges, rdma->sc_max_send_sges),
126126
GFP_KERNEL, node);
127127
if (!ctxt)
128128
goto fail0;

0 commit comments

Comments
 (0)