sp_nrthreads and sv_nrthreads are the number of threads that have been explicitly requested. Future patches will allow extra threads to be created as needed. So move the updating of these fields to code which is for updating configuration rather that code that is for starting/stopping threads. Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx> Signed-off-by: NeilBrown <neilb@xxxxxxx> --- net/sunrpc/svc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 79879b7d39cb..bd4f02b34f44 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -713,9 +713,6 @@ svc_prepare_thread(struct svc_serv *serv, struct svc_pool *pool, int node) rqstp->rq_err = -EAGAIN; /* No error yet */ - serv->sv_nrthreads += 1; - pool->sp_nrthreads += 1; - /* Protected by whatever lock the service uses when calling * svc_set_num_threads() */ @@ -815,6 +812,8 @@ svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) svc_exit_thread(rqstp); return PTR_ERR(task); } + serv->sv_nrthreads += 1; + chosen_pool->sp_nrthreads += 1; rqstp->rq_task = task; if (serv->sv_nrpools > 1) @@ -844,6 +843,8 @@ svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) victim = svc_pool_victim(serv, pool, &state); if (!victim) break; + victim->sp_nrthreads -= 1; + serv->sv_nrthreads -= 1; svc_pool_wake_idle_thread(victim); wait_on_bit(&victim->sp_flags, SP_VICTIM_REMAINS, TASK_IDLE); @@ -959,8 +960,6 @@ svc_exit_thread(struct svc_rqst *rqstp) list_del_rcu(&rqstp->rq_all); - pool->sp_nrthreads -= 1; - serv->sv_nrthreads -= 1; svc_sock_update_bufs(serv); svc_rqst_free(rqstp); -- 2.46.0