Skip to content

Commit 580a257

Browse files
neilbrownchucklever
authored andcommitted
SUNRPC: discard sp_lock
sp_lock is now only used to protect sp_all_threads. This isn't needed as sp_all_threads is only manipulated through svc_set_num_threads(), which is already serialized. Read-acccess only requires rcu_read_lock(). So no more locking is needed. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 2e8fc92 commit 580a257

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

include/linux/sunrpc/svc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
*/
3535
struct svc_pool {
3636
unsigned int sp_id; /* pool id; also node id on NUMA */
37-
spinlock_t sp_lock; /* protects all fields */
3837
struct lwq sp_xprts; /* pending transports */
3938
atomic_t sp_nrthreads; /* # of threads in pool */
4039
struct list_head sp_all_threads; /* all server threads */

net/sunrpc/svc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
511511
lwq_init(&pool->sp_xprts);
512512
INIT_LIST_HEAD(&pool->sp_all_threads);
513513
init_llist_head(&pool->sp_idle_threads);
514-
spin_lock_init(&pool->sp_lock);
515514

516515
percpu_counter_init(&pool->sp_messages_arrived, 0, GFP_KERNEL);
517516
percpu_counter_init(&pool->sp_sockets_queued, 0, GFP_KERNEL);
@@ -682,9 +681,12 @@ svc_prepare_thread(struct svc_serv *serv, struct svc_pool *pool, int node)
682681
spin_unlock_bh(&serv->sv_lock);
683682

684683
atomic_inc(&pool->sp_nrthreads);
685-
spin_lock_bh(&pool->sp_lock);
684+
685+
/* Protected by whatever lock the service uses when calling
686+
* svc_set_num_threads()
687+
*/
686688
list_add_rcu(&rqstp->rq_all, &pool->sp_all_threads);
687-
spin_unlock_bh(&pool->sp_lock);
689+
688690
return rqstp;
689691
}
690692

@@ -922,9 +924,7 @@ svc_exit_thread(struct svc_rqst *rqstp)
922924
struct svc_serv *serv = rqstp->rq_server;
923925
struct svc_pool *pool = rqstp->rq_pool;
924926

925-
spin_lock_bh(&pool->sp_lock);
926927
list_del_rcu(&rqstp->rq_all);
927-
spin_unlock_bh(&pool->sp_lock);
928928

929929
atomic_dec(&pool->sp_nrthreads);
930930

0 commit comments

Comments
 (0)