Skip to content

Commit 586095d

Browse files
Sebastian Andrzej Siewiorchucklever
authored andcommitted
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 <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent e9488d5 commit 586095d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

net/sunrpc/svc_xprt.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
448448
{
449449
struct svc_pool *pool;
450450
struct svc_rqst *rqstp = NULL;
451-
int cpu;
452451

453452
if (!svc_xprt_ready(xprt))
454453
return;
@@ -461,8 +460,7 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
461460
if (test_and_set_bit(XPT_BUSY, &xprt->xpt_flags))
462461
return;
463462

464-
cpu = get_cpu();
465-
pool = svc_pool_for_cpu(xprt->xpt_server, cpu);
463+
pool = svc_pool_for_cpu(xprt->xpt_server, raw_smp_processor_id());
466464

467465
atomic_long_inc(&pool->sp_stats.packets);
468466

@@ -485,7 +483,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
485483
rqstp = NULL;
486484
out_unlock:
487485
rcu_read_unlock();
488-
put_cpu();
489486
trace_svc_xprt_enqueue(xprt, rqstp);
490487
}
491488
EXPORT_SYMBOL_GPL(svc_xprt_enqueue);

0 commit comments

Comments
 (0)