Skip to contentSkip to conversation

nfsd: serialize filecache garbage collector

PATCH Superseded Wang Yugui 2 participants 2 messages May 30, 2022 – May 31, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wang Yugui

author
#0 lore raw

PATCH 1/1 nfsd: serialize filecache garbage collector

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.

---
 fs/nfsd/filecache.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/nfsd/filecache.c +6 -1
index f172412447f5..28a8f8d6d235 100644
@@ -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. */
+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
Signature · 1 line
2.36.1
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Wang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.18 next-20220527]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Wang-Yugui/nfsd-serialize-filecache-garbage-collector/20220530-093218
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b00ed48bb0a7c295facf9036135a573a5cdbe7de
config: x86_64-randconfig-s021 (https://download.01.org/0day-ci/archive/20220531/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-1) 11.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-14-g5a0004b5-dirty
        # https://github.com/intel-lab-lkp/linux/commit/7e2af8570695784cb8a9f9a3931dc631a9077206
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Wang-Yugui/nfsd-serialize-filecache-garbage-collector/20220530-093218
        git checkout 7e2af8570695784cb8a9f9a3931dc631a9077206
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/nfsd/

If you fix the issue, kindly add following tag where applicable

sparse warnings: (new ones prefixed by >>)

>> fs/nfsd/filecache.c:475:10: sparse: sparse: symbol 'nfsd_file_gc_running' was not declared. Should it be static?

Please review and possibly fold the followup patch.

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp