Skip to content

Commit 0740ee0

Browse files
chucklevergregkh
authored andcommitted
SUNRPC: Mitigate cond_resched() in xprt_transmit()
[ 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>
1 parent 8101c05 commit 0740ee0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/sunrpc/xprt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,18 +1520,20 @@ xprt_transmit(struct rpc_task *task)
15201520
{
15211521
struct rpc_rqst *next, *req = task->tk_rqstp;
15221522
struct rpc_xprt *xprt = req->rq_xprt;
1523-
int status;
1523+
int counter, status;
15241524

15251525
spin_lock(&xprt->queue_lock);
1526+
counter = 0;
15261527
while (!list_empty(&xprt->xmit_queue)) {
1528+
if (++counter == 20)
1529+
break;
15271530
next = list_first_entry(&xprt->xmit_queue,
15281531
struct rpc_rqst, rq_xmit);
15291532
xprt_pin_rqst(next);
15301533
spin_unlock(&xprt->queue_lock);
15311534
status = xprt_request_transmit(next, task);
15321535
if (status == -EBADMSG && next != req)
15331536
status = 0;
1534-
cond_resched();
15351537
spin_lock(&xprt->queue_lock);
15361538
xprt_unpin_rqst(next);
15371539
if (status == 0) {

0 commit comments

Comments
 (0)