From nobody Mon Jun 8 23:56:08 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D41D037FF64; Mon, 25 May 2026 12:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779712741; cv=none; b=SqsVGCfVyB4JpFXnr/nubxJmX1jIAlhDR8nDyT55eMQ7v1NAcIE+n+Y7NQEd24n5Fn3H8YkwdcARTAAGtz4bvK0L7g241414QM4dxenwzf24/dWwzrTNaZFfsj3PQUH3I/k5O+2EXq51VMJhod9TH5Jf6RqsTZU1PuRr7kJTNzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779712741; c=relaxed/simple; bh=lOHASzelpNwvAEmAG86+t5FwQeO+cIYotmZQw44qLCQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SycWkTGSA4kIxobYyWMBPT2ZDZjPt5JCHSHrqR4WoEKdx0l9Yb9OvHIOKMe2PQVixJT1NUsPUbFavfN0krfBV/JiZoHSA/+isboxPp2uFnFyBJBRCXHndNXSuJHXIDVGQvFXYT75OhRvviGZXC3DuqeZW0W/nPXhv7zHzck3pws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JPLSNEu6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JPLSNEu6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 965A91F000E9; Mon, 25 May 2026 12:38:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779712739; bh=9JQ6Eiu80K+GOEC9U5hLFcrnSqv2viTghgU9ZaZvwyg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=JPLSNEu6Kna8xnpgOehD+EScejuU/HX+xucO3gLjRpGHDBvv8FnPWaeq4Y1CLbHwe gV6iww8iQGWclMrD4LBfzIInhcAGPdZzlth0Hqom9iiTmuFCSv4zXj3lkaeEvVxOXz I7z8LZkxzwGl6QAzfATyzweOqI6crg66nf/gVpL4F6Sa6/PNFTMGOMkyhQa7+GmtmN Y5+CDGkeOHtncvTfc977Ey4bpNoOwUZ/3vppXakxVi3mXLl6g8C3qJjWikG2aC44Yd Jb4+DfDUwV5Y1G9Z5CuSBOQTc4jC6ni+Owng52xCFTkxmsdsEhNnTTrKvKzWgnNx6i D3Farje9IA6nQ== From: Jeff Layton Date: Mon, 25 May 2026 08:38:47 -0400 Subject: [PATCH v2 1/4] sunrpc: add per-netns per-procedure call counts to svc_stat Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260525-exportd-netlink-v2-1-40003fed450c@kernel.org> References: <20260525-exportd-netlink-v2-0-40003fed450c@kernel.org> In-Reply-To: <20260525-exportd-netlink-v2-0-40003fed450c@kernel.org> To: Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , Steve Dickson , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5305; i=jlayton@kernel.org; h=from:subject:message-id; bh=lOHASzelpNwvAEmAG86+t5FwQeO+cIYotmZQw44qLCQ=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBqFELg7Z3gs7P+yW9d+/54ljP3FutpBz97EEIQI yQPc+Caxo+JAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCahRC4AAKCRAADmhBGVaC Fe5cD/9f1hpiLpPhg7zl12RRhM7lMXIt5pgDKWsfO0Ib65/xkFzh8aMw1tFnVI6LuE7HRyjbEwm TSQy1gXf6OrPn8aXOe5HbpGDMBZj9Kj0e2Hy1GlcpE4i1sJcqqjv2J6Tfvw6KVlil7BxZUqJ757 ntoJVyOC6DzUeBT9zASpnTTPaYp8e0zj9tPHVVf8dIN3HOlG9X+HppP+ywZD4Nu48HwjH3uzGeg eb0vQzTCjZ7HjsF8qE9ubwOyZuY4VNM2eTx+D5/X+5+LO874G3mWVVDHDCNjZaK1sKn2duQzRPb vfcHxZKq/of3VYfPeqS3raCuAuPiDGhYaVmfgMUdfi4+AQ6DbZot8Kbxf0tj0tjdQbcRhlY5bBV UAQ3mlxpyM4kl125gWmjj5L7pjhS0eDGFPmrOsjwYJROf0ZxpEn+NMt1H2gieFMUzGko8oep9Lf pDNzxNkmHVCwx849EByMINSgz4iTlC1wanaz1MDmkcfW3EKY7LkRSRe/Mz0jLwA/uF02fdEaRXq YtpMBeg7GWEBpMMlKOF9I112M9k/ntoLbMRvWmLFn2wi38RG40Gi/mrjmoPIedFEInDu9CUG2JL P5QT85n0NEXFW88IccAgT/IvSUpauxtL6UFdcckh+rKoBsXjk79S22cEVNmT2cvqw/17q7sZT5Z HXbAhHemtJ35/7g== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 The existing per-procedure call counts live in global svc_version->vs_count[] arrays which are not network-namespace-aware. Add per-netns equivalents in struct svc_stat so the upcoming netlink stats interface can return namespace-scoped statistics. Add a vs_count pointer array to struct svc_stat, along with svc_stat_alloc_counts() and svc_stat_free_counts() helpers to manage per-version percpu call count arrays. Increment the per-net counter alongside the global one in svc_generic_init_request(). Call the alloc/free helpers from nfsd_net_init() and nfsd_net_exit(). Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Jeff Layton --- fs/nfsd/nfsctl.c | 8 ++++++- include/linux/sunrpc/stats.h | 6 +++++ net/sunrpc/stats.c | 54 ++++++++++++++++++++++++++++++++++++++++= ++++ net/sunrpc/svc.c | 7 ++++++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 468aad8c3af9..3aaa67b322d5 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -2445,9 +2445,12 @@ static __net_init int nfsd_net_init(struct net *net) =20 memset(&nn->nfsd_svcstats, 0, sizeof(nn->nfsd_svcstats)); nn->nfsd_svcstats.program =3D &nfsd_programs[0]; + retval =3D svc_stat_alloc_counts(&nn->nfsd_svcstats); + if (retval) + goto out_proc_error; if (!nfsd_proc_stat_init(net)) { retval =3D -ENOMEM; - goto out_proc_error; + goto out_svcstats_error; } =20 for (i =3D 0; i < sizeof(nn->nfsd_versions); i++) @@ -2465,6 +2468,8 @@ static __net_init int nfsd_net_init(struct net *net) #endif return 0; =20 +out_svcstats_error: + svc_stat_free_counts(&nn->nfsd_svcstats); out_proc_error: percpu_counter_destroy_many(nn->counter, NFSD_STATS_COUNTERS_NUM); out_repcache_error: @@ -2505,6 +2510,7 @@ static __net_exit void nfsd_net_exit(struct net *net) kfree_sensitive(nn->fh_key); nfsd_net_cb_shutdown(nn); nfsd_proc_stat_shutdown(net); + svc_stat_free_counts(&nn->nfsd_svcstats); percpu_counter_destroy_many(nn->counter, NFSD_STATS_COUNTERS_NUM); nfsd_idmap_shutdown(net); nfsd_export_shutdown(net); diff --git a/include/linux/sunrpc/stats.h b/include/linux/sunrpc/stats.h index 3ce1550d1beb..087ade905e29 100644 --- a/include/linux/sunrpc/stats.h +++ b/include/linux/sunrpc/stats.h @@ -37,9 +37,15 @@ struct svc_stat { rpcbadfmt, rpcbadauth, rpcbadclnt; + + /* Per-version per-procedure call counts (per-cpu, per-netns) */ + unsigned long __percpu **vs_count; }; =20 struct net; +int svc_stat_alloc_counts(struct svc_stat *statp); +void svc_stat_free_counts(struct svc_stat *statp); + #ifdef CONFIG_PROC_FS int rpc_proc_init(struct net *); void rpc_proc_exit(struct net *); diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index 7093e18ac26c..5bcecd2919b1 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c @@ -116,6 +116,60 @@ void svc_seq_show(struct seq_file *seq, const struct s= vc_stat *statp) } EXPORT_SYMBOL_GPL(svc_seq_show); =20 +/** + * svc_stat_alloc_counts - allocate per-netns per-version call count arrays + * @statp: svc_stat whose vs_count arrays should be allocated + * + * statp->program must be set before calling this. + * + * Returns zero on success, or a negative errno otherwise. + */ +int svc_stat_alloc_counts(struct svc_stat *statp) +{ + struct svc_program *prog =3D statp->program; + unsigned int i; + + statp->vs_count =3D kcalloc(prog->pg_nvers, + sizeof(unsigned long __percpu *), + GFP_KERNEL); + if (!statp->vs_count) + return -ENOMEM; + + for (i =3D 0; i < prog->pg_nvers; i++) { + if (!prog->pg_vers[i]) + continue; + statp->vs_count[i] =3D __alloc_percpu(prog->pg_vers[i]->vs_nproc * + sizeof(unsigned long), + sizeof(unsigned long)); + if (!statp->vs_count[i]) + goto err; + } + return 0; +err: + svc_stat_free_counts(statp); + return -ENOMEM; +} +EXPORT_SYMBOL_GPL(svc_stat_alloc_counts); + +/** + * svc_stat_free_counts - free per-netns per-version call count arrays + * @statp: svc_stat whose vs_count arrays should be freed + */ +void svc_stat_free_counts(struct svc_stat *statp) +{ + struct svc_program *prog =3D statp->program; + unsigned int i; + + if (!statp->vs_count) + return; + + for (i =3D 0; i < prog->pg_nvers; i++) + free_percpu(statp->vs_count[i]); + kfree(statp->vs_count); + statp->vs_count =3D NULL; +} +EXPORT_SYMBOL_GPL(svc_stat_free_counts); + /** * rpc_alloc_iostats - allocate an rpc_iostats structure * @clnt: RPC program, version, and xprt diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index ae9ec4bf34f7..bf7c57cbfa3d 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -1375,6 +1375,13 @@ svc_generic_init_request(struct svc_rqst *rqstp, /* Bump per-procedure stats counter */ this_cpu_inc(versp->vs_count[rqstp->rq_proc]); =20 + /* Bump per-net per-procedure stats counter */ + if (rqstp->rq_server->sv_stats && + rqstp->rq_server->sv_stats->vs_count && + rqstp->rq_server->sv_stats->vs_count[rqstp->rq_vers]) + this_cpu_inc(rqstp->rq_server->sv_stats->vs_count + [rqstp->rq_vers][rqstp->rq_proc]); + ret->dispatch =3D versp->vs_dispatch; return rpc_success; err_bad_vers: --=20 2.54.0 From nobody Mon Jun 8 23:56:08 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0747E382F1D; Mon, 25 May 2026 12:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779712742; cv=none; b=A9gM+jdPQrw7XCFo2wWetkQG/13Oeco6ZE+jxsWYSf6S8Zb1B9b89g8kHfJ7gpwa3rutlzWDj+w+Lfj/QeDeA1GDU2nw8wrEXUrDTW0cZiOn3+IxIjjvYY8HaoMYwOWbn1pmxywEG3Tx1OExyuAziXWkwaogqwGK7jsvDvWThR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779712742; c=relaxed/simple; bh=0DyK6gpsbXEKdN+zvODLIFmNbG9l/JlTuIMh+Vp/ZCY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EOOROZCzVHTEhTl1XClcMIDmmD3FZY+PyJ5RWJteBQQxcjGJqeu98BAtLyX9Y2x2SZAOGov5nKmOTlwT+93I4iPd718k7+ioPMVHjH4eo5GUBXEeKM6Q971IdrP8/seZhNr/8nJdupK2mgW8jl5VH2C1ViMhTYCaCDN0BKJMWL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Uo0GDr9R; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Uo0GDr9R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C49861F00A3C; Mon, 25 May 2026 12:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779712740; bh=7GUrlKj+2ZTyBVhmXbHZ9ccQ+KlfhqvBRavl7nGi83A=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Uo0GDr9RNR7ei/nJUwVtYH07PqMhSkZ+vZO7dX8g/lZa0RL2InCaUcDM2QlyG474L oNAQw6T0mF45qSXJP81/ar2NYvl4UC1Fczc8wCHN2zPgd+VOl3EPzmtYYk2m1VKekG 76OKSVs7qHNd+n414klvyMU5T5AwsJdX9uVpd5vAZcN9/q1ywdue3cfPzE1jEMw4tb WGKZfme/kCG5qf4zw1HbBSzbkhk1WGOX+Pd7A525kxMsa/enVmipnqftGX1yNyzn7y ZoB7Au9xWpd6PZqUuikQjfRDXRd/m/bG+au9vi9sVZqOkzykrtr92Pw9a43kWFdPtS Ln+4s8q2lT/7g== From: Jeff Layton Date: Mon, 25 May 2026 08:38:48 -0400 Subject: [PATCH v2 2/4] sunrpc: use per-net counts in svc_seq_show() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260525-exportd-netlink-v2-2-40003fed450c@kernel.org> References: <20260525-exportd-netlink-v2-0-40003fed450c@kernel.org> In-Reply-To: <20260525-exportd-netlink-v2-0-40003fed450c@kernel.org> To: Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , Steve Dickson , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1043; i=jlayton@kernel.org; h=from:subject:message-id; bh=0DyK6gpsbXEKdN+zvODLIFmNbG9l/JlTuIMh+Vp/ZCY=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBqFELgg10MtdqX5pEaWFMZuNMew5ooajBL4Q+pw AK3ULoXHFCJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCahRC4AAKCRAADmhBGVaC FZkyEACw6RwzmAlRvQpW4pmcW2YIYVgC52iL2N2Qc4LlEFQK7qy0uh43q60nUAX3tTbryEuMK1V Sz2VO263UwiNcX4QQJZkmgwnO3LrcKYYkm6qZE5odSjQt+yK90B7rTpId5xXh/whSl6f/mdIgFB +HXNx++xiEL+dYls+ObRoBUB+a5EwXqLSY67ZhsOlZwGZvUIu7SOrgyupCAJbk2zZSA1Sq/vUeg kPsUgbYV9n5Ak/xpER3DwHdguMZYG/pkVWF0hd2MqtYmF5b5lfddrGfBl/qpRCeCW2bB38YlcLY BMZx9UNYkG4BCr8X9eJgEp3msFebzP7HzODkscDLWLqbwTowki2oc066W7p0R54zfsmcWkY9Gfw ZXVz7bs1SPrNr8dvjEFR22Qfp1IfaC3Znyvz+inmqnfsvGvxqrU3KFR/QaAMiA3tYKBeK+uTBkK j4NQH7wtbghqL4pwvp8qabScwfDERIquvndjm43mntb0DrHMh7BKnBVznb8xxsA8gKAgwYk3HCx IUZ6F+AgzGKSd6Q509Np4PLEBWgbvFvb0kHjsVBfWrEHngFFSYggvdb7lNxYcUGTGRjShfOF+qC UZMLvDUY38SfcxZepf50qRX1HjUu2702lVmqSiJOFHNBMkmtRHZRTrvpMLYSNzGqMRMJ1OYqtkF MfF4ZlsFxQkyN5A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Update svc_seq_show() to read from the per-netns statp->vs_count[] arrays instead of the global svc_version->vs_count[]. The only caller is nfsd, which always allocates vs_count via svc_stat_alloc_counts() in nfsd_net_init(), so the per-netns arrays are always available. This makes /proc/net/rpc/nfsd report per-network-namespace procedure call counts. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Jeff Layton --- net/sunrpc/stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index 5bcecd2919b1..fc2db251dfa0 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c @@ -108,7 +108,7 @@ void svc_seq_show(struct seq_file *seq, const struct sv= c_stat *statp) for (j =3D 0; j < vers->vs_nproc; j++) { count =3D 0; for_each_possible_cpu(k) - count +=3D per_cpu(vers->vs_count[j], k); + count +=3D per_cpu(statp->vs_count[i][j], k); seq_printf(seq, " %lu", count); } seq_putc(seq, '\n'); --=20 2.54.0 From nobody Mon Jun 8 23:56:08 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4053838333A; Mon, 25 May 2026 12:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779712743; cv=none; b=dn8wHlaVnEgHjSBUVXwJsZkc3OJBUTj3kZH+pNathINb/cj8xp4t1+fzGz3faEpUO0OSE3bFxHniYX3aePUG/d90QqmIXlSxBOgwY9z6yQUpJW1T2JQrujHYHRB79evDnftD39sADeikEZLqM1gnnavPQXqoZ55X9Vi8B1uExio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779712743; c=relaxed/simple; bh=2esJKpdb4IQ+/3FQlqkAtQkDeAiM3QGkaIUd+9x2bfQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uNkDO4ZS3cMtzzmcB+Yol3uu8kcSOHyu6qVlYnSDtqBuL0p5xOCUJ3DXuv/jOEL7+qdXtB3eMeF0duLUX020BQwvnrvRE8bvZXVKVRYzLH9X2SOL6lcHyeirkLqLjcsBgHRxKpX9IxuMixkibcDoE9usTyuxcI7+TqvP9Zc8VYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nBn+55L0; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nBn+55L0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F39D91F00A3A; Mon, 25 May 2026 12:39:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779712741; bh=wwnwqJ6JKKPHEUzKBYI6xskOxDwr9Ik9WeFxa5gjde8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=nBn+55L0ZtDaKk1Hc6Cd5/bYtCNoP4eNUXQmeqgBtonke7LT6ETIuVopBniRQyEq+ TDx5dK4FUEcAz9CYTUzSD8fckToW8SOIJQQzckrSc4pJ9vO7fJNNEfcd93nC30Mh6T DU2e2e39zAVeU5EmHQkFqEQwUKngV/FMFj42qz2vTMLBR7/tAxbGhSlnkFTSuWK29f V/w0q/tH6MIkOPoJaPeI1v4TfM9xCI1sKQ/mZx4NzJrGPYbkSgQ7aQ8oziTQsRpK0I Nl5Ts11H4dP7HuCBYqEXxAkDBoUl1g8lUkXuYVyokTQzVAwR4SyLYmK7jjBa53CMYZ eIGJKEFUl0GMQ== From: Jeff Layton Date: Mon, 25 May 2026 08:38:49 -0400 Subject: [PATCH v2 3/4] nfsd: implement server-stats-get netlink handler Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260525-exportd-netlink-v2-3-40003fed450c@kernel.org> References: <20260525-exportd-netlink-v2-0-40003fed450c@kernel.org> In-Reply-To: <20260525-exportd-netlink-v2-0-40003fed450c@kernel.org> To: Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , Steve Dickson , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=13119; i=jlayton@kernel.org; h=from:subject:message-id; bh=2esJKpdb4IQ+/3FQlqkAtQkDeAiM3QGkaIUd+9x2bfQ=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBqFELgOYrGbTbgekqH6HmE7ltBF9BStgvbPMCGA Vgikm5Y0X2JAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCahRC4AAKCRAADmhBGVaC FdECD/9dZn/DYObyXhUNtNakUr45VKLpYePWi5Zjbgep+zbrf1RwM1WWUoSXNlWJm+5Ar4NLn7R KH6GIbq2a/FVI7FIkVwb9XKvqyjsuMjIYCoSfdYVBBRgh+n/jw1jjhYT9QPydtWd/oIamIqZMNP 3w0Fv/AnZj7y0T92paUQ0iBW99VzOfcsG4h1Q/wFK6t9fghtZg4bQNkJib5WPRfMEeGx+/LQGGI CYw4njpEnN4W85EmXa/h4g/kt7x4sU9KpDmVcnYlySJYuFTOJ4NBECkz60lf6/SRbm45oM+j8yv hWru/4+Kii5sPmgcQtr72k5BbfVO8oauGx1NLaWR6DnmrnH1GyMj0OzzMInE9lv0sIXArQ76Dji RkfQ35EmZxYFaMRPnN3p1LRpHgR4uD1gUpFW6d953xgjSoB0v+6aXGDCIe0J+IN645UXmOpUwfj WPMRfGhSvE26oauqGkA4A+5gEUFqpdDrUj9QQeyyWW7v++IP944BiuiOoL2x2kDoVz5NuFA2VAq WIHM/RZRD40AYD/5EUmAZIdApU1LwqJoFCnQR3Irkt9IqynnUq8yv1n/h+4p4tBru10noRGXwWu iYlSxqPBuIrI2IkEU209zJyS/C8wZ1yWEWzi0yT9HjWLLnoGA0DF0BYkoE1Ch+si3Znmr1zeHgz C8ah87nWpHljFgA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Implement nfsd_nl_server_stats_get_dumpit() which exposes the NFS server statistics currently available via /proc/net/rpc/nfsd through the nfsd generic netlink family. The handler uses a dump operation to stream statistics across multiple netlink messages: - First message: all scalar stats (reply cache, filehandle, IO, network, RPC) plus per-version procedure counts (proc2/3/4-ops) using per-netns vs_count arrays. - Subsequent messages: NFSv4 per-operation counts (proc4ops-ops), one entry per message, using cb->args[0] to track the current operation index across dump calls. This allows nfsstat to retrieve server statistics via netlink with a procfs fallback for older kernels. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Jeff Layton --- Documentation/netlink/specs/nfsd.yaml | 105 +++++++++++++++++ fs/nfsd/netlink.c | 5 + fs/nfsd/netlink.h | 2 + fs/nfsd/nfsctl.c | 213 ++++++++++++++++++++++++++++++= ++++ include/uapi/linux/nfsd_netlink.h | 35 ++++++ 5 files changed, 360 insertions(+) diff --git a/Documentation/netlink/specs/nfsd.yaml b/Documentation/netlink/= specs/nfsd.yaml index 8f36fadd68f7..2a89d355ee7b 100644 --- a/Documentation/netlink/specs/nfsd.yaml +++ b/Documentation/netlink/specs/nfsd.yaml @@ -330,6 +330,86 @@ attribute-sets: of which client holds the state. Intended for use after all clients have been unexported from a given path, enabling the underlying filesystem to be unmounted. + - + name: server-proc-entry + attributes: + - + name: op + type: u32 + - + name: count + type: u64 + - + name: pad + type: pad + - + name: server-stats + attributes: + - + name: rc-hits + type: u64 + - + name: rc-misses + type: u64 + - + name: rc-nocache + type: u64 + - + name: pad + type: pad + - + name: fh-stale + type: u64 + - + name: io-read + type: u64 + - + name: io-write + type: u64 + - + name: netcnt + type: u32 + - + name: netudpcnt + type: u32 + - + name: nettcpcnt + type: u32 + - + name: nettcpconn + type: u32 + - + name: rpccnt + type: u32 + - + name: rpcbadfmt + type: u32 + - + name: rpcbadauth + type: u32 + - + name: rpcbadclnt + type: u32 + - + name: proc2-ops + type: nest + nested-attributes: server-proc-entry + multi-attr: true + - + name: proc3-ops + type: nest + nested-attributes: server-proc-entry + multi-attr: true + - + name: proc4-ops + type: nest + nested-attributes: server-proc-entry + multi-attr: true + - + name: proc4ops-ops + type: nest + nested-attributes: server-proc-entry + multi-attr: true =20 operations: list: @@ -516,6 +596,31 @@ operations: request: attributes: - path + - + name: server-stats-get + doc: dump NFS server statistics + attribute-set: server-stats + dump: + reply: + attributes: + - rc-hits + - rc-misses + - rc-nocache + - fh-stale + - io-read + - io-write + - netcnt + - netudpcnt + - nettcpcnt + - nettcpconn + - rpccnt + - rpcbadfmt + - rpcbadauth + - rpcbadclnt + - proc2-ops + - proc3-ops + - proc4-ops + - proc4ops-ops =20 mcast-groups: list: diff --git a/fs/nfsd/netlink.c b/fs/nfsd/netlink.c index fbee3676d253..eba8b353f412 100644 --- a/fs/nfsd/netlink.c +++ b/fs/nfsd/netlink.c @@ -225,6 +225,11 @@ static const struct genl_split_ops nfsd_nl_ops[] =3D { .maxattr =3D NFSD_A_UNLOCK_EXPORT_PATH, .flags =3D GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, + { + .cmd =3D NFSD_CMD_SERVER_STATS_GET, + .dumpit =3D nfsd_nl_server_stats_get_dumpit, + .flags =3D GENL_CMD_CAP_DUMP, + }, }; =20 static const struct genl_multicast_group nfsd_nl_mcgrps[] =3D { diff --git a/fs/nfsd/netlink.h b/fs/nfsd/netlink.h index af41aa0d4a65..027e2953db26 100644 --- a/fs/nfsd/netlink.h +++ b/fs/nfsd/netlink.h @@ -42,6 +42,8 @@ int nfsd_nl_cache_flush_doit(struct sk_buff *skb, struct = genl_info *info); int nfsd_nl_unlock_ip_doit(struct sk_buff *skb, struct genl_info *info); int nfsd_nl_unlock_filesystem_doit(struct sk_buff *skb, struct genl_info *= info); int nfsd_nl_unlock_export_doit(struct sk_buff *skb, struct genl_info *info= ); +int nfsd_nl_server_stats_get_dumpit(struct sk_buff *skb, + struct netlink_callback *cb); =20 enum { NFSD_NLGRP_NONE, diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 3aaa67b322d5..751864d8e34e 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -2261,6 +2261,219 @@ int nfsd_nl_cache_flush_doit(struct sk_buff *skb, s= truct genl_info *info) return 0; } =20 +static int nfsd_nl_fill_proc_ops(struct sk_buff *skb, int attr, + unsigned long __percpu *counts, + unsigned int nproc) +{ + struct nlattr *nest; + unsigned int j; + int k; + + for (j =3D 0; j < nproc; j++) { + unsigned long count =3D 0; + + for_each_possible_cpu(k) + count +=3D per_cpu(counts[j], k); + + nest =3D nla_nest_start(skb, attr); + if (!nest) + return -EMSGSIZE; + if (nla_put_u32(skb, NFSD_A_SERVER_PROC_ENTRY_OP, j) || + nla_put_u64_64bit(skb, NFSD_A_SERVER_PROC_ENTRY_COUNT, + count, NFSD_A_SERVER_PROC_ENTRY_PAD)) { + nla_nest_cancel(skb, nest); + return -EMSGSIZE; + } + nla_nest_end(skb, nest); + } + + return 0; +} + +/** + * nfsd_nl_server_stats_get_dumpit - dump NFS server statistics + * @skb: reply buffer + * @cb: netlink metadata and command arguments + * + * cb->args[0] tracks the current NFSv4 operation index for proc4ops. + * A value of 0 means we haven't started yet. We emit all scalar stats + * and per-version procedure counts in the first message, then emit + * proc4ops entries filling as many as will fit per message. + * + * Returns the size of the reply or a negative errno. + */ +int nfsd_nl_server_stats_get_dumpit(struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct net *net =3D sock_net(skb->sk); + struct nfsd_net *nn =3D net_generic(net, nfsd_net_id); + struct svc_stat *statp =3D &nn->nfsd_svcstats; + struct svc_program *prog =3D statp->program; + int start =3D cb->args[0]; + void *hdr; + int ret; + + /* + * cb->args[0] =3D=3D 0: first call, emit scalar stats + procN counts + * cb->args[0] > 0: emit proc4ops entries starting from args[0] - 1 + * cb->args[0] < 0: done + */ + if (start < 0) + return 0; + + if (start =3D=3D 0) { + hdr =3D genlmsg_put(skb, NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, &nfsd_nl_family, + NLM_F_MULTI, NFSD_CMD_SERVER_STATS_GET); + if (!hdr) + return -ENOBUFS; + + /* Reply cache stats */ + { + u64 hits, misses, nocache; + + hits =3D percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_HITS]); + misses =3D percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_MISSE= S]); + nocache =3D percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_NOCA= CHE]); + ret =3D nla_put_u64_64bit(skb, NFSD_A_SERVER_STATS_RC_HITS, + hits, NFSD_A_SERVER_STATS_PAD) || + nla_put_u64_64bit(skb, NFSD_A_SERVER_STATS_RC_MISSES, + misses, NFSD_A_SERVER_STATS_PAD) || + nla_put_u64_64bit(skb, NFSD_A_SERVER_STATS_RC_NOCACHE, + nocache, NFSD_A_SERVER_STATS_PAD); + } + if (ret) + goto err_cancel; + + /* Filehandle stats */ + ret =3D nla_put_u64_64bit(skb, NFSD_A_SERVER_STATS_FH_STALE, + percpu_counter_sum_positive(&nn->counter[NFSD_STATS_FH_STALE]), + NFSD_A_SERVER_STATS_PAD); + if (ret) + goto err_cancel; + + /* IO stats */ + { + u64 rd, wr; + + rd =3D percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_READ]); + wr =3D percpu_counter_sum_positive(&nn->counter[NFSD_STATS_IO_WRITE]); + ret =3D nla_put_u64_64bit(skb, NFSD_A_SERVER_STATS_IO_READ, + rd, NFSD_A_SERVER_STATS_PAD) || + nla_put_u64_64bit(skb, NFSD_A_SERVER_STATS_IO_WRITE, + wr, NFSD_A_SERVER_STATS_PAD); + } + if (ret) + goto err_cancel; + + /* Network stats */ + ret =3D nla_put_u32(skb, NFSD_A_SERVER_STATS_NETCNT, + statp->netcnt) || + nla_put_u32(skb, NFSD_A_SERVER_STATS_NETUDPCNT, + statp->netudpcnt) || + nla_put_u32(skb, NFSD_A_SERVER_STATS_NETTCPCNT, + statp->nettcpcnt) || + nla_put_u32(skb, NFSD_A_SERVER_STATS_NETTCPCONN, + statp->nettcpconn); + if (ret) + goto err_cancel; + + /* RPC stats */ + ret =3D nla_put_u32(skb, NFSD_A_SERVER_STATS_RPCCNT, + statp->rpccnt) || + nla_put_u32(skb, NFSD_A_SERVER_STATS_RPCBADFMT, + statp->rpcbadfmt) || + nla_put_u32(skb, NFSD_A_SERVER_STATS_RPCBADAUTH, + statp->rpcbadauth) || + nla_put_u32(skb, NFSD_A_SERVER_STATS_RPCBADCLNT, + statp->rpcbadclnt); + if (ret) + goto err_cancel; + + /* Per-version procedure counts */ + if (statp->vs_count) { + static const int proc_attrs[] =3D { + [2] =3D NFSD_A_SERVER_STATS_PROC2_OPS, + [3] =3D NFSD_A_SERVER_STATS_PROC3_OPS, + [4] =3D NFSD_A_SERVER_STATS_PROC4_OPS, + }; + unsigned int i; + + for (i =3D 0; i < prog->pg_nvers && + i < ARRAY_SIZE(proc_attrs); i++) { + if (!prog->pg_vers[i] || + !statp->vs_count[i]) + continue; + if (!proc_attrs[i]) + continue; + ret =3D nfsd_nl_fill_proc_ops(skb, + proc_attrs[i], + statp->vs_count[i], + prog->pg_vers[i]->vs_nproc); + if (ret) + goto err_cancel; + } + } + + genlmsg_end(skb, hdr); + cb->args[0] =3D 1; + } + +#ifdef CONFIG_NFSD_V4 + /* NFSv4 individual operation counts */ + { + int i =3D (start > 0) ? start - 1 : 0; + + for (; i <=3D LAST_NFS4_OP; i++) { + struct percpu_counter *ctr; + struct nlattr *nest; + u64 cnt; + + ctr =3D &nn->counter[NFSD_STATS_NFS4_OP(i)]; + cnt =3D percpu_counter_sum_positive(ctr); + + hdr =3D genlmsg_put(skb, NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, + &nfsd_nl_family, NLM_F_MULTI, + NFSD_CMD_SERVER_STATS_GET); + if (!hdr) { + cb->args[0] =3D i + 1; + goto out; + } + + nest =3D nla_nest_start(skb, + NFSD_A_SERVER_STATS_PROC4OPS_OPS); + if (!nest) { + genlmsg_cancel(skb, hdr); + cb->args[0] =3D i + 1; + goto out; + } + if (nla_put_u32(skb, NFSD_A_SERVER_PROC_ENTRY_OP, + i) || + nla_put_u64_64bit(skb, + NFSD_A_SERVER_PROC_ENTRY_COUNT, + cnt, + NFSD_A_SERVER_PROC_ENTRY_PAD)) { + nla_nest_cancel(skb, nest); + genlmsg_cancel(skb, hdr); + cb->args[0] =3D i + 1; + goto out; + } + nla_nest_end(skb, nest); + genlmsg_end(skb, hdr); + } + } +#endif + + cb->args[0] =3D -1; +out: + return skb->len; + +err_cancel: + genlmsg_cancel(skb, hdr); + return ret; +} + int nfsd_cache_notify(struct cache_detail *cd, struct cache_head *h, u32 c= ache_type) { struct genlmsghdr *hdr; diff --git a/include/uapi/linux/nfsd_netlink.h b/include/uapi/linux/nfsd_ne= tlink.h index f5b75d5caba9..3d076d173b1d 100644 --- a/include/uapi/linux/nfsd_netlink.h +++ b/include/uapi/linux/nfsd_netlink.h @@ -225,6 +225,40 @@ enum { NFSD_A_UNLOCK_EXPORT_MAX =3D (__NFSD_A_UNLOCK_EXPORT_MAX - 1) }; =20 +enum { + NFSD_A_SERVER_PROC_ENTRY_OP =3D 1, + NFSD_A_SERVER_PROC_ENTRY_COUNT, + NFSD_A_SERVER_PROC_ENTRY_PAD, + + __NFSD_A_SERVER_PROC_ENTRY_MAX, + NFSD_A_SERVER_PROC_ENTRY_MAX =3D (__NFSD_A_SERVER_PROC_ENTRY_MAX - 1) +}; + +enum { + NFSD_A_SERVER_STATS_RC_HITS =3D 1, + NFSD_A_SERVER_STATS_RC_MISSES, + NFSD_A_SERVER_STATS_RC_NOCACHE, + NFSD_A_SERVER_STATS_PAD, + NFSD_A_SERVER_STATS_FH_STALE, + NFSD_A_SERVER_STATS_IO_READ, + NFSD_A_SERVER_STATS_IO_WRITE, + NFSD_A_SERVER_STATS_NETCNT, + NFSD_A_SERVER_STATS_NETUDPCNT, + NFSD_A_SERVER_STATS_NETTCPCNT, + NFSD_A_SERVER_STATS_NETTCPCONN, + NFSD_A_SERVER_STATS_RPCCNT, + NFSD_A_SERVER_STATS_RPCBADFMT, + NFSD_A_SERVER_STATS_RPCBADAUTH, + NFSD_A_SERVER_STATS_RPCBADCLNT, + NFSD_A_SERVER_STATS_PROC2_OPS, + NFSD_A_SERVER_STATS_PROC3_OPS, + NFSD_A_SERVER_STATS_PROC4_OPS, + NFSD_A_SERVER_STATS_PROC4OPS_OPS, + + __NFSD_A_SERVER_STATS_MAX, + NFSD_A_SERVER_STATS_MAX =3D (__NFSD_A_SERVER_STATS_MAX - 1) +}; + enum { NFSD_CMD_RPC_STATUS_GET =3D 1, NFSD_CMD_THREADS_SET, @@ -244,6 +278,7 @@ enum { NFSD_CMD_UNLOCK_IP, NFSD_CMD_UNLOCK_FILESYSTEM, NFSD_CMD_UNLOCK_EXPORT, + NFSD_CMD_SERVER_STATS_GET, =20 __NFSD_CMD_MAX, NFSD_CMD_MAX =3D (__NFSD_CMD_MAX - 1) --=20 2.54.0 From nobody Mon Jun 8 23:56:08 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35A633839B6; Mon, 25 May 2026 12:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779712744; cv=none; b=JqZ7ktO5Q2+EmxTpHTziQjZPqkrHI9Ec2R9mbHQyveFS0tKGGMLosYQPGbSXpMvro/aRekhNqKXnkGYQGD2VRDYS0za+cnTDx6G0M1HG85V8wi6xPJiEe4UH7/YDCtA0e3SDIvCuGh3AXRu+4Ikl6nMJtXJuxUt3Ou3+9hiOSvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779712744; c=relaxed/simple; bh=YpsnZICd+OwAEPHJWxvrCatjXdcPBTLD06TkzL/ArQ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e+f/UQJ5oiOWKEqIEg1EkIgQroJMmjH0jhCtlwLA0vPVuUVU9lxQiNU9o2zbCofXBo0YVn1yUCCNUpYbl62ZOB8aZYlDxg98zlQ3d1psPOjM4uqSFrLGuQGYyuHRfEe8nkRdN8vXSO0TvsD2NiP0FcxvvIwb4sJuUF7rTXBAgS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HcUoi8C2; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HcUoi8C2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E2311F000E9; Mon, 25 May 2026 12:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779712743; bh=adhZRUNWM2evnjf9fbjGilGijSVBjQi9Ym5pL/7Yun8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=HcUoi8C21y+TTzvW4SE+5FqcsShPTzauqTiBoMvlBpGCUB05oB0iNygkqKY+gC94n qAJrBqebqZ3Yq18DZK1Sjvi0oDBPJBET16pJ0vFECE1r1u2ERkRuhaslAbZ1rclWoJ CZUpcCVELWnrAhOk5W5XXi30YoSCViCB+jHbNhoGW5ZUl19EWnucU2BAg9035u+6L1 j+piqrBRTBIAHC0aJ5oybxcCc8RBHlhba+MyHagFpY8Zo4smPnFEb/mkH274teD+Lt pcDdfWg+4eqoQCXUNzEs27TbfRVrq7bVPlHzfT260eVAkK/pfL/dh4yFbDO67Vrzaj MbU7ZS0ClNEqg== From: Jeff Layton Date: Mon, 25 May 2026 08:38:50 -0400 Subject: [PATCH v2 4/4] sunrpc: remove unused svc_version vs_count field Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260525-exportd-netlink-v2-4-40003fed450c@kernel.org> References: <20260525-exportd-netlink-v2-0-40003fed450c@kernel.org> In-Reply-To: <20260525-exportd-netlink-v2-0-40003fed450c@kernel.org> To: Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , Steve Dickson , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=8477; i=jlayton@kernel.org; h=from:subject:message-id; bh=YpsnZICd+OwAEPHJWxvrCatjXdcPBTLD06TkzL/ArQ0=; b=kA0DAAoBAA5oQRlWghUByyZiAGoUQuGgiq5vP8l47lU9iT5VxesSi5BWLg2iMkqjQWXzfmIOU IkCMwQAAQoAHRYhBEvA17JEcbKhhOr10wAOaEEZVoIVBQJqFELhAAoJEAAOaEEZVoIVncQQANCc /xUqk/r6lTtjmMXKZQqGndZ+oT7WPOGZo474tYvsoH3CWJfibC6wiTFrHiWHjj19LbEkrBD+kUk RoY0QVXHPNBcMLPBQA3kROCMGpLuqSd1E3+3ecGQfkV+FSI4y+7x+Ke6YpQKfDFmW0pnv5ogdRE ttwOhRNVter85MJEjN164c0D++vSub7C4oozCtbIvIWEf1h3yTXiy1fx9/TxfCYp4YLEkbm5/l3 HxGjI5xVwEdy3gvyPsfBl2BJzasj6PnU3ESs+YkDRsHN5zVJsf7f8if6oeKVzj4QY7Sc5S3PfI9 cBD93Grxk8MKJ6xuJN+5fQDHT7Zt0BfTbT+urZrCWYIQ+LxOV7l3/AQk/5BtAX4WKq6JzRuyqxg D14GnW9+ZnO73f7fFr/Qe/ArWqrLxZevG4wDHdf8mqrWiGM92BjiKEpldEY89tdt/1myde5/2xE 7gidimm70jYo9/alkE1EE5vjr/ovGtHpmoa/wa4DvDSahwHHmRu0VSKOUS/QP3oHdurVPOf0zfn FW85/FNUocBySE08TK66HNazfyxUG4YpkqowAjzs3SuYXAQVi6Xj1E+wa4kDhFCM7XXu9aE7RZP Lw4IOQ7W2qn1hkNVnQdWtVlpmlhfmHHQOIx0VTWYwYMm2O7OX7O51oUq+iOW8pXo5U708NbIqlB YHWZQ X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Now that svc_seq_show() and the nfsd netlink stats handler both use the per-netns svc_stat vs_count arrays, the global per-version vs_count percpu counters are no longer read by anything. Remove the vs_count field from struct svc_version and all the associated DEFINE_PER_CPU_ALIGNED arrays and initializers across nfsd, lockd, and the NFS client callback service. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Jeff Layton --- fs/lockd/svc4proc.c | 4 ---- fs/lockd/svcproc.c | 7 ------- fs/nfs/callback_xdr.c | 6 ------ fs/nfsd/localio.c | 3 --- fs/nfsd/nfs2acl.c | 3 --- fs/nfsd/nfs3acl.c | 3 --- fs/nfsd/nfs3proc.c | 3 --- fs/nfsd/nfs4proc.c | 3 --- fs/nfsd/nfsproc.c | 3 --- include/linux/sunrpc/svc.h | 1 - net/sunrpc/svc.c | 3 --- 11 files changed, 39 deletions(-) diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 78e675470c4b..8910ee9c2c24 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -1420,14 +1420,10 @@ union nlm4svc_xdrstore { struct nlm4_shareres_wrapper shareres; }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nlm4svc_call_counters[ARRAY_SIZE(nlm4svc_procedures)]); - const struct svc_version nlmsvc_version4 =3D { .vs_vers =3D 4, .vs_nproc =3D ARRAY_SIZE(nlm4svc_procedures), .vs_proc =3D nlm4svc_procedures, - .vs_count =3D nlm4svc_call_counters, .vs_dispatch =3D nlmsvc_dispatch, .vs_xdrsize =3D sizeof(union nlm4svc_xdrstore), }; diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index 4836887f11ef..8f81d95fc5ff 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -1433,25 +1433,18 @@ union nlmsvc_xdrstore { * NLMv1 defines only procedures 1 - 15. Linux lockd also implements * procedures 0 (NULL) and 16 (SM_NOTIFY). */ -static DEFINE_PER_CPU_ALIGNED(unsigned long, nlm1svc_call_counters[17]); - const struct svc_version nlmsvc_version1 =3D { .vs_vers =3D 1, .vs_nproc =3D 17, .vs_proc =3D nlmsvc_procedures, - .vs_count =3D nlm1svc_call_counters, .vs_dispatch =3D nlmsvc_dispatch, .vs_xdrsize =3D sizeof(union nlmsvc_xdrstore), }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nlm3svc_call_counters[ARRAY_SIZE(nlmsvc_procedures)]); - const struct svc_version nlmsvc_version3 =3D { .vs_vers =3D 3, .vs_nproc =3D ARRAY_SIZE(nlmsvc_procedures), .vs_proc =3D nlmsvc_procedures, - .vs_count =3D nlm3svc_call_counters, .vs_dispatch =3D nlmsvc_dispatch, .vs_xdrsize =3D sizeof(union nlmsvc_xdrstore), }; diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 4382baddc9ee..eec6040556c9 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c @@ -1090,26 +1090,20 @@ static const struct svc_procedure nfs4_callback_pro= cedures1[] =3D { } }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfs4_callback_count1[ARRAY_SIZE(nfs4_callback_procedures1)]); const struct svc_version nfs4_callback_version1 =3D { .vs_vers =3D 1, .vs_nproc =3D ARRAY_SIZE(nfs4_callback_procedures1), .vs_proc =3D nfs4_callback_procedures1, - .vs_count =3D nfs4_callback_count1, .vs_xdrsize =3D NFS4_CALLBACK_XDRSIZE, .vs_dispatch =3D nfs_callback_dispatch, .vs_hidden =3D true, .vs_need_cong_ctrl =3D true, }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfs4_callback_count4[ARRAY_SIZE(nfs4_callback_procedures1)]); const struct svc_version nfs4_callback_version4 =3D { .vs_vers =3D 4, .vs_nproc =3D ARRAY_SIZE(nfs4_callback_procedures1), .vs_proc =3D nfs4_callback_procedures1, - .vs_count =3D nfs4_callback_count4, .vs_xdrsize =3D NFS4_CALLBACK_XDRSIZE, .vs_dispatch =3D nfs_callback_dispatch, .vs_hidden =3D true, diff --git a/fs/nfsd/localio.c b/fs/nfsd/localio.c index be710d809a3b..81cb245c45b6 100644 --- a/fs/nfsd/localio.c +++ b/fs/nfsd/localio.c @@ -204,14 +204,11 @@ static const struct svc_procedure localio_procedures1= [] =3D { }; =20 #define LOCALIO_NR_PROCEDURES ARRAY_SIZE(localio_procedures1) -static DEFINE_PER_CPU_ALIGNED(unsigned long, - localio_count[LOCALIO_NR_PROCEDURES]); const struct svc_version localio_version1 =3D { .vs_vers =3D 1, .vs_nproc =3D LOCALIO_NR_PROCEDURES, .vs_proc =3D localio_procedures1, .vs_dispatch =3D nfsd_dispatch, - .vs_count =3D localio_count, .vs_xdrsize =3D XDR_QUADLEN(UUID_SIZE), .vs_hidden =3D true, }; diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 76305b86c1a9..eb8095c5c22d 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -384,13 +384,10 @@ static const struct svc_procedure nfsd_acl_procedures= 2[5] =3D { }, }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)]); const struct svc_version nfsd_acl_version2 =3D { .vs_vers =3D 2, .vs_nproc =3D ARRAY_SIZE(nfsd_acl_procedures2), .vs_proc =3D nfsd_acl_procedures2, - .vs_count =3D nfsd_acl_count2, .vs_dispatch =3D nfsd_dispatch, .vs_xdrsize =3D NFS3_SVC_XDRSIZE, }; diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index e87731380be8..a7029914d7ba 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c @@ -273,13 +273,10 @@ static const struct svc_procedure nfsd_acl_procedures= 3[3] =3D { }, }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfsd_acl_count3[ARRAY_SIZE(nfsd_acl_procedures3)]); const struct svc_version nfsd_acl_version3 =3D { .vs_vers =3D 3, .vs_nproc =3D ARRAY_SIZE(nfsd_acl_procedures3), .vs_proc =3D nfsd_acl_procedures3, - .vs_count =3D nfsd_acl_count3, .vs_dispatch =3D nfsd_dispatch, .vs_xdrsize =3D NFS3_SVC_XDRSIZE, }; diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index aeda7a802bdf..2d5ab2178702 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -1068,13 +1068,10 @@ static const struct svc_procedure nfsd_procedures3[= 22] =3D { }, }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfsd_count3[ARRAY_SIZE(nfsd_procedures3)]); const struct svc_version nfsd_version3 =3D { .vs_vers =3D 3, .vs_nproc =3D ARRAY_SIZE(nfsd_procedures3), .vs_proc =3D nfsd_procedures3, .vs_dispatch =3D nfsd_dispatch, - .vs_count =3D nfsd_count3, .vs_xdrsize =3D NFS3_SVC_XDRSIZE, }; diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 34f2921e4ef8..9ddebfd0dd29 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -4122,13 +4122,10 @@ static const struct svc_procedure nfsd_procedures4[= 2] =3D { }, }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfsd_count4[ARRAY_SIZE(nfsd_procedures4)]); const struct svc_version nfsd_version4 =3D { .vs_vers =3D 4, .vs_nproc =3D ARRAY_SIZE(nfsd_procedures4), .vs_proc =3D nfsd_procedures4, - .vs_count =3D nfsd_count4, .vs_dispatch =3D nfsd_dispatch, .vs_xdrsize =3D NFS4_SVC_XDRSIZE, .vs_rpcb_optnl =3D true, diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 8873033d1e82..9efd261fae45 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -838,13 +838,10 @@ static const struct svc_procedure nfsd_procedures2[18= ] =3D { }, }; =20 -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfsd_count2[ARRAY_SIZE(nfsd_procedures2)]); const struct svc_version nfsd_version2 =3D { .vs_vers =3D 2, .vs_nproc =3D ARRAY_SIZE(nfsd_procedures2), .vs_proc =3D nfsd_procedures2, - .vs_count =3D nfsd_count2, .vs_dispatch =3D nfsd_dispatch, .vs_xdrsize =3D NFS2_SVC_XDRSIZE, }; diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 4be6204f6630..db9ee1d3a50b 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -408,7 +408,6 @@ struct svc_version { u32 vs_vers; /* version number */ u32 vs_nproc; /* number of procedures */ const struct svc_procedure *vs_proc; /* per-procedure info */ - unsigned long __percpu *vs_count; /* call counts */ u32 vs_xdrsize; /* xdrsize needed for this version */ =20 /* Don't register with rpcbind */ diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index bf7c57cbfa3d..caaca2cd7fcf 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -1372,9 +1372,6 @@ svc_generic_init_request(struct svc_rqst *rqstp, memset(rqstp->rq_argp, 0, procp->pc_argzero); memset(rqstp->rq_resp, 0, procp->pc_ressize); =20 - /* Bump per-procedure stats counter */ - this_cpu_inc(versp->vs_count[rqstp->rq_proc]); - /* Bump per-net per-procedure stats counter */ if (rqstp->rq_server->sv_stats && rqstp->rq_server->sv_stats->vs_count && --=20 2.54.0