public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Chuck Lever <chuck.lever@oracle.com>, Jeff Layton <jlayton@kernel.org>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 09/10] SUNRPC: discard sp_lock
Date: Tue, 15 Aug 2023 11:54:25 +1000	[thread overview]
Message-ID: <20230815015426.5091-10-neilb@suse.de> (raw)
In-Reply-To: <20230815015426.5091-1-neilb@suse.de>

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 must be locked.  Read-acccess only requires rcu_read_lock().  So
no more locking is needed.

Signed-off-by: NeilBrown <neilb@suse.de>
---
 include/linux/sunrpc/svc.h |  1 -
 net/sunrpc/svc.c           | 10 +++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index c972561f5ab8..b80b698b09c5 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -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 */
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 9524af33ace9..61ea8ce7975f 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -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);
@@ -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;
 }
 
@@ -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);
 
-- 
2.40.1


  parent reply	other threads:[~2023-08-15  1:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15  1:54 [PATCH 00/10] SUNRPC: remainder of srv queueing work NeilBrown
2023-08-15  1:54 ` [PATCH 01/10] SQUASH: SUNRPC: rename and refactor svc_get_next_xprt() NeilBrown
2023-08-15  1:54 ` [PATCH 02/10] SUNRPC: add list of idle threads NeilBrown
2023-08-15  1:54 ` [PATCH 03/10] SUNRPC: discard SP_CONGESTED NeilBrown
2023-08-15  1:54 ` [PATCH 04/10] SUNRPC: change service idle list to be an llist NeilBrown
2023-08-15 16:59   ` Chuck Lever
2023-08-15 22:44     ` NeilBrown
2023-08-16 15:56       ` Chuck Lever
2023-08-15  1:54 ` [PATCH 05/10] SUNRPC: only have one thread waking up at a time NeilBrown
2023-08-15  1:54 ` [PATCH 06/10] SUNRPC/svc: add light-weight queuing mechanism NeilBrown
2023-08-17 14:41   ` Chuck Lever
2023-08-17 22:06     ` NeilBrown
2023-08-18 13:38       ` Chuck Lever
2023-08-15  1:54 ` [PATCH 07/10] SUNRPC: use lwq for sp_sockets - renamed to sp_xprts NeilBrown
2023-08-15  1:54 ` [PATCH 08/10] SUNRPC: change sp_nrthreads to atomic_t NeilBrown
2023-08-15  1:54 ` NeilBrown [this message]
2023-08-15  1:54 ` [PATCH 10/10] SUNRPC: change the back-channel queue to lwq NeilBrown
  -- strict thread matches above, loose matches on Subject: below --
2023-08-30  2:54 [PATCH 00/10] SUNRPC thread management changes NeilBrown
2023-08-30  2:54 ` [PATCH 09/10] SUNRPC: discard sp_lock NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230815015426.5091-10-neilb@suse.de \
    --to=neilb@suse.de \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox