All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org, netdev@vger.kernel.org
Cc: david@fromorbit.com, jlayton@redhat.com, tgraf@suug.ch
Subject: [PATCH v2 09/31] NFSD: Report the number of items evicted by the LRU walk
Date: Tue, 28 Jun 2022 14:06:44 -0400	[thread overview]
Message-ID: <165643960453.84360.17714600817178415563.stgit@manet.1015granger.net> (raw)
In-Reply-To: <165643915086.84360.2809940286726976517.stgit@manet.1015granger.net>

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/filecache.c |   13 ++++++++++---
 fs/nfsd/trace.h     |   29 +++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index 79cbbbdf8355..12f587473913 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -46,6 +46,7 @@ static DEFINE_PER_CPU(unsigned long, nfsd_file_cache_hits);
 static DEFINE_PER_CPU(unsigned long, nfsd_file_acquisitions);
 static DEFINE_PER_CPU(unsigned long, nfsd_file_releases);
 static DEFINE_PER_CPU(unsigned long, nfsd_file_total_age);
+static DEFINE_PER_CPU(unsigned long, nfsd_file_evictions);
 
 struct nfsd_fcache_disposal {
 	struct work_struct work;
@@ -452,6 +453,7 @@ nfsd_file_lru_cb(struct list_head *item, struct list_lru_one *lru,
 		goto out_skip;
 
 	list_lru_isolate_move(lru, &nf->nf_lru, head);
+	this_cpu_inc(nfsd_file_evictions);
 	return LRU_REMOVED;
 out_skip:
 	return LRU_SKIP;
@@ -482,9 +484,11 @@ static void
 nfsd_file_gc(void)
 {
 	LIST_HEAD(dispose);
+	unsigned long ret;
 
-	list_lru_walk(&nfsd_file_lru, nfsd_file_lru_cb,
-		      &dispose, LONG_MAX);
+	ret = list_lru_walk(&nfsd_file_lru, nfsd_file_lru_cb,
+			    &dispose, LONG_MAX);
+	trace_nfsd_file_gc_removed(ret, list_lru_count(&nfsd_file_lru));
 	nfsd_file_gc_dispose_list(&dispose);
 }
 
@@ -509,6 +513,7 @@ nfsd_file_lru_scan(struct shrinker *s, struct shrink_control *sc)
 
 	ret = list_lru_shrink_walk(&nfsd_file_lru, sc,
 				   nfsd_file_lru_cb, &dispose);
+	trace_nfsd_file_shrinker_removed(ret, list_lru_count(&nfsd_file_lru));
 	nfsd_file_gc_dispose_list(&dispose);
 	return ret;
 }
@@ -1085,7 +1090,7 @@ nfsd_file_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
  */
 static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
 {
-	unsigned long hits = 0, acquisitions = 0, releases = 0;
+	unsigned long hits = 0, acquisitions = 0, releases = 0, evictions = 0;
 	unsigned int i, count = 0, longest = 0;
 	unsigned long lru = 0, total_age = 0;
 
@@ -1109,6 +1114,7 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
 		acquisitions += per_cpu(nfsd_file_acquisitions, i);
 		releases += per_cpu(nfsd_file_releases, i);
 		total_age += per_cpu(nfsd_file_total_age, i);
+		evictions += per_cpu(nfsd_file_evictions, i);
 	}
 
 	seq_printf(m, "total entries: %u\n", count);
@@ -1117,6 +1123,7 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
 	seq_printf(m, "cache hits:    %lu\n", hits);
 	seq_printf(m, "acquisitions:  %lu\n", acquisitions);
 	seq_printf(m, "releases:      %lu\n", releases);
+	seq_printf(m, "evictions:     %lu\n", evictions);
 	if (releases)
 		seq_printf(m, "mean age (ms): %ld\n", total_age / releases);
 	else
diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index a60ead3b227a..5eb2643f5fcd 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -851,6 +851,35 @@ TRACE_EVENT(nfsd_file_fsnotify_handle_event,
 			__entry->nlink, __entry->mode, __entry->mask)
 );
 
+DECLARE_EVENT_CLASS(nfsd_file_lruwalk_class,
+	TP_PROTO(
+		unsigned long removed,
+		unsigned long remaining
+	),
+	TP_ARGS(removed, remaining),
+	TP_STRUCT__entry(
+		__field(unsigned long, removed)
+		__field(unsigned long, remaining)
+	),
+	TP_fast_assign(
+		__entry->removed = removed;
+		__entry->remaining = remaining;
+	),
+	TP_printk("%lu entries removed, %lu remaining",
+		__entry->removed, __entry->remaining)
+);
+
+#define DEFINE_NFSD_FILE_LRUWALK_EVENT(name)				\
+DEFINE_EVENT(nfsd_file_lruwalk_class, name,				\
+	TP_PROTO(							\
+		unsigned long removed,					\
+		unsigned long remaining					\
+	),								\
+	TP_ARGS(removed, remaining))
+
+DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_gc_removed);
+DEFINE_NFSD_FILE_LRUWALK_EVENT(nfsd_file_shrinker_removed);
+
 #include "cache.h"
 
 TRACE_DEFINE_ENUM(RC_DROPIT);



  parent reply	other threads:[~2022-06-28 18:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 18:05 [PATCH v2 00/31] Overhaul NFSD filecache Chuck Lever
2022-06-28 18:05 ` [PATCH v2 01/31] NFSD: Demote a WARN to a pr_warn() Chuck Lever
2022-06-28 18:05 ` [PATCH v2 02/31] NFSD: Report filecache LRU size Chuck Lever
2022-06-28 18:06 ` [PATCH v2 03/31] NFSD: Report count of calls to nfsd_file_acquire() Chuck Lever
2022-06-28 18:06 ` [PATCH v2 04/31] NFSD: Report count of freed filecache items Chuck Lever
2022-06-28 18:06 ` [PATCH v2 05/31] NFSD: Report average age of " Chuck Lever
2022-06-28 18:06 ` [PATCH v2 06/31] NFSD: Add nfsd_file_lru_dispose_list() helper Chuck Lever
2022-06-28 18:06 ` [PATCH v2 07/31] NFSD: Refactor nfsd_file_gc() Chuck Lever
2022-06-28 18:06 ` [PATCH v2 08/31] NFSD: Refactor nfsd_file_lru_scan() Chuck Lever
2022-06-28 18:06 ` Chuck Lever [this message]
2022-06-28 18:06 ` [PATCH v2 10/31] NFSD: Record number of flush calls Chuck Lever
2022-06-28 18:06 ` [PATCH v2 11/31] NFSD: Zero counters when the filecache is re-initialized Chuck Lever
2022-06-28 18:07 ` [PATCH v2 12/31] NFSD: Hook up the filecache stat file Chuck Lever
2022-06-28 18:07 ` [PATCH v2 13/31] NFSD: WARN when freeing an item still linked via nf_lru Chuck Lever
2022-06-28 18:07 ` [PATCH v2 14/31] NFSD: Trace filecache LRU activity Chuck Lever
2022-06-28 18:07 ` [PATCH v2 15/31] NFSD: Leave open files out of the filecache LRU Chuck Lever
2022-06-28 18:07 ` [PATCH v2 16/31] NFSD: Fix the filecache LRU shrinker Chuck Lever
2022-06-28 18:07 ` [PATCH v2 17/31] NFSD: Never call nfsd_file_gc() in foreground paths Chuck Lever
2022-06-28 18:07 ` [PATCH v2 18/31] NFSD: No longer record nf_hashval in the trace log Chuck Lever
2022-06-28 18:07 ` [PATCH v2 19/31] NFSD: Remove lockdep assertion from unhash_and_release_locked() Chuck Lever
2022-06-28 18:07 ` [PATCH v2 20/31] NFSD: nfsd_file_unhash can compute hashval from nf->nf_inode Chuck Lever
2022-06-28 18:08 ` [PATCH v2 21/31] NFSD: Refactor __nfsd_file_close_inode() Chuck Lever
2022-06-28 18:08 ` [PATCH v2 22/31] NFSD: nfsd_file_hash_remove can compute hashval Chuck Lever
2022-06-28 18:08 ` [PATCH v2 23/31] NFSD: Remove nfsd_file::nf_hashval Chuck Lever
2022-06-28 18:08 ` [PATCH v2 24/31] NFSD: Replace the "init once" mechanism Chuck Lever
2022-06-28 18:08 ` [PATCH v2 25/31] NFSD: Set up an rhashtable for the filecache Chuck Lever
2022-06-28 18:08 ` [PATCH v2 26/31] NFSD: Convert the filecache to use rhashtable Chuck Lever
2022-06-28 18:08 ` [PATCH v2 27/31] NFSD: Clean up unused code after rhashtable conversion Chuck Lever
2022-06-28 18:08 ` [PATCH v2 28/31] NFSD: Separate tracepoints for acquire and create Chuck Lever
2022-06-28 18:08 ` [PATCH v2 29/31] NFSD: Move nfsd_file_trace_alloc() tracepoint Chuck Lever
2022-06-28 18:09 ` [PATCH v2 30/31] NFSD: Update the nfsd_file_fsnotify_handle_event() tracepoint Chuck Lever
2022-06-28 18:09 ` [PATCH v2 31/31] NFSD: NFSv4 CLOSE should release an nfsd_file immediately 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=165643960453.84360.17714600817178415563.stgit@manet.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=david@fromorbit.com \
    --cc=jlayton@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.