SUNRPC: Don't disable preemption while calling svc_pool_for_cpu().

svc_xprt_enqueue() disables preemption via get_cpu() and then asks
for a pool of a specific CPU (current) via svc_pool_for_cpu().
While preemption is disabled, svc_xprt_enqueue() acquires
svc_pool::sp_lock with bottom-halfs disabled, which can sleep on
PREEMPT_RT.

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>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Sebastian Andrzej Siewior
2022-05-10 16:38:33 +02:00
committed by Chuck Lever
parent e9488d5ae1
commit 586095d339

View File

@@ -448,7 +448,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
{ {
struct svc_pool *pool; struct svc_pool *pool;
struct svc_rqst *rqstp = NULL; struct svc_rqst *rqstp = NULL;
int cpu;
if (!svc_xprt_ready(xprt)) if (!svc_xprt_ready(xprt))
return; return;
@@ -461,8 +460,7 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
if (test_and_set_bit(XPT_BUSY, &xprt->xpt_flags)) if (test_and_set_bit(XPT_BUSY, &xprt->xpt_flags))
return; return;
cpu = get_cpu(); pool = svc_pool_for_cpu(xprt->xpt_server, raw_smp_processor_id());
pool = svc_pool_for_cpu(xprt->xpt_server, cpu);
atomic_long_inc(&pool->sp_stats.packets); atomic_long_inc(&pool->sp_stats.packets);
@@ -485,7 +483,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
rqstp = NULL; rqstp = NULL;
out_unlock: out_unlock:
rcu_read_unlock(); rcu_read_unlock();
put_cpu();
trace_svc_xprt_enqueue(xprt, rqstp); trace_svc_xprt_enqueue(xprt, rqstp);
} }
EXPORT_SYMBOL_GPL(svc_xprt_enqueue); EXPORT_SYMBOL_GPL(svc_xprt_enqueue);