Skip to content

Commit

Permalink
SUNRPC: discard sp_lock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NeilBrown authored and Chuck Lever committed Oct 16, 2023
1 parent 2e8fc92 commit 580a257
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion include/linux/sunrpc/svc.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*/
struct svc_pool {
unsigned int sp_id; /* pool id; also node id on NUMA */
spinlock_t sp_lock; /* protects all fields */
struct lwq sp_xprts; /* pending transports */
atomic_t sp_nrthreads; /* # of threads in pool */
struct list_head sp_all_threads; /* all server threads */
Expand Down
10 changes: 5 additions & 5 deletions net/sunrpc/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
lwq_init(&pool->sp_xprts);
INIT_LIST_HEAD(&pool->sp_all_threads);
init_llist_head(&pool->sp_idle_threads);
spin_lock_init(&pool->sp_lock);

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

atomic_inc(&pool->sp_nrthreads);
spin_lock_bh(&pool->sp_lock);

/* Protected by whatever lock the service uses when calling
* svc_set_num_threads()
*/
list_add_rcu(&rqstp->rq_all, &pool->sp_all_threads);
spin_unlock_bh(&pool->sp_lock);

return rqstp;
}

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

spin_lock_bh(&pool->sp_lock);
list_del_rcu(&rqstp->rq_all);
spin_unlock_bh(&pool->sp_lock);

atomic_dec(&pool->sp_nrthreads);

Expand Down

0 comments on commit 580a257

Please sign in to comment.