From: Jeff Layton <jlayton@kernel.org>
To: Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>, NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Chuck Lever <cel@kernel.org>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Jeff Layton <jlayton@kernel.org>
Subject: [PATCH v5 4/5] sunrpc: tear down pool counters before dropping the pool map reference
Date: Mon, 06 Jul 2026 09:29:24 -0400 [thread overview]
Message-ID: <20260706-sunrpc-pool-mode-v5-4-6c4ee7cd89aa@kernel.org> (raw)
In-Reply-To: <20260706-sunrpc-pool-mode-v5-0-6c4ee7cd89aa@kernel.org>
svc_destroy() drops the service's reference to the global svc_pool_map
before iterating serv->sv_pools[] to destroy each pool's percpu counters.
That ordering happens to be fine today because the loop is bounded by the
per-service sv_nrpools field.
A following patch removes sv_nrpools and derives the pool count from the
pool map instead. svc_pool_map_put() zeroes svc_pool_map.npools when the
last reference is dropped, so a derived loop bound would read as zero for
the last pooled service and skip svc_pool_destroy_counters() entirely,
leaking the percpu counters (which remain linked on the global
percpu_counters list while the svc_serv is freed).
Reorder svc_destroy() to destroy the pool counters while the map is still
referenced, then drop the reference. No functional change.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
net/sunrpc/svc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 2d1cdf55c561..ece69cb0138a 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -520,14 +520,15 @@ svc_destroy(struct svc_serv **servp)
cache_clean_deferred(serv);
- if (serv->sv_is_pooled)
- svc_pool_map_put();
-
for (i = 0; i < serv->sv_nrpools; i++) {
struct svc_pool *pool = &serv->sv_pools[i];
svc_pool_destroy_counters(pool);
}
+
+ if (serv->sv_is_pooled)
+ svc_pool_map_put();
+
kfree(serv->sv_pools);
kfree(serv);
}
--
2.55.0
next prev parent reply other threads:[~2026-07-06 13:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 13:29 [PATCH v5 0/5] sunrpc: hardcode pool_mode to pernode, remove other modes Jeff Layton
2026-07-06 13:29 ` [PATCH v5 1/5] sunrpc: route to a populated pool in svc_pool_for_cpu() Jeff Layton
2026-07-06 13:29 ` [PATCH v5 2/5] sunrpc: hardcode pool_mode to pernode, remove other modes Jeff Layton
2026-07-06 13:29 ` [PATCH v5 3/5] sunrpc: guarantee a thread per pool when auto-distributing Jeff Layton
2026-07-06 13:29 ` Jeff Layton [this message]
2026-07-06 13:29 ` [PATCH v5 5/5] sunrpc: derive the pool count instead of caching it in sv_nrpools Jeff Layton
2026-07-06 22:50 ` NeilBrown
2026-07-06 22:59 ` Jeff Layton
2026-07-06 20:50 ` [PATCH v5 0/5] sunrpc: hardcode pool_mode to pernode, remove other modes Chuck Lever
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=20260706-sunrpc-pool-mode-v5-4-6c4ee7cd89aa@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=anna@kernel.org \
--cc=cel@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
--cc=trondmy@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