Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea7a101

Browse files
author
Trond Myklebust
committed
SUNRPC: Partial revert of commit 6f9f172
The premise of commit 6f9f172 ("SUNRPC: Mitigate cond_resched() in xprt_transmit()") was that cond_resched() is expensive and unnecessary when there has been just a single send. The point of cond_resched() is to ensure that tasks that should pre-empt this one get a chance to do so when it is safe to do so. The code prior to commit 6f9f172 failed to take into account that it was keeping a rpc_task pinned for longer than it needed to, and so rather than doing a full revert, let's just move the cond_resched. Signed-off-by: Trond Myklebust <[email protected]>
1 parent ca05cba commit ea7a101

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

net/sunrpc/xprt.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,29 +1603,31 @@ xprt_transmit(struct rpc_task *task)
16031603
{
16041604
struct rpc_rqst *next, *req = task->tk_rqstp;
16051605
struct rpc_xprt *xprt = req->rq_xprt;
1606-
int counter, status;
1606+
int status;
16071607

16081608
spin_lock(&xprt->queue_lock);
1609-
counter = 0;
1610-
while (!list_empty(&xprt->xmit_queue)) {
1611-
if (++counter == 20)
1609+
for (;;) {
1610+
next = list_first_entry_or_null(&xprt->xmit_queue,
1611+
struct rpc_rqst, rq_xmit);
1612+
if (!next)
16121613
break;
1613-
next = list_first_entry(&xprt->xmit_queue,
1614-
struct rpc_rqst, rq_xmit);
16151614
xprt_pin_rqst(next);
16161615
spin_unlock(&xprt->queue_lock);
16171616
status = xprt_request_transmit(next, task);
16181617
if (status == -EBADMSG && next != req)
16191618
status = 0;
16201619
spin_lock(&xprt->queue_lock);
16211620
xprt_unpin_rqst(next);
1622-
if (status == 0) {
1623-
if (!xprt_request_data_received(task) ||
1624-
test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
1625-
continue;
1626-
} else if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
1627-
task->tk_status = status;
1628-
break;
1621+
if (status < 0) {
1622+
if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
1623+
task->tk_status = status;
1624+
break;
1625+
}
1626+
/* Was @task transmitted, and has it received a reply? */
1627+
if (xprt_request_data_received(task) &&
1628+
!test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
1629+
break;
1630+
cond_resched_lock(&xprt->queue_lock);
16291631
}
16301632
spin_unlock(&xprt->queue_lock);
16311633
}

0 commit comments

Comments
 (0)