Skip to content

Commit

Permalink
SUNRPC: Mitigate cond_resched() in xprt_transmit()
Browse files Browse the repository at this point in the history
[ Upstream commit 6f9f172 ]

The original purpose of this expensive call is to prevent a long
queue of requests from blocking other work.

The cond_resched() call is unnecessary after just a single send
operation.

For longer queues, instead of invoking the kernel scheduler, simply
release the transport send lock and return to the RPC scheduler.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
chucklever authored and gregkh committed Nov 5, 2020
1 parent 8101c05 commit 0740ee0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/sunrpc/xprt.c
Expand Up @@ -1520,18 +1520,20 @@ xprt_transmit(struct rpc_task *task)
{
struct rpc_rqst *next, *req = task->tk_rqstp;
struct rpc_xprt *xprt = req->rq_xprt;
int status;
int counter, status;

spin_lock(&xprt->queue_lock);
counter = 0;
while (!list_empty(&xprt->xmit_queue)) {
if (++counter == 20)
break;
next = list_first_entry(&xprt->xmit_queue,
struct rpc_rqst, rq_xmit);
xprt_pin_rqst(next);
spin_unlock(&xprt->queue_lock);
status = xprt_request_transmit(next, task);
if (status == -EBADMSG && next != req)
status = 0;
cond_resched();
spin_lock(&xprt->queue_lock);
xprt_unpin_rqst(next);
if (status == 0) {
Expand Down

0 comments on commit 0740ee0

Please sign in to comment.