Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
	 Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>,  Tom Talpey <tom@talpey.com>,
	Trond Myklebust <trondmy@kernel.org>,
	 Anna Schumaker <anna@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>
Cc: Sargun Dillon <sargun@meta.com>,
	linux-nfs@vger.kernel.org,  linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org,  Jeff Layton <jlayton@kernel.org>
Subject: [PATCH 4/4] sunrpc: keep a count of when there are no threads available
Date: Thu, 06 Mar 2025 07:38:16 -0500	[thread overview]
Message-ID: <20250306-nfsd-tracepoints-v1-4-4405bf41b95f@kernel.org> (raw)
In-Reply-To: <20250306-nfsd-tracepoints-v1-0-4405bf41b95f@kernel.org>

Add a new percpu counter and pool_stat that can track how often the
kernel went to wake up a thread, but they all were busy.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 include/linux/sunrpc/svc.h | 1 +
 net/sunrpc/svc.c           | 4 +++-
 net/sunrpc/svc_xprt.c      | 7 ++++---
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 74658cca0f38f21e2673c84c7bcae948ff7feea6..179dbfc86887374e1a0a2b669c5839cb622dd3f5 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -44,6 +44,7 @@ struct svc_pool {
 	struct percpu_counter	sp_messages_arrived;
 	struct percpu_counter	sp_sockets_queued;
 	struct percpu_counter	sp_threads_woken;
+	struct percpu_counter	sp_no_threads_avail;
 
 	unsigned long		sp_flags;
 } ____cacheline_aligned_in_smp;
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index e7f9c295d13c03bf28a5eeec839fd85e24f5525f..789f08022aec210b6df08036997ef801d3c73ac8 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -545,6 +545,7 @@ __svc_create(struct svc_program *prog, int nprogs, struct svc_stat *stats,
 		percpu_counter_init(&pool->sp_messages_arrived, 0, GFP_KERNEL);
 		percpu_counter_init(&pool->sp_sockets_queued, 0, GFP_KERNEL);
 		percpu_counter_init(&pool->sp_threads_woken, 0, GFP_KERNEL);
+		percpu_counter_init(&pool->sp_no_threads_avail, 0, GFP_KERNEL);
 	}
 
 	return serv;
@@ -629,6 +630,7 @@ svc_destroy(struct svc_serv **servp)
 		percpu_counter_destroy(&pool->sp_messages_arrived);
 		percpu_counter_destroy(&pool->sp_sockets_queued);
 		percpu_counter_destroy(&pool->sp_threads_woken);
+		percpu_counter_destroy(&pool->sp_no_threads_avail);
 	}
 	kfree(serv->sv_pools);
 	kfree(serv);
@@ -756,7 +758,7 @@ void svc_pool_wake_idle_thread(struct svc_pool *pool)
 		return;
 	}
 	rcu_read_unlock();
-
+	percpu_counter_inc(&pool->sp_no_threads_avail);
 }
 EXPORT_SYMBOL_GPL(svc_pool_wake_idle_thread);
 
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index ae25405d8bd22672a361d1fd3adfdcebb403f90f..b2c5a74e4609e8f4a3f5f4637dd9b46b40b79324 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -1451,15 +1451,16 @@ static int svc_pool_stats_show(struct seq_file *m, void *p)
 	struct svc_pool *pool = p;
 
 	if (p == SEQ_START_TOKEN) {
-		seq_puts(m, "# pool packets-arrived sockets-enqueued threads-woken threads-timedout\n");
+		seq_puts(m, "# pool packets-arrived sockets-enqueued threads-woken threads-timedout no-threads-avail\n");
 		return 0;
 	}
 
-	seq_printf(m, "%u %llu %llu %llu 0\n",
+	seq_printf(m, "%u %llu %llu %llu 0 %llu\n",
 		   pool->sp_id,
 		   percpu_counter_sum_positive(&pool->sp_messages_arrived),
 		   percpu_counter_sum_positive(&pool->sp_sockets_queued),
-		   percpu_counter_sum_positive(&pool->sp_threads_woken));
+		   percpu_counter_sum_positive(&pool->sp_threads_woken),
+		   percpu_counter_sum_positive(&pool->sp_no_threads_avail));
 
 	return 0;
 }

-- 
2.48.1


      parent reply	other threads:[~2025-03-06 12:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 12:38 [PATCH 0/4] nfsd: observability improvements Jeff Layton
2025-03-06 12:38 ` [PATCH 1/4] nfsd: add commit start/done tracepoints around nfsd_commit() Jeff Layton
2025-03-06 12:38 ` [PATCH 2/4] nfsd: add a tracepoint for nfsd_setattr Jeff Layton
2025-03-06 14:19   ` Chuck Lever
2025-03-06 12:38 ` [PATCH 3/4] nfsd: add some stub tracepoints around key vfs functions Jeff Layton
2025-03-06 14:29   ` Chuck Lever
2025-03-06 16:28     ` Jeff Layton
2025-03-06 17:40       ` Chuck Lever
2025-03-06 12:38 ` Jeff Layton [this message]

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=20250306-nfsd-tracepoints-v1-4-4405bf41b95f@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=okorniev@redhat.com \
    --cc=pabeni@redhat.com \
    --cc=sargun@meta.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