Skip to content

Commit a53d5cb

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
svcrdma: Avoid releasing a page in svc_xprt_release()
svc_xprt_release() invokes svc_free_res_pages(), which releases pages between rq_respages and rq_next_page. Historically, the RPC/RDMA transport has set these two pointers to be different by one, which means: - one page gets released when svc_recv returns 0. This normally happens whenever one or more RDMA Reads need to be dispatched to complete construction of an RPC Call. - one page gets released after every call to svc_send. In both cases, this released page is immediately refilled by svc_alloc_arg. There does not seem to be a reason for releasing this page. To avoid this unnecessary memory allocator traffic, set rq_next_page more carefully. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 7b4d6da commit a53d5cb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,6 @@ static void svc_rdma_build_arg_xdr(struct svc_rqst *rqstp,
366366
arg->page_base = 0;
367367
arg->buflen = ctxt->rc_byte_len;
368368
arg->len = ctxt->rc_byte_len;
369-
370-
rqstp->rq_respages = &rqstp->rq_pages[0];
371-
rqstp->rq_next_page = rqstp->rq_respages + 1;
372369
}
373370

374371
/* This accommodates the largest possible Write chunk,
@@ -730,6 +727,12 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
730727

731728
svc_rdma_build_arg_xdr(rqstp, ctxt);
732729

730+
/* Prevent svc_xprt_release from releasing pages in rq_pages
731+
* if we return 0 or an error.
732+
*/
733+
rqstp->rq_respages = rqstp->rq_pages;
734+
rqstp->rq_next_page = rqstp->rq_respages;
735+
733736
p = (__be32 *)rqstp->rq_arg.head[0].iov_base;
734737
ret = svc_rdma_xdr_decode_req(&rqstp->rq_arg);
735738
if (ret < 0)

net/sunrpc/xprtrdma/svc_rdma_sendto.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,9 @@ static void svc_rdma_save_io_pages(struct svc_rqst *rqstp,
657657
ctxt->sc_pages[i] = rqstp->rq_respages[i];
658658
rqstp->rq_respages[i] = NULL;
659659
}
660-
rqstp->rq_next_page = rqstp->rq_respages + 1;
660+
661+
/* Prevent svc_xprt_release from releasing pages in rq_pages */
662+
rqstp->rq_next_page = rqstp->rq_respages;
661663
}
662664

663665
/* Prepare the portion of the RPC Reply that will be transmitted

0 commit comments

Comments
 (0)