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 01/10] SQUASH: revise comments in SUNRPC: change service idle list to be an llist
Date: Wed, 30 Aug 2023 12:54:44 +1000 [thread overview]
Message-ID: <20230830025755.21292-2-neilb@suse.de> (raw)
In-Reply-To: <20230830025755.21292-1-neilb@suse.de>
Revise some comments to hopefully make the more clear and less verbose.
Signed-off-by: NeilBrown <neilb@suse.de>
---
include/linux/sunrpc/svc.h | 6 +++---
net/sunrpc/svc_xprt.c | 20 +++++++-------------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 5216f95411e3..ed20a2ea1f81 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -271,7 +271,7 @@ enum {
* @rqstp: the thread which is now busy
*
* By convention a thread is busy if rq_idle.next points to rq_idle.
- * This ensures it is not on the idle list.
+ * This will never be the case for threads on the idle list.
*/
static inline void svc_thread_set_busy(struct svc_rqst *rqstp)
{
@@ -283,9 +283,9 @@ static inline void svc_thread_set_busy(struct svc_rqst *rqstp)
* @rqstp: the thread which might be busy
*
* By convention a thread is busy if rq_idle.next points to rq_idle.
- * This ensures it is not on the idle list.
+ * This will never be the case for threads on the idle list.
*/
-static inline bool svc_thread_busy(struct svc_rqst *rqstp)
+static inline bool svc_thread_busy(const struct svc_rqst *rqstp)
{
return rqstp->rq_idle.next == &rqstp->rq_idle;
}
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 81327001e074..17c43bde35c9 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -734,22 +734,16 @@ static void svc_rqst_wait_for_work(struct svc_rqst *rqstp)
llist_add(&rqstp->rq_idle, &pool->sp_idle_threads);
if (unlikely(!rqst_should_sleep(rqstp)))
- /* maybe there were no idle threads when some work
- * became ready and so nothing was woken. We've just
- * become idle so someone can to the work - maybe us.
- * But we cannot reliably remove ourselves from the
- * idle list - we can only remove the first task which
- * might be us, and might not.
- * So remove and wake it, then schedule(). If it was
- * us, we won't sleep. If it is some other thread, they
- * will do the work.
+ /* Work just became available. This thread cannot simply
+ * choose not to sleep as it *must* wait until removed.
+ * So wake the first waiter - whether it is this
+ * thread or some other, it will get the work done.
*/
svc_pool_wake_idle_thread(pool);
- /* We mustn't continue while on the idle list, and we
- * cannot remove outselves reliably. The only "work"
- * we can do while on the idle list is to freeze.
- * So loop until someone removes us
+ /* Since a thread cannot remove itself from an llist,
+ * schedule until someone else removes @rqstp from
+ * the idle list.
*/
while (!svc_thread_busy(rqstp)) {
schedule();
--
2.41.0
next prev parent reply other threads:[~2023-08-30 2:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-30 2:54 [PATCH 00/10] SUNRPC thread management changes NeilBrown
2023-08-30 2:54 ` NeilBrown [this message]
2023-08-30 2:54 ` [PATCH 02/10] llist: add interface to check if a node is on a list NeilBrown
2023-08-30 2:54 ` [PATCH 03/10] SQUASH use new llist interfaces in SUNRPC: change service idle list to be an llist NeilBrown
2023-08-30 2:54 ` [PATCH 04/10] llist: add llist_del_first_this() NeilBrown
2023-08-30 2:54 ` [PATCH 05/10] lib: add light-weight queuing mechanism NeilBrown
2023-08-30 15:21 ` Chuck Lever
2023-09-03 23:57 ` NeilBrown
2023-08-30 15:35 ` Chuck Lever
2023-09-03 23:59 ` NeilBrown
2023-08-30 16:03 ` Chuck Lever
2023-09-04 0:02 ` NeilBrown
2023-08-30 2:54 ` [PATCH 06/10] SUNRPC: only have one thread waking up at a time NeilBrown
2023-08-30 15:28 ` Chuck Lever
2023-09-04 0:35 ` NeilBrown
2023-08-30 2:54 ` [PATCH 07/10] SUNRPC: use lwq for sp_sockets - renamed to sp_xprts NeilBrown
2023-08-30 2:54 ` [PATCH 08/10] SUNRPC: change sp_nrthreads to atomic_t NeilBrown
2023-08-30 2:54 ` [PATCH 09/10] SUNRPC: discard sp_lock NeilBrown
2023-08-30 2:54 ` [PATCH 10/10] SUNRPC: change the back-channel queue to lwq 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=20230830025755.21292-2-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