Skip to content

Commit a3ab867

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
svcrdma: Combine list fields in struct svc_rdma_op_ctxt
Clean up: The free list and the dto_q list fields are never used at the same time. Reduce the size of struct svc_rdma_op_ctxt by combining these fields. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent aba7d14 commit a3ab867

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

include/linux/sunrpc/svc_rdma.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ extern atomic_t rdma_stat_sq_prod;
7070
* completes.
7171
*/
7272
struct svc_rdma_op_ctxt {
73-
struct list_head free;
73+
struct list_head list;
7474
struct svc_rdma_op_ctxt *read_hdr;
7575
struct svc_rdma_fastreg_mr *frmr;
7676
int hdr_count;
7777
struct xdr_buf arg;
7878
struct ib_cqe cqe;
7979
struct ib_cqe reg_cqe;
8080
struct ib_cqe inv_cqe;
81-
struct list_head dto_q;
8281
u32 byte_len;
8382
u32 position;
8483
struct svcxprt_rdma *xprt;

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -608,18 +608,16 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
608608

609609
spin_lock_bh(&rdma_xprt->sc_rq_dto_lock);
610610
if (!list_empty(&rdma_xprt->sc_read_complete_q)) {
611-
ctxt = list_entry(rdma_xprt->sc_read_complete_q.next,
612-
struct svc_rdma_op_ctxt,
613-
dto_q);
614-
list_del_init(&ctxt->dto_q);
611+
ctxt = list_first_entry(&rdma_xprt->sc_read_complete_q,
612+
struct svc_rdma_op_ctxt, list);
613+
list_del(&ctxt->list);
615614
spin_unlock_bh(&rdma_xprt->sc_rq_dto_lock);
616615
rdma_read_complete(rqstp, ctxt);
617616
goto complete;
618617
} else if (!list_empty(&rdma_xprt->sc_rq_dto_q)) {
619-
ctxt = list_entry(rdma_xprt->sc_rq_dto_q.next,
620-
struct svc_rdma_op_ctxt,
621-
dto_q);
622-
list_del_init(&ctxt->dto_q);
618+
ctxt = list_first_entry(&rdma_xprt->sc_rq_dto_q,
619+
struct svc_rdma_op_ctxt, list);
620+
list_del(&ctxt->list);
623621
} else {
624622
atomic_inc(&rdma_stat_rq_starve);
625623
clear_bit(XPT_DATA, &xprt->xpt_flags);

net/sunrpc/xprtrdma/svc_rdma_transport.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ static struct svc_rdma_op_ctxt *alloc_ctxt(struct svcxprt_rdma *xprt,
157157
ctxt = kmalloc(sizeof(*ctxt), flags);
158158
if (ctxt) {
159159
ctxt->xprt = xprt;
160-
INIT_LIST_HEAD(&ctxt->free);
161-
INIT_LIST_HEAD(&ctxt->dto_q);
160+
INIT_LIST_HEAD(&ctxt->list);
162161
}
163162
return ctxt;
164163
}
@@ -180,7 +179,7 @@ static bool svc_rdma_prealloc_ctxts(struct svcxprt_rdma *xprt)
180179
dprintk("svcrdma: No memory for RDMA ctxt\n");
181180
return false;
182181
}
183-
list_add(&ctxt->free, &xprt->sc_ctxts);
182+
list_add(&ctxt->list, &xprt->sc_ctxts);
184183
}
185184
return true;
186185
}
@@ -195,8 +194,8 @@ struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *xprt)
195194
goto out_empty;
196195

197196
ctxt = list_first_entry(&xprt->sc_ctxts,
198-
struct svc_rdma_op_ctxt, free);
199-
list_del_init(&ctxt->free);
197+
struct svc_rdma_op_ctxt, list);
198+
list_del(&ctxt->list);
200199
spin_unlock_bh(&xprt->sc_ctxt_lock);
201200

202201
out:
@@ -256,7 +255,7 @@ void svc_rdma_put_context(struct svc_rdma_op_ctxt *ctxt, int free_pages)
256255

257256
spin_lock_bh(&xprt->sc_ctxt_lock);
258257
xprt->sc_ctxt_used--;
259-
list_add(&ctxt->free, &xprt->sc_ctxts);
258+
list_add(&ctxt->list, &xprt->sc_ctxts);
260259
spin_unlock_bh(&xprt->sc_ctxt_lock);
261260
}
262261

@@ -266,8 +265,8 @@ static void svc_rdma_destroy_ctxts(struct svcxprt_rdma *xprt)
266265
struct svc_rdma_op_ctxt *ctxt;
267266

268267
ctxt = list_first_entry(&xprt->sc_ctxts,
269-
struct svc_rdma_op_ctxt, free);
270-
list_del(&ctxt->free);
268+
struct svc_rdma_op_ctxt, list);
269+
list_del(&ctxt->list);
271270
kfree(ctxt);
272271
}
273272
}
@@ -404,7 +403,7 @@ static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
404403
/* All wc fields are now known to be valid */
405404
ctxt->byte_len = wc->byte_len;
406405
spin_lock(&xprt->sc_rq_dto_lock);
407-
list_add_tail(&ctxt->dto_q, &xprt->sc_rq_dto_q);
406+
list_add_tail(&ctxt->list, &xprt->sc_rq_dto_q);
408407
spin_unlock(&xprt->sc_rq_dto_lock);
409408

410409
set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
@@ -525,7 +524,7 @@ void svc_rdma_wc_read(struct ib_cq *cq, struct ib_wc *wc)
525524

526525
read_hdr = ctxt->read_hdr;
527526
spin_lock(&xprt->sc_rq_dto_lock);
528-
list_add_tail(&read_hdr->dto_q,
527+
list_add_tail(&read_hdr->list,
529528
&xprt->sc_read_complete_q);
530529
spin_unlock(&xprt->sc_rq_dto_lock);
531530

@@ -1213,20 +1212,18 @@ static void __svc_rdma_free(struct work_struct *work)
12131212
*/
12141213
while (!list_empty(&rdma->sc_read_complete_q)) {
12151214
struct svc_rdma_op_ctxt *ctxt;
1216-
ctxt = list_entry(rdma->sc_read_complete_q.next,
1217-
struct svc_rdma_op_ctxt,
1218-
dto_q);
1219-
list_del_init(&ctxt->dto_q);
1215+
ctxt = list_first_entry(&rdma->sc_read_complete_q,
1216+
struct svc_rdma_op_ctxt, list);
1217+
list_del(&ctxt->list);
12201218
svc_rdma_put_context(ctxt, 1);
12211219
}
12221220

12231221
/* Destroy queued, but not processed recv completions */
12241222
while (!list_empty(&rdma->sc_rq_dto_q)) {
12251223
struct svc_rdma_op_ctxt *ctxt;
1226-
ctxt = list_entry(rdma->sc_rq_dto_q.next,
1227-
struct svc_rdma_op_ctxt,
1228-
dto_q);
1229-
list_del_init(&ctxt->dto_q);
1224+
ctxt = list_first_entry(&rdma->sc_rq_dto_q,
1225+
struct svc_rdma_op_ctxt, list);
1226+
list_del(&ctxt->list);
12301227
svc_rdma_put_context(ctxt, 1);
12311228
}
12321229

0 commit comments

Comments
 (0)