linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SUNRPC: Don't disable preemption while calling svc_pool_for_cpu().
@ 2022-05-04 17:24 Sebastian Andrzej Siewior
  2022-05-05  3:19 ` Chuck Lever III
  2022-05-09 16:56 ` Chuck Lever III
  0 siblings, 2 replies; 8+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-05-04 17:24 UTC (permalink / raw)
  To: linux-nfs
  Cc: Trond Myklebust, Anna Schumaker, Chuck Lever, Thomas Gleixner,
	Mike Galbraith

svc_xprt_enqueue() disables preemption via get_cpu() and then asks for a
pool of a specific CPU (current) via svc_pool_for_cpu().
With disabled preemption it acquires svc_pool::sp_lock, a spinlock_t,
which is a sleeping lock on PREEMPT_RT and can't be acquired with
disabled preemption.

Disabling preemption is not required here. The pool is protected with a
lock so the following list access is safe even cross-CPU. The following
iteration through svc_pool::sp_all_threads is under RCU-readlock and
remaining operations within the loop are atomic and do not rely on
disabled-preemption.

Use raw_smp_processor_id() as the argument for the requested CPU in
svc_pool_for_cpu().

Reported-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 net/sunrpc/svc_xprt.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 5b59e2103526e..79965deec5b12 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -448,7 +448,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
 {
 	struct svc_pool *pool;
 	struct svc_rqst	*rqstp = NULL;
-	int cpu;
 
 	if (!svc_xprt_ready(xprt))
 		return;
@@ -461,8 +460,7 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
 	if (test_and_set_bit(XPT_BUSY, &xprt->xpt_flags))
 		return;
 
-	cpu = get_cpu();
-	pool = svc_pool_for_cpu(xprt->xpt_server, cpu);
+	pool = svc_pool_for_cpu(xprt->xpt_server, raw_smp_processor_id());
 
 	atomic_long_inc(&pool->sp_stats.packets);
 
@@ -485,7 +483,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
 	rqstp = NULL;
 out_unlock:
 	rcu_read_unlock();
-	put_cpu();
 	trace_svc_xprt_enqueue(xprt, rqstp);
 }
 EXPORT_SYMBOL_GPL(svc_xprt_enqueue);
-- 
2.36.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-10 15:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-04 17:24 [PATCH] SUNRPC: Don't disable preemption while calling svc_pool_for_cpu() Sebastian Andrzej Siewior
2022-05-05  3:19 ` Chuck Lever III
2022-05-05  6:26   ` Sebastian Andrzej Siewior
2022-05-09 16:56 ` Chuck Lever III
2022-05-10 12:02   ` Sebastian Andrzej Siewior
2022-05-10 13:38     ` Chuck Lever III
2022-05-10 14:38       ` [PATCH v2] " Sebastian Andrzej Siewior
2022-05-10 15:43         ` Chuck Lever III

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).