Skip to content

Commit d41f4d4

Browse files
Trond Myklebustgregkh
authored andcommitted
SUNRPC: Partial revert of commit 6f9f172
commit ea7a101 upstream. 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 <trond.myklebust@hammerspace.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c7a440c commit d41f4d4

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

net/sunrpc/xprt.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,29 +1552,31 @@ xprt_transmit(struct rpc_task *task)
15521552
{
15531553
struct rpc_rqst *next, *req = task->tk_rqstp;
15541554
struct rpc_xprt *xprt = req->rq_xprt;
1555-
int counter, status;
1555+
int status;
15561556

15571557
spin_lock(&xprt->queue_lock);
1558-
counter = 0;
1559-
while (!list_empty(&xprt->xmit_queue)) {
1560-
if (++counter == 20)
1558+
for (;;) {
1559+
next = list_first_entry_or_null(&xprt->xmit_queue,
1560+
struct rpc_rqst, rq_xmit);
1561+
if (!next)
15611562
break;
1562-
next = list_first_entry(&xprt->xmit_queue,
1563-
struct rpc_rqst, rq_xmit);
15641563
xprt_pin_rqst(next);
15651564
spin_unlock(&xprt->queue_lock);
15661565
status = xprt_request_transmit(next, task);
15671566
if (status == -EBADMSG && next != req)
15681567
status = 0;
15691568
spin_lock(&xprt->queue_lock);
15701569
xprt_unpin_rqst(next);
1571-
if (status == 0) {
1572-
if (!xprt_request_data_received(task) ||
1573-
test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
1574-
continue;
1575-
} else if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
1576-
task->tk_status = status;
1577-
break;
1570+
if (status < 0) {
1571+
if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
1572+
task->tk_status = status;
1573+
break;
1574+
}
1575+
/* Was @task transmitted, and has it received a reply? */
1576+
if (xprt_request_data_received(task) &&
1577+
!test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
1578+
break;
1579+
cond_resched_lock(&xprt->queue_lock);
15781580
}
15791581
spin_unlock(&xprt->queue_lock);
15801582
}

0 commit comments

Comments
 (0)