From 47dd8796a31e132f9e2b93a4f558a9f924a7388f Mon Sep 17 00:00:00 2001
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Date: Mon, 12 Jul 2021 09:57:08 -0400
Subject: [PATCH] SUNRPC: Add cond_resched() at the appropriate point in
 __rpc_execute()

Allow tasks that need to pre-empt rpciod/xprtiod to do so when it is
safe.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 net/sunrpc/sched.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index c045f63d11fa6..dc46130d46a0b 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -903,8 +903,10 @@ static void __rpc_execute(struct rpc_task *task)
 		/*
 		 * Lockless check for whether task is sleeping or not.
 		 */
-		if (!RPC_IS_QUEUED(task))
+		if (!RPC_IS_QUEUED(task)) {
+			cond_resched();
 			continue;
+		}
 
 		/*
 		 * Signalled tasks should exit rather than sleep.
-- 
2.30.2