]> git.dujemihanovic.xyz Git - linux.git/commitdiff
sunrpc: document locking rules for svc_exit_thread()
authorNeilBrown <neilb@suse.de>
Fri, 26 Jul 2024 03:59:55 +0000 (13:59 +1000)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 20 Sep 2024 23:31:03 +0000 (19:31 -0400)
The locking required for svc_exit_thread() is not obvious, so document
it in a kdoc comment.

Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/svc.c

index 561d20a5316e073537d89b4702558c9d0f747fb3..2e148137376da5ffc0fc7fa4bbf624127592ca50 100644 (file)
@@ -945,6 +945,20 @@ void svc_rqst_release_pages(struct svc_rqst *rqstp)
        }
 }
 
+/**
+ * svc_exit_thread - finalise the termination of a sunrpc server thread
+ * @rqstp: the svc_rqst which represents the thread.
+ *
+ * When a thread started with svc_new_thread() exits it must call
+ * svc_exit_thread() as its last act.  This must be done with the
+ * service mutex held.  Normally this is held by a DIFFERENT thread, the
+ * one that is calling svc_set_num_threads() and which will wait for
+ * SP_VICTIM_REMAINS to be cleared before dropping the mutex.  If the
+ * thread exits for any reason other than svc_thread_should_stop()
+ * returning %true (which indicated that svc_set_num_threads() is
+ * waiting for it to exit), then it must take the service mutex itself,
+ * which can only safely be done using mutex_try_lock().
+ */
 void
 svc_exit_thread(struct svc_rqst *rqstp)
 {