All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nfsd: serialize filecache garbage collector
@ 2022-05-31 10:34 Wang Yugui
  2022-05-31 14:12 ` Chuck Lever III
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Yugui @ 2022-05-31 10:34 UTC (permalink / raw)
  To: linux-nfs; +Cc: Wang Yugui

When many(>NFSD_FILE_LRU_THRESHOLD) files are kept as OPEN, such as
xfstests generic/531, nfsd proceses are in CPU high-load state,
and nfsd_file_gc(nfsd filecache garbage collector) waste many CPU times.

concurrency nfsd_file_gc() is almost meaningless, so serialize it.

Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
---
Changes since v1:
- add static to 'atomic_t nfsd_file_gc_running'.
  thanks for kernel test robot <lkp@intel.com>

 fs/nfsd/filecache.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index f172412447f5..28a8f8d6d235 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -471,10 +471,15 @@ nfsd_file_lru_walk_list(struct shrink_control *sc)
 	return ret;
 }
 
+/* concurrency nfsd_file_gc() is almost meaningless, so serialize it. */
+static atomic_t nfsd_file_gc_running = ATOMIC_INIT(0);
 static void
 nfsd_file_gc(void)
 {
-	nfsd_file_lru_walk_list(NULL);
+	if(atomic_cmpxchg(&nfsd_file_gc_running, 0, 1) == 0) {
+		nfsd_file_lru_walk_list(NULL);
+		atomic_set(&nfsd_file_gc_running, 0);
+	}
 }
 
 static void
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-31 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-31 10:34 [PATCH v2] nfsd: serialize filecache garbage collector Wang Yugui
2022-05-31 14:12 ` Chuck Lever III
2022-05-31 14:44   ` Wang Yugui

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.